replace php_sapi_name() with PHP_SAPI
Closed, ResolvedPublic

Description

This bug is about replacing our calls to php_sapi_name() by the PHP building constant PHP_SAPI.

PHP_SAPI has been available since PHP 4.2 and provide the same string that php_sapi_name() provides. I find it shorter and cleaner to read. Consider:

if( php_sapi_name() !== 'cli ) { }

if( PHP_SAPI !== 'cli ) { }


Version: 1.20.x
Severity: enhancement

Details

Reference
bz37957
bzimport set Reference to bz37957.
bzimport added a subscriber: Unknown Object (MLST).
hashar created this task.Jun 26 2012, 9:13 AM

CCing Sam and Chad for input.

PHP_SAPI is also faster.

ori added a comment.Feb 4 2013, 3:14 AM

Patch in Gerrit: https://gerrit.wikimedia.org/r/#/c/47379/

(In reply to comment #2)

PHP_SAPI is also faster.

I will now add "MediaWiki performance engineering" to my résumé.

hashar added a comment.Feb 4 2013, 8:18 AM

Bug 44633 track the addition of a rule in PHP CodeSniffer

We could probably do the same for some extensions.

Change 80866 had a related patch set uploaded by Yuvipanda:
Use PHP_SAPI instead of php_sapi_name()

https://gerrit.wikimedia.org/r/80866

Change 80866 merged by jenkins-bot:
Use PHP_SAPI instead of php_sapi_name()

https://gerrit.wikimedia.org/r/80866

Add Comment