|
These two functions are the single most common entry point in the
codebase — ~30+ files call them as valid_keyval($_GET["My_key"]) or
valid_input($_POST[...]) with no isset() guard at the call site. When
the key is absent, PHP passes null straight into trim(), which is a
non-nullable string parameter. As of PHP 8.1 this triggers a
"Passing null to parameter #1 ($string) ... is deprecated" notice on
every one of those call sites, on every request missing the param.
Coalescing to '' inside the two functions themselves fixes this once,
for every caller, instead of patching every call site individually.
Verified empirically against PHP 8.3.28: valid_keyval(null) /
valid_input(null) no longer emit the trim() deprecation notice and
still return '' as before (same effective behavior as PHP 7.4).
Reviewed by: Frederick M Muriithi <fredmanglis@gmail.com>
|