Page MenuHomePhabricator

Preemptively fix possible weak type-checking errors
Open, LowPublicFeature

Description

Author: ayg

Description:

$ grep "\([^\!=]==\|\!=\)\s*''" {includes,skins,languages,maintenance,math,../extensions}/{*,*/*,*/*/*,*/*/*/*}/*.php *.php 2> /dev/null | wc -l
481

That's a lot of == '' and != ''. These should all be examined and fixed to either check strictly (if that's desired) or, I guess, drop the equality check, since that's more explicit. Of course, this doesn't count all the cases where you say !$var and assume strong type checking, but there's not much hope for automatically detecting those. Core looks a little better:

$ grep "\([^\!=]==\|\!=\)\s*''" {includes,skins,languages,maintenance,math}/{*,*/*,*/*/*}/*.php *.php 2> /dev/null | wc -l
27

I'll get on some of these, maybe, if I have the time.


Version: 1.12.x
Severity: enhancement

Details

Reference
bz12769

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:03 PM
bzimport set Reference to bz12769.
bzimport added a subscriber: Unknown Object (MLST).

ayg wrote:

Of course, my bash globbing was totally off . . .

$ grep "\([^\!=]==\|\!=\)\s*''" {includes,skins,languages,maintenance,math,../extensions}/{,*/,*/*/,*/*/*/}*.php *.php 2> /dev/null | wc -l
748
$ grep "\([^\!=]==\|\!=\)\s*''" {includes,skins,languages,maintenance,math}/{,*/,*/*/,*/*/*/}*.php *.php 2> /dev/null | wc -l
295

That looks less pleasant.

Score with 1.13alpha (r32654): 790/300

All on one line:
find . -name '*php' -exec grep -H "\([^\!=]==\|\!=\)\s*''" {} \;

Krinkle set Security to None.
Krinkle removed a subscriber: Unknown Object (MLST).
Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:01 AM