processwire / processwire-issues

ProcessWire issue reports.
45 stars 2 forks source link

$page->get(fielda|fieldb) wrongly returns null #1998

Open Toutouwai opened 1 day ago

Toutouwai commented 1 day ago

Short description of the issue

When title and headline is "0" (or title is "0" and headline is empty)...

$page->get('headline'); // works
$page->get('title'); // works
$page->get('headline|title'); // doesn't work

2024-11-21_161418

Setup/Environment

ryancramerdesign commented 3 hours ago

@Toutouwai I'm not so sure on this one, as the a|b|c format is intended to return the first non-empty match (see here). A "0" string is empty, according to PHP. So it's more a question of whether you consider a "0" to be empty or not. PW mostly follows the PHP definitions of things like this, but I can also see how a case could be made that a "0" string has a length of 1, so a 0 as a string isn't really empty...