Make WordPress Core

Opened 10 years ago

Closed 4 months ago

#33034 closed enhancement (duplicate)

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:
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 10 years ago.
Patch

Download all attachments as: .zip

Change History (4)

#1 @dd32
10 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
10 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!

#3 @jorbin
4 months ago

  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 4.3 deleted

In [56245] this was updated to use str_ends_with which accomplishes the goal of making this more readable, ergo I am closing this as a duplicate of #58206 which is what that was committed under. Thank you for your attempt to improve WordPress @wildpeat!

Note: See TracTickets for help on using tickets.