Make WordPress Core

Ticket #50493: register_rest_route-patch-2.patch.txt

File register_rest_route-patch-2.patch.txt, 11.7 KB (added by Lwangaman, 6 years ago)

change grammatical order of a couple messages

Line 
1From aa2f10e5d8ee854f597250fca963e44efdd899ae Mon Sep 17 00:00:00 2001
2From: "John R. D'Orazio" <priest@johnromanodorazio.com>
3Date: Thu, 16 Jul 2020 22:15:07 +0200
4Subject: [PATCH 1/4] Update rest-api.php
5
6---
7 src/wp-includes/rest-api.php | 16 +++++++++-------
8 1 file changed, 9 insertions(+), 7 deletions(-)
9
10diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
11index d3bb80a3d6..d6db464c0e 100644
12--- a/src/wp-includes/rest-api.php
13+++ b/src/wp-includes/rest-api.php
14@@ -37,25 +37,27 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
15 * and namespace indexes. If you really need to register a
16 * non-namespaced route, call `WP_REST_Server::register_route` directly.
17 */
18- _doing_it_wrong( 'register_rest_route', __( 'Routes must be namespaced with plugin or theme name and version.' ), '4.4.0' );
19+ _doing_it_wrong( 'register_rest_route', __( 'Routes must be namespaced with plugin or theme name and version.' ) . ' [Namespace = "' . $namespace . '", Route = "' . $route . '"]', '4.4.0' );
20 return false;
21 } elseif ( empty( $route ) ) {
22- _doing_it_wrong( 'register_rest_route', __( 'Route must be specified.' ), '4.4.0' );
23+ _doing_it_wrong( 'register_rest_route', __( 'Route must be specified.' ) . ' [Namespace = "' . $namespace . '", Route = "' . $route . '"]', '4.4.0' );
24 return false;
25 }
26
27 $clean_namespace = trim( $namespace, '/' );
28
29 if ( $clean_namespace !== $namespace ) {
30- _doing_it_wrong( __FUNCTION__, __( 'Namespace must not start or end with a slash.' ), '5.4.2' );
31+ _doing_it_wrong(
32+ __FUNCTION__,
33+ __( 'Namespace must not start or end with a slash.' ) . ' [Namespace = "' . $namespace . '", Route = "' . $route . '"]', '5.4.2' );
34 }
35-
36+
37 if ( ! did_action( 'rest_api_init' ) ) {
38 _doing_it_wrong(
39- 'register_rest_route',
40+ __FUNCTION__,
41 sprintf(
42 /* translators: %s: rest_api_init */
43- __( 'REST API routes must be registered on the %s action.' ),
44+ __( 'REST API routes must be registered on the %s action.' ) . ' [Namespace = "' . $namespace . '", Route = "' . $route . '"]',
45 '<code>rest_api_init</code>'
46 ),
47 '5.1.0'
48@@ -1835,7 +1837,7 @@ function rest_sanitize_value_from_schema( $value, $args, $param = '' ) {
49 _doing_it_wrong(
50 __FUNCTION__,
51 /* translators: 1. Parameter. 2. The list of allowed types. */
52- wp_sprintf( __( 'The "type" schema keyword for %1$s can only be on of the built-in types: %2$l.' ), $param, $allowed_types ),
53+ wp_sprintf( __( 'The "type" schema keyword for %1$s can only be one of the built-in types: %2$l.' ), $param, $allowed_types ),
54 '5.5.0'
55 );
56 }
57
58From 059bee8c0f63f9540c9fa37e0ed56c69932e7227 Mon Sep 17 00:00:00 2001
59From: "John R. D'Orazio" <priest@johnromanodorazio.com>
60Date: Sat, 18 Jul 2020 11:11:39 +0200
61Subject: [PATCH 2/4] Fix _doing_it_wrong messages using sprintf
62
63give more info in the messages output by _doing_it_wrong by including route and namespace
64---
65 src/wp-includes/rest-api.php | 39 ++++++++++++++++++++++++++++++------
66 1 file changed, 33 insertions(+), 6 deletions(-)
67
68diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
69index d6db464c0e..eaa9c3726b 100644
70--- a/src/wp-includes/rest-api.php
71+++ b/src/wp-includes/rest-api.php
72@@ -37,10 +37,28 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
73 * and namespace indexes. If you really need to register a
74 * non-namespaced route, call `WP_REST_Server::register_route` directly.
75 */
76- _doing_it_wrong( 'register_rest_route', __( 'Routes must be namespaced with plugin or theme name and version.' ) . ' [Namespace = "' . $namespace . '", Route = "' . $route . '"]', '4.4.0' );
77+ _doing_it_wrong(
78+ __FUNCTION__,
79+ sprintf(
80+ /* translators: %1$s: string value of the route, %2$s: string value of the namespace */
81+ __( 'Routes must be namespaced with plugin or theme name and version. Instead route %1$s seems to have empty namespace %2$s.' ),
82+ '<code>'.$namespace.'</code>',
83+ '<code>'.$route.'</code>'
84+ ),
85+ '4.4.0'
86+ );
87 return false;
88 } elseif ( empty( $route ) ) {
89- _doing_it_wrong( 'register_rest_route', __( 'Route must be specified.' ) . ' [Namespace = "' . $namespace . '", Route = "' . $route . '"]', '4.4.0' );
90+ _doing_it_wrong(
91+ __FUNCTION__,
92+ sprintf(
93+ /* translators: %1$s: string value of the route, %2$s: string value of the namespace */
94+ __( 'Route must be specified. Instead there seems to be an empty route %1$s for the namespace %2$s.' ),
95+ '<code>'.$namespace.'</code>',
96+ '<code>'.$route.'</code>'
97+ ),
98+ '4.4.0'
99+ );
100 return false;
101 }
102
103@@ -49,16 +67,25 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
104 if ( $clean_namespace !== $namespace ) {
105 _doing_it_wrong(
106 __FUNCTION__,
107- __( 'Namespace must not start or end with a slash.' ) . ' [Namespace = "' . $namespace . '", Route = "' . $route . '"]', '5.4.2' );
108+ sprintf(
109+ /* translators: %1$s: string value of the route, %2$s: string value of the namespace */
110+ __( 'Namespace must not start or end with a slash. Instead route %1$s has namespace %2$s.' ),
111+ '<code>'.$namespace.'</code>',
112+ '<code>'.$route.'</code>'
113+ ),
114+ '5.4.2'
115+ );
116 }
117
118 if ( ! did_action( 'rest_api_init' ) ) {
119 _doing_it_wrong(
120 __FUNCTION__,
121 sprintf(
122- /* translators: %s: rest_api_init */
123- __( 'REST API routes must be registered on the %s action.' ) . ' [Namespace = "' . $namespace . '", Route = "' . $route . '"]',
124- '<code>rest_api_init</code>'
125+ /* translators: %1$s: rest_api_init, %2$s: string value of the route, %3$s: string value of the namespace */
126+ __( 'REST API routes must be registered on the %1$s action. Instead route %2$s with namespace %3$s was not registered on this action.' ),
127+ '<code>rest_api_init</code>',
128+ '<code>'.$namespace.'</code>',
129+ '<code>'.$route.'</code>'
130 ),
131 '5.1.0'
132 );
133
134From 28d04022aa2207c6fb2f1586637dcb4ad5beebaa Mon Sep 17 00:00:00 2001
135From: "John R. D'Orazio" <priest@johnromanodorazio.com>
136Date: Sat, 18 Jul 2020 11:16:18 +0200
137Subject: [PATCH 3/4] fix association of sprintf variables
138
139---
140 src/wp-includes/rest-api.php | 16 ++++++++--------
141 1 file changed, 8 insertions(+), 8 deletions(-)
142
143diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
144index eaa9c3726b..527112c698 100644
145--- a/src/wp-includes/rest-api.php
146+++ b/src/wp-includes/rest-api.php
147@@ -40,8 +40,8 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
148 _doing_it_wrong(
149 __FUNCTION__,
150 sprintf(
151- /* translators: %1$s: string value of the route, %2$s: string value of the namespace */
152- __( 'Routes must be namespaced with plugin or theme name and version. Instead route %1$s seems to have empty namespace %2$s.' ),
153+ /* translators: %1$s: string value of the namespace, %2$s: string value of the route */
154+ __( 'Routes must be namespaced with plugin or theme name and version. Instead route %2$s seems to have empty namespace %1$s.' ),
155 '<code>'.$namespace.'</code>',
156 '<code>'.$route.'</code>'
157 ),
158@@ -52,8 +52,8 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
159 _doing_it_wrong(
160 __FUNCTION__,
161 sprintf(
162- /* translators: %1$s: string value of the route, %2$s: string value of the namespace */
163- __( 'Route must be specified. Instead there seems to be an empty route %1$s for the namespace %2$s.' ),
164+ /* translators: %1$s: string value of the namespace, %2$s: string value of the route */
165+ __( 'Route must be specified. Instead there seems to be an empty route %2$s for the namespace %1$s.' ),
166 '<code>'.$namespace.'</code>',
167 '<code>'.$route.'</code>'
168 ),
169@@ -68,8 +68,8 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
170 _doing_it_wrong(
171 __FUNCTION__,
172 sprintf(
173- /* translators: %1$s: string value of the route, %2$s: string value of the namespace */
174- __( 'Namespace must not start or end with a slash. Instead route %1$s has namespace %2$s.' ),
175+ /* translators: %1$s: string value of the namespace, %2$s: string value of the route */
176+ __( 'Namespace must not start or end with a slash. Instead route %2$s has namespace %1$s.' ),
177 '<code>'.$namespace.'</code>',
178 '<code>'.$route.'</code>'
179 ),
180@@ -81,8 +81,8 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
181 _doing_it_wrong(
182 __FUNCTION__,
183 sprintf(
184- /* translators: %1$s: rest_api_init, %2$s: string value of the route, %3$s: string value of the namespace */
185- __( 'REST API routes must be registered on the %1$s action. Instead route %2$s with namespace %3$s was not registered on this action.' ),
186+ /* translators: %1$s: rest_api_init, %2$s: string value of the namespace, %3$s: string value of the route */
187+ __( 'REST API routes must be registered on the %1$s action. Instead route %3$s with namespace %2$s was not registered on this action.' ),
188 '<code>rest_api_init</code>',
189 '<code>'.$namespace.'</code>',
190 '<code>'.$route.'</code>'
191
192From e5e6b5e8f96d4d7651fe582545b80e3f6051c84c Mon Sep 17 00:00:00 2001
193From: "John R. D'Orazio" <priest@johnromanodorazio.com>
194Date: Tue, 21 Jul 2020 10:21:21 +0200
195Subject: [PATCH 4/4] Update rest-api.php
196
197change grammatical order of some messages
198---
199 src/wp-includes/rest-api.php | 8 ++++----
200 1 file changed, 4 insertions(+), 4 deletions(-)
201
202diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
203index 527112c698..9c10a8292a 100644
204--- a/src/wp-includes/rest-api.php
205+++ b/src/wp-includes/rest-api.php
206@@ -41,7 +41,7 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
207 __FUNCTION__,
208 sprintf(
209 /* translators: %1$s: string value of the namespace, %2$s: string value of the route */
210- __( 'Routes must be namespaced with plugin or theme name and version. Instead route %2$s seems to have empty namespace %1$s.' ),
211+ __( 'Routes must be namespaced with plugin or theme name and version. Instead there seems to be an empty namespace \'%1$s\' for route \'%2$s\'.' ),
212 '<code>'.$namespace.'</code>',
213 '<code>'.$route.'</code>'
214 ),
215@@ -53,7 +53,7 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
216 __FUNCTION__,
217 sprintf(
218 /* translators: %1$s: string value of the namespace, %2$s: string value of the route */
219- __( 'Route must be specified. Instead there seems to be an empty route %2$s for the namespace %1$s.' ),
220+ __( 'Route must be specified. Instead within the namespace \'%1$s\', there seems to be an empty route \'%2$s\'.' ),
221 '<code>'.$namespace.'</code>',
222 '<code>'.$route.'</code>'
223 ),
224@@ -69,7 +69,7 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
225 __FUNCTION__,
226 sprintf(
227 /* translators: %1$s: string value of the namespace, %2$s: string value of the route */
228- __( 'Namespace must not start or end with a slash. Instead route %2$s has namespace %1$s.' ),
229+ __( 'Namespace must not start or end with a slash. Instead namespace \'%1$s\' for route \'%2$s\' seems to contain a slash.' ),
230 '<code>'.$namespace.'</code>',
231 '<code>'.$route.'</code>'
232 ),
233@@ -82,7 +82,7 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
234 __FUNCTION__,
235 sprintf(
236 /* translators: %1$s: rest_api_init, %2$s: string value of the namespace, %3$s: string value of the route */
237- __( 'REST API routes must be registered on the %1$s action. Instead route %3$s with namespace %2$s was not registered on this action.' ),
238+ __( 'REST API routes must be registered on the %1$s action. Instead route \'%3$s\' with namespace \'%2$s\' was not registered on this action.' ),
239 '<code>rest_api_init</code>',
240 '<code>'.$namespace.'</code>',
241 '<code>'.$route.'</code>'