[wp-trac] [WordPress Trac] #58132: Slashes used in block templates slug is a problem on Windows

WordPress Trac noreply at wordpress.org
Sun Jul 9 21:25:38 UTC 2023


#58132: Slashes used in block templates slug is a problem on Windows
-------------------------------------------------+-------------------------
 Reporter:  gaft                                 |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  6.2.3
Component:  Editor                               |     Version:  5.9
 Severity:  normal                               |  Resolution:
 Keywords:  needs-testing-info reporter-         |     Focuses:
  feedback has-patch has-unit-tests 2nd-opinion  |
-------------------------------------------------+-------------------------
Changes (by soulseekah):

 * keywords:  needs-testing-info reporter-feedback has-patch has-unit-tests
     =>
     needs-testing-info reporter-feedback has-patch has-unit-tests 2nd-
     opinion


Comment:

 Hi @gaft, welcome to Trac and thanks for opening this ticket and adding
 patches for consideration!

 I believe that this patch would actually break things on Windows and
 should not be committed.

 When picking a template through the UI on Windows the `_wp_page_template`
 meta is saved with backslashes. The query works fine. If we suddenly
 rewrite all slugs from backslashes to forward ones the query will stop
 working. In order for this to work, you will need to further change the
 `_wp_page_template` meta value throughout the database as well!

 The only way the reported bug can be reproduced is when saving the
 template to a page on Windows, then moving the whole site onto Linux (or
 the other way around). That's when slugs start mismatching.

 Your suggested steps to reproduce the issue further follow the above case.
 You are setting the meta value to a Linux-style slug and hoping it to work
 on Windows. Your slug would have been correct if you saved it via the UI.

 The best course in addressing this edge case where we've migrated from
 Windows to Linux or the other way around would be to actually check BOTH
 versions of the slug slashes (using a `preg_match` maybe?). This way, no
 matter what direction the slashes are looking in `_wp_page_template` it
 would always match.

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


More information about the wp-trac mailing list