Make WordPress Core

Changeset 50353


Ignore:
Timestamp:
02/16/2021 05:01:46 PM (4 years ago)
Author:
SergeyBiryukov
Message:

XML-RPC: Pass the method arguments and the XML-RPC server instance to the xmlrpc_call action.

This provides better context and makes the action easier to use when the call passes specific content in the payload of the request.

Props dd32.
Fixes #52524.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r49927 r50353  
    682682         *
    683683         * @since 2.5.0
     684         * @since 5.7.0 Added the `$args` and `$server` parameters.
    684685         *
    685          * @param string $name The method name.
     686         * @param string           $name   The method name.
     687         * @param array|string     $args   The escaped arguments passed to the method.
     688         * @param wp_xmlrpc_server $server The XML-RPC server instance.
    686689         */
    687         do_action( 'xmlrpc_call', 'wp.getUsersBlogs' );
     690        do_action( 'xmlrpc_call', 'wp.getUsersBlogs', $args, $this );
    688691
    689692        $blogs           = (array) get_blogs_of_user( $user->ID );
     
    12951298
    12961299        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    1297         do_action( 'xmlrpc_call', 'wp.newPost' );
     1300        do_action( 'xmlrpc_call', 'wp.newPost', $args, $this );
    12981301
    12991302        unset( $content_struct['ID'] );
     
    16881691
    16891692        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    1690         do_action( 'xmlrpc_call', 'wp.editPost' );
     1693        do_action( 'xmlrpc_call', 'wp.editPost', $args, $this );
    16911694
    16921695        $post = get_post( $post_id, ARRAY_A );
     
    17711774
    17721775        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    1773         do_action( 'xmlrpc_call', 'wp.deletePost' );
     1776        do_action( 'xmlrpc_call', 'wp.deletePost', $args, $this );
    17741777
    17751778        $post = get_post( $post_id, ARRAY_A );
     
    18711874
    18721875        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    1873         do_action( 'xmlrpc_call', 'wp.getPost' );
     1876        do_action( 'xmlrpc_call', 'wp.getPost', $args, $this );
    18741877
    18751878        $post = get_post( $post_id, ARRAY_A );
     
    19321935
    19331936        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    1934         do_action( 'xmlrpc_call', 'wp.getPosts' );
     1937        do_action( 'xmlrpc_call', 'wp.getPosts', $args, $this );
    19351938
    19361939        $query = array();
     
    20312034
    20322035        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    2033         do_action( 'xmlrpc_call', 'wp.newTerm' );
     2036        do_action( 'xmlrpc_call', 'wp.newTerm', $args, $this );
    20342037
    20352038        if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) {
     
    21362139
    21372140        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    2138         do_action( 'xmlrpc_call', 'wp.editTerm' );
     2141        do_action( 'xmlrpc_call', 'wp.editTerm', $args, $this );
    21392142
    21402143        if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) {
     
    22522255
    22532256        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    2254         do_action( 'xmlrpc_call', 'wp.deleteTerm' );
     2257        do_action( 'xmlrpc_call', 'wp.deleteTerm', $args, $this );
    22552258
    22562259        if ( ! taxonomy_exists( $taxonomy ) ) {
     
    23312334
    23322335        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    2333         do_action( 'xmlrpc_call', 'wp.getTerm' );
     2336        do_action( 'xmlrpc_call', 'wp.getTerm', $args, $this );
    23342337
    23352338        if ( ! taxonomy_exists( $taxonomy ) ) {
     
    23962399
    23972400        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    2398         do_action( 'xmlrpc_call', 'wp.getTerms' );
     2401        do_action( 'xmlrpc_call', 'wp.getTerms', $args, $this );
    23992402
    24002403        if ( ! taxonomy_exists( $taxonomy ) ) {
     
    25022505
    25032506        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    2504         do_action( 'xmlrpc_call', 'wp.getTaxonomy' );
     2507        do_action( 'xmlrpc_call', 'wp.getTaxonomy', $args, $this );
    25052508
    25062509        if ( ! taxonomy_exists( $taxonomy ) ) {
     
    25602563
    25612564        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    2562         do_action( 'xmlrpc_call', 'wp.getTaxonomies' );
     2565        do_action( 'xmlrpc_call', 'wp.getTaxonomies', $args, $this );
    25632566
    25642567        $taxonomies = get_taxonomies( $filter, 'objects' );
     
    26462649
    26472650        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    2648         do_action( 'xmlrpc_call', 'wp.getUser' );
     2651        do_action( 'xmlrpc_call', 'wp.getUser', $args, $this );
    26492652
    26502653        if ( ! current_user_can( 'edit_user', $user_id ) ) {
     
    27092712
    27102713        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    2711         do_action( 'xmlrpc_call', 'wp.getUsers' );
     2714        do_action( 'xmlrpc_call', 'wp.getUsers', $args, $this );
    27122715
    27132716        if ( ! current_user_can( 'list_users' ) ) {
     
    27892792
    27902793        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    2791         do_action( 'xmlrpc_call', 'wp.getProfile' );
     2794        do_action( 'xmlrpc_call', 'wp.getProfile', $args, $this );
    27922795
    27932796        if ( ! current_user_can( 'edit_user', $user->ID ) ) {
     
    28392842
    28402843        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    2841         do_action( 'xmlrpc_call', 'wp.editProfile' );
     2844        do_action( 'xmlrpc_call', 'wp.editProfile', $args, $this );
    28422845
    28432846        if ( ! current_user_can( 'edit_user', $user->ID ) ) {
     
    29282931
    29292932        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    2930         do_action( 'xmlrpc_call', 'wp.getPage' );
     2933        do_action( 'xmlrpc_call', 'wp.getPage', $args, $this );
    29312934
    29322935        // If we found the page then format the data.
     
    29712974
    29722975        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    2973         do_action( 'xmlrpc_call', 'wp.getPages' );
     2976        do_action( 'xmlrpc_call', 'wp.getPages', $args, $this );
    29742977
    29752978        $pages     = get_posts(
     
    30263029
    30273030        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3028         do_action( 'xmlrpc_call', 'wp.newPage' );
     3031        do_action( 'xmlrpc_call', 'wp.newPage', $args, $this );
    30293032
    30303033        // Mark this as content for a page.
     
    30633066
    30643067        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3065         do_action( 'xmlrpc_call', 'wp.deletePage' );
     3068        do_action( 'xmlrpc_call', 'wp.deletePage', $args, $this );
    30663069
    30673070        // Get the current page based on the 'page_id' and
     
    31303133
    31313134        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3132         do_action( 'xmlrpc_call', 'wp.editPage' );
     3135        do_action( 'xmlrpc_call', 'wp.editPage', $args, $this );
    31333136
    31343137        // Get the page data and make sure it is a page.
     
    31933196
    31943197        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3195         do_action( 'xmlrpc_call', 'wp.getPageList' );
     3198        do_action( 'xmlrpc_call', 'wp.getPageList', $args, $this );
    31963199
    31973200        // Get list of page IDs and titles.
     
    32543257
    32553258        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3256         do_action( 'xmlrpc_call', 'wp.getAuthors' );
     3259        do_action( 'xmlrpc_call', 'wp.getAuthors', $args, $this );
    32573260
    32583261        $authors = array();
     
    32983301
    32993302        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3300         do_action( 'xmlrpc_call', 'wp.getKeywords' );
     3303        do_action( 'xmlrpc_call', 'wp.getKeywords', $args, $this );
    33013304
    33023305        $tags = array();
     
    33483351
    33493352        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3350         do_action( 'xmlrpc_call', 'wp.newCategory' );
     3353        do_action( 'xmlrpc_call', 'wp.newCategory', $args, $this );
    33513354
    33523355        // Make sure the user is allowed to add a category.
     
    34313434
    34323435        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3433         do_action( 'xmlrpc_call', 'wp.deleteCategory' );
     3436        do_action( 'xmlrpc_call', 'wp.deleteCategory', $args, $this );
    34343437
    34353438        if ( ! current_user_can( 'delete_term', $category_id ) ) {
     
    34883491
    34893492        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3490         do_action( 'xmlrpc_call', 'wp.suggestCategories' );
     3493        do_action( 'xmlrpc_call', 'wp.suggestCategories', $args, $this );
    34913494
    34923495        $category_suggestions = array();
     
    35343537
    35353538        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3536         do_action( 'xmlrpc_call', 'wp.getComment' );
     3539        do_action( 'xmlrpc_call', 'wp.getComment', $args, $this );
    35373540
    35383541        $comment = get_comment( $comment_id );
     
    35873590
    35883591        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3589         do_action( 'xmlrpc_call', 'wp.getComments' );
     3592        do_action( 'xmlrpc_call', 'wp.getComments', $args, $this );
    35903593
    35913594        if ( isset( $struct['status'] ) ) {
     
    36823685
    36833686        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3684         do_action( 'xmlrpc_call', 'wp.deleteComment' );
     3687        do_action( 'xmlrpc_call', 'wp.deleteComment', $args, $this );
    36853688
    36863689        $status = wp_delete_comment( $comment_ID );
     
    37503753
    37513754        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3752         do_action( 'xmlrpc_call', 'wp.editComment' );
     3755        do_action( 'xmlrpc_call', 'wp.editComment', $args, $this );
    37533756        $comment = array(
    37543757            'comment_ID' => $comment_ID,
     
    39433946
    39443947        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3945         do_action( 'xmlrpc_call', 'wp.newComment' );
     3948        do_action( 'xmlrpc_call', 'wp.newComment', $args, $this );
    39463949
    39473950        $comment_ID = wp_new_comment( $comment, true );
     
    39974000
    39984001        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    3999         do_action( 'xmlrpc_call', 'wp.getCommentStatusList' );
     4002        do_action( 'xmlrpc_call', 'wp.getCommentStatusList', $args, $this );
    40004003
    40014004        return get_comment_statuses();
     
    40394042
    40404043        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4041         do_action( 'xmlrpc_call', 'wp.getCommentCount' );
     4044        do_action( 'xmlrpc_call', 'wp.getCommentCount', $args, $this );
    40424045
    40434046        $count = wp_count_comments( $post_id );
     
    40814084
    40824085        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4083         do_action( 'xmlrpc_call', 'wp.getPostStatusList' );
     4086        do_action( 'xmlrpc_call', 'wp.getPostStatusList', $args, $this );
    40844087
    40854088        return get_post_statuses();
     
    41164119
    41174120        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4118         do_action( 'xmlrpc_call', 'wp.getPageStatusList' );
     4121        do_action( 'xmlrpc_call', 'wp.getPageStatusList', $args, $this );
    41194122
    41204123        return get_page_statuses();
     
    43094312
    43104313        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4311         do_action( 'xmlrpc_call', 'wp.getMediaItem' );
     4314        do_action( 'xmlrpc_call', 'wp.getMediaItem', $args, $this );
    43124315
    43134316        $attachment = get_post( $attachment_id );
     
    43624365
    43634366        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4364         do_action( 'xmlrpc_call', 'wp.getMediaLibrary' );
     4367        do_action( 'xmlrpc_call', 'wp.getMediaLibrary', $args, $this );
    43654368
    43664369        $parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : '';
     
    44184421
    44194422        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4420         do_action( 'xmlrpc_call', 'wp.getPostFormats' );
     4423        do_action( 'xmlrpc_call', 'wp.getPostFormats', $args, $this );
    44214424
    44224425        $formats = get_post_format_strings();
     
    44984501
    44994502        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4500         do_action( 'xmlrpc_call', 'wp.getPostType' );
     4503        do_action( 'xmlrpc_call', 'wp.getPostType', $args, $this );
    45014504
    45024505        if ( ! post_type_exists( $post_type_name ) ) {
     
    45554558
    45564559        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4557         do_action( 'xmlrpc_call', 'wp.getPostTypes' );
     4560        do_action( 'xmlrpc_call', 'wp.getPostTypes', $args, $this );
    45584561
    45594562        $post_types = get_post_types( $filter, 'objects' );
     
    46254628
    46264629        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4627         do_action( 'xmlrpc_call', 'wp.getRevisions' );
     4630        do_action( 'xmlrpc_call', 'wp.getRevisions', $args, $this );
    46284631
    46294632        $post = get_post( $post_id );
     
    46994702
    47004703        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4701         do_action( 'xmlrpc_call', 'wp.restoreRevision' );
     4704        do_action( 'xmlrpc_call', 'wp.restoreRevision', $args, $this );
    47024705
    47034706        $revision = wp_get_post_revision( $revision_id );
     
    47704773
    47714774        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4772         do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' );
     4775        do_action( 'xmlrpc_call', 'blogger.getUsersBlogs', $args, $this );
    47734776
    47744777        $is_admin = current_user_can( 'manage_options' );
     
    48564859
    48574860        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4858         do_action( 'xmlrpc_call', 'blogger.getUserInfo' );
     4861        do_action( 'xmlrpc_call', 'blogger.getUserInfo', $args, $this );
    48594862
    48604863        $struct = array(
     
    49064909
    49074910        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4908         do_action( 'xmlrpc_call', 'blogger.getPost' );
     4911        do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this );
    49094912
    49104913        $categories = implode( ',', wp_get_post_categories( $post_ID ) );
     
    49634966
    49644967        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    4965         do_action( 'xmlrpc_call', 'blogger.getRecentPosts' );
     4968        do_action( 'xmlrpc_call', 'blogger.getRecentPosts', $args, $this );
    49664969
    49674970        $posts_list = wp_get_recent_posts( $query );
     
    50535056
    50545057        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    5055         do_action( 'xmlrpc_call', 'blogger.newPost' );
     5058        do_action( 'xmlrpc_call', 'blogger.newPost', $args, $this );
    50565059
    50575060        $cap = ( $publish ) ? 'publish_posts' : 'edit_posts';
     
    51305133
    51315134        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    5132         do_action( 'xmlrpc_call', 'blogger.editPost' );
     5135        do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this );
    51335136
    51345137        $actual_post = get_post( $post_ID, ARRAY_A );
     
    52045207
    52055208        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    5206         do_action( 'xmlrpc_call', 'blogger.deletePost' );
     5209        do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this );
    52075210
    52085211        $actual_post = get_post( $post_ID, ARRAY_A );
     
    52925295
    52935296        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    5294         do_action( 'xmlrpc_call', 'metaWeblog.newPost' );
     5297        do_action( 'xmlrpc_call', 'metaWeblog.newPost', $args, $this );
    52955298
    52965299        $page_template = '';
     
    56715674
    56725675        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    5673         do_action( 'xmlrpc_call', 'metaWeblog.editPost' );
     5676        do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this );
    56745677
    56755678        $postdata = get_post( $post_ID, ARRAY_A );
     
    60096012
    60106013        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6011         do_action( 'xmlrpc_call', 'metaWeblog.getPost' );
     6014        do_action( 'xmlrpc_call', 'metaWeblog.getPost', $args, $this );
    60126015
    60136016        if ( '' !== $postdata['post_date'] ) {
     
    61506153
    61516154        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6152         do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' );
     6155        do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts', $args, $this );
    61536156
    61546157        $posts_list = wp_get_recent_posts( $query );
     
    62716274
    62726275        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6273         do_action( 'xmlrpc_call', 'metaWeblog.getCategories' );
     6276        do_action( 'xmlrpc_call', 'metaWeblog.getCategories', $args, $this );
    62746277
    62756278        $categories_struct = array();
     
    63326335
    63336336        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6334         do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' );
     6337        do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject', $args, $this );
    63356338
    63366339        if ( ! current_user_can( 'upload_files' ) ) {
     
    64516454
    64526455        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6453         do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' );
     6456        do_action( 'xmlrpc_call', 'mt.getRecentPostTitles', $args, $this );
    64546457
    64556458        $posts_list = wp_get_recent_posts( $query );
     
    65136516
    65146517        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6515         do_action( 'xmlrpc_call', 'mt.getCategoryList' );
     6518        do_action( 'xmlrpc_call', 'mt.getCategoryList', $args, $this );
    65166519
    65176520        $categories_struct = array();
     
    65716574
    65726575        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6573         do_action( 'xmlrpc_call', 'mt.getPostCategories' );
     6576        do_action( 'xmlrpc_call', 'mt.getPostCategories', $args, $this );
    65746577
    65756578        $categories = array();
     
    66186621
    66196622        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6620         do_action( 'xmlrpc_call', 'mt.setPostCategories' );
     6623        do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this );
    66216624
    66226625        if ( ! get_post( $post_ID ) ) {
     
    66476650    public function mt_supportedMethods() {
    66486651        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6649         do_action( 'xmlrpc_call', 'mt.supportedMethods' );
     6652        do_action( 'xmlrpc_call', 'mt.supportedMethods', $args, $this );
    66506653
    66516654        return array_keys( $this->methods );
     
    66596662    public function mt_supportedTextFilters() {
    66606663        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6661         do_action( 'xmlrpc_call', 'mt.supportedTextFilters' );
     6664        do_action( 'xmlrpc_call', 'mt.supportedTextFilters', $args, $this );
    66626665
    66636666        /**
     
    66856688
    66866689        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6687         do_action( 'xmlrpc_call', 'mt.getTrackbackPings' );
     6690        do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_ID, $this );
    66886691
    66896692        $actual_post = get_post( $post_ID, ARRAY_A );
     
    67426745
    67436746        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6744         do_action( 'xmlrpc_call', 'mt.publishPost' );
     6747        do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this );
    67456748
    67466749        $postdata = get_post( $post_ID, ARRAY_A );
     
    67846787
    67856788        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6786         do_action( 'xmlrpc_call', 'pingback.ping' );
     6789        do_action( 'xmlrpc_call', 'pingback.ping', $args, $this );
    67876790
    67886791        $this->escape( $args );
     
    70237026
    70247027        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    7025         do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' );
     7028        do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks', $url, $this );
    70267029
    70277030        $url = $this->escape( $url );
Note: See TracChangeset for help on using the changeset viewer.