[wp-trac] [WordPress Trac] #62355: WP sets REQUEST_URI to an invalid value if it's not set

WordPress Trac noreply at wordpress.org
Mon Dec 16 09:38:32 UTC 2024


#62355: WP sets REQUEST_URI to an invalid value if it's not set
--------------------------+------------------------------
 Reporter:  kkmuffme      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by kkmuffme):

 Yes, it's not allowed and it creates issues that are not caught with
 static analysis, since we typed it as  non-falsy-string|null e.g. in
 psalm.

 Practical example is also for caching - the empty string can lead to
 unexpected behavior

 Also 2 examples that will result in a fatal when you pass an empty string:
 {{{#!php
 <?php
 explode('', '/some/url', 2);
 random_bytes( strlen( '' ) );
 }}}


 >The empty string is not a valid value in this case, but programmers
 initialize variables to invalid values all the time

 Can you provide me an example of that in recent code? That used to be the
 case 15 years ago, but since the advent of strict_types and static
 analysis, you'll probably find that only in some sweatshop code.

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


More information about the wp-trac mailing list