[wp-trac] [WordPress Trac] #51986: PHP Warning: array_intersect_key(): Expected parameter 1 to be an array, string given in class-wp-rest-server.php

WordPress Trac noreply at wordpress.org
Wed Dec 9 15:11:33 UTC 2020


#51986: PHP Warning: array_intersect_key(): Expected parameter 1 to be an array,
string given in class-wp-rest-server.php
---------------------------------------------+-----------------------------
 Reporter:  slaFFik                          |       Owner:  (none)
     Type:  defect (bug)                     |      Status:  new
 Priority:  normal                           |   Milestone:  Awaiting
                                             |  Review
Component:  Editor                           |     Version:  5.6
 Severity:  normal                           |  Resolution:
 Keywords:  reporter-feedback needs-testing  |     Focuses:  rest-api
---------------------------------------------+-----------------------------

Comment (by slaFFik):

 @desrosj

 The plugin is not hosted on wp.org.
 Here is the related code that registers the endpoints:

 {{{
 public function register_api_endpoints() {

     register_rest_route( 'example/v1', '/some-
 content/woof/(?P<type>[a-zA-Z0-9-]+)', array(
         'methods'             => 'GET',
         'callback'            => array( $this, 'get_gutenberg_themes' ),
         'permission_callback' => function () {
             return current_user_can( 'edit_posts' );
         },
         'args'                => array(
             'type',
         ),
     ) );

     register_rest_route( 'example/v1', '/terms/(?P<slug>[a-zA-Z0-9-_]+)',
 array(
         'methods'             => 'GET',
         'callback'            => array( $this, 'get_taxonomy_terms' ),
         'permission_callback' => function () {
             return current_user_can( 'edit_posts' );
         },
         'args'                => array(
             'slug',
         ),
     ) );

     register_rest_route( 'example/v1',
 '/taxonomy/(?P<slug>[a-zA-Z0-9-_]+)', array(
         'methods'             => 'GET',
         'callback'            => array( $this, 'get_taxonomy' ),
         'permission_callback' => function () {
             return current_user_can( 'edit_posts' );
         },
         'args'                => array(
             'slug',
         ),
     ) );
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51986#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list