[wp-trac] [WordPress Trac] #48530: Match REST API route by namespace before performing regex checks

WordPress Trac noreply at wordpress.org
Wed Feb 19 14:19:50 UTC 2020


#48530: Match REST API route by namespace before performing regex checks
--------------------------------------+--------------------------
 Reporter:  TimothyBlynJacobs         |       Owner:  kadamwhite
     Type:  enhancement               |      Status:  reopened
 Priority:  normal                    |   Milestone:  5.4
Component:  REST API                  |     Version:  4.4
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  performance
--------------------------------------+--------------------------
Changes (by david.binda):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 While testing the related patch, I have run into an issue with clashing
 namespaces resulting in routes not being found. This might be an edge
 case, but still feels like a backward compatibility breaking change.

 In case there is a namespace extending a shorter one, it's routes are not
 being recognised.

 For instance, routes in a namespace `test-ns/v1` would not be found, if
 there is a `test-ns` namespace also registered. While it might not be the
 best use-case to have such namespaces, it definitely worked prior r47260

 I'm attaching a patch with a unit test showing the issue (which is passing
 prior r47260, but not afterwards).

 Feels like we could still preserve some of the performance improvements by
 not breaking the foreach cycle if a match on a namespace is found, but
 rather continue the cycle, while merging found namespaces together (see
 attached diff).

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


More information about the wp-trac mailing list