[wp-trac] [WordPress Trac] #54142: Undefined array key "SCRIPT_NAME" in wp_fix_server_vars()

WordPress Trac noreply at wordpress.org
Fri Nov 12 01:08:50 UTC 2021


#54142: Undefined array key "SCRIPT_NAME" in wp_fix_server_vars()
-----------------------------------------+-----------------------------
 Reporter:  mcjambi                      |       Owner:  hellofromTonya
     Type:  defect (bug)                 |      Status:  closed
 Priority:  normal                       |   Milestone:  5.9
Component:  Bootstrap/Load               |     Version:  2.0
 Severity:  normal                       |  Resolution:  fixed
 Keywords:  has-patch commit php8 php81  |     Focuses:
-----------------------------------------+-----------------------------
Changes (by hellofromTonya):

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


Comment:

 In [changeset:"52144" 52144]:
 {{{
 #!CommitTicketReference repository="" revision="52144"
 Bootstrap/Load: Check `$_SERVER['SCRIPT_NAME']` exists before passing to
 `strpos()` in `wp_fix_server_vars()`.

 If `SCRIPT_NAME'` does not exist (which can happen in cron jobs), the
 following happens:

 * PHP 8.1+:
     * `Warning: Undefined array key "SCRIPT_NAME"`
     * `Deprecated: strpos(): Passing null to parameter #1 ($haystack) of
 type string is deprecated`
 * PHP 8.0: `Warning: Undefined array key "SCRIPT_NAME"`
 * PHP 5.6-7.4: No warning or notice

 This commit checks if the key exists before passing it to `strpos()`. This
 resolves the warning, notice, and future error.

 Follow-up to [3034], [3069], [12732].

 Props audrasjb, costdev, hellofromTonya, karpstrucking, mcjambi,
 sergeybiryukov.
 Fixes #54142.
 }}}

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


More information about the wp-trac mailing list