Automattic /
jetpack
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | new WPCOM_JSON_API_Bulk_Restore_Post_Endpoint( array( |
||
| 4 | 'description' => 'Restore multiple posts.', |
||
| 5 | 'group' => 'posts', |
||
| 6 | 'stat' => 'posts:1:bulk-restore', |
||
| 7 | 'min_version' => '1.1', |
||
| 8 | 'max_version' => '1.1', |
||
| 9 | 'method' => 'POST', |
||
| 10 | 'path' => '/sites/%s/posts/restore', |
||
| 11 | 'path_labels' => array( |
||
| 12 | '$site' => '(int|string) Site ID or domain', |
||
| 13 | ), |
||
| 14 | 'request_format' => array( |
||
| 15 | 'post_ids' => '(array|string) An array, or comma-separated list, of Post IDs to restore.', |
||
| 16 | ), |
||
| 17 | |||
| 18 | 'response_format' => array( |
||
| 19 | 'results' => '(object) An object containing results, ' |
||
| 20 | ), |
||
| 21 | |||
| 22 | 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/restore', |
||
| 23 | |||
| 24 | 'example_request_data' => array( |
||
| 25 | 'headers' => array( |
||
| 26 | 'authorization' => 'Bearer YOUR_API_TOKEN' |
||
| 27 | ), |
||
| 28 | |||
| 29 | 'body' => array( |
||
| 30 | 'post_ids' => array( 881, 882 ), |
||
| 31 | ), |
||
| 32 | |||
| 33 | ) |
||
| 34 | ) ); |
||
| 35 | |||
| 36 | View Code Duplication | class WPCOM_JSON_API_Bulk_Restore_Post_Endpoint extends WPCOM_JSON_API_Update_Post_v1_1_Endpoint { |
|
| 37 | // /sites/%s/posts/restore |
||
| 38 | // The unused $object parameter is for making the method signature compatible with its parent class method. |
||
| 39 | function callback( $path = '', $blog_id = 0, $object = null ) { |
||
| 40 | $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); |
||
| 41 | if ( is_wp_error( $blog_id ) ) { |
||
| 42 | return $blog_id; |
||
| 43 | } |
||
| 44 | |||
| 45 | $input = $this->input(); |
||
| 46 | |||
| 47 | if ( is_array( $input['post_ids'] ) ) { |
||
| 48 | $post_ids = (array) $input['post_ids']; |
||
| 49 | } else if ( ! empty( $input['post_ids'] ) ) { |
||
| 50 | $post_ids = explode( ',', $input['post_ids'] ); |
||
| 51 | } else { |
||
| 52 | $post_ids = array(); |
||
| 53 | } |
||
| 54 | |||
| 55 | if ( count( $post_ids ) < 1 ) { |
||
| 56 | return new WP_Error( 'empty_post_ids', 'The request must include post_ids' ); |
||
|
0 ignored issues
–
show
|
|||
| 57 | } |
||
| 58 | |||
| 59 | $result = array( |
||
| 60 | 'results' => array(), |
||
| 61 | ); |
||
| 62 | |||
| 63 | foreach( $post_ids as $post_id ) { |
||
| 64 | $result['results'][ $post_id ] = $this->restore_post( $path, $blog_id, $post_id ); |
||
| 65 | } |
||
| 66 | |||
| 67 | return $result; |
||
| 68 | } |
||
| 69 | } |
||
| 70 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.