WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 5 months ago

#33034 new enhancement

Refactor SCRIPT_FILENAME ending with php.cgi check in load.php

Reported by: wildpeat Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3
Component: Bootstrap/Load Keywords:
Focuses: Cc:
PR Number:

Description

I found the original check pretty confusing :)

Attachments (1)

refactor_SCRIPT_FILENAME_check.patch (672 bytes) - added by wildpeat 4 years ago.
Patch

Download all attachments as: .zip

Change History (3)

#1 @dd32
4 years ago

To avoid the usage of a regular expression here, this seems far more readable than the current odd code:

if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && 'php.cgi' == substr( $_SERVER['SCRIPT_FILENAME'], -7 ) ) 

#2 @wildpeat
4 years ago

With the caveat that I'm brand new to PHP, I agree that's more readable than the original, but I don't like the constant -7 in the code. I have noticed this hardcoding of the string length in lots of other parts of the code-base and I'll gladly nod to your experience if this is more idiomatic in PHP than the regex.

Cheers for looking!

Note: See TracTickets for help on using tickets.