Make WordPress Core

Ticket #34488: 34488.diff

File 34488.diff, 967 bytes (added by TobiasBg, 9 years ago)
  • src/wp-includes/rest-api/class-wp-rest-server.php

    diff --git src/wp-includes/rest-api/class-wp-rest-server.php src/wp-includes/rest-api/class-wp-rest-server.php
    index eae1254..1a239a5 100644
    class WP_REST_Server { 
    763763                $path   = $request->get_route();
    764764
    765765                foreach ( $this->get_routes() as $route => $handlers ) {
     766                        $match = preg_match( '@^' . $route . '$@i', $path, $args );
     767
     768                        if ( ! $match ) {
     769                                continue;
     770                        }
     771
    766772                        foreach ( $handlers as $handler ) {
    767773                                $callback  = $handler['callback'];
    768774                                $response = null;
    class WP_REST_Server { 
    771777                                        continue;
    772778                                }
    773779
    774                                 $match = preg_match( '@^' . $route . '$@i', $path, $args );
    775 
    776                                 if ( ! $match ) {
    777                                         continue;
    778                                 }
    779 
    780780                                if ( ! is_callable( $callback ) ) {
    781781                                        $response = new WP_Error( 'rest_invalid_handler', __( 'The handler for the route is invalid' ), array( 'status' => 500 ) );
    782782                                }