Make WordPress Core


Ignore:
Timestamp:
11/23/2016 02:46:42 AM (10 years ago)
Author:
joehoyle
Message:

REST API: Allow unsetting of page templates in update requests.

Sending a request to update a page with the template property set to an empty string resulted in an error because “” was not a valid value in the enum.

Props lucasstark, swissspidy.
Fixes #38877.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/spy-rest-server.php

    r37163 r39343  
    66        public $sent_body = '';
    77        public $last_request = null;
     8        public $override_by_default = false;
    89
    910        /**
    … …  
    4243        }
    4344
     45        /**
     46         * Override the register_route method so we can re-register routes internally if needed.
     47         *
     48         * @param string $namespace  Namespace.
     49         * @param string $route      The REST route.
     50         * @param array  $route_args Route arguments.
     51         * @param bool   $override   Optional. Whether the route should be overridden if it already exists.
     52         *                           Default false. Also set $GLOBALS['wp_rest_server']->override_by_default = true
     53         *                           to set overrides when you don't have access to the caller context.
     54         */
     55        public function register_route( $namespace, $route, $route_args, $override = false ) {
     56                parent::register_route( $namespace, $route, $route_args, $override || $this->override_by_default );
     57        }
     58
    4459        public function serve_request( $path = null ) {
    4560
Note: See TracChangeset for help on using the changeset viewer.