Make WordPress Core

Opened 9 years ago

Last modified 5 years ago

#33034 new enhancement

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

Reported by: wildpeat's profile wildpeat Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3
Component: Bootstrap/Load Keywords:
Focuses: Cc:

Description

I found the original check pretty confusing :)

Attachments (1)

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

Download all attachments as: .zip

Change History (3)

#1 @dd32
9 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
9 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.