Encountered the bug in 3.6.3 and confirmed it in my development environment. By moving the line, this can be compensated for. Patch to follow.
Created attachment 10623 [details] [review] Moved the substitution inside the if statement While generating this patch, I realized that the if statement needs fixing too. Bug report to follow for that problem. However, the if statement modification won't affect the NULL case, which is being handled by moving this. It does differ technically in the case of 0 or '0', however the result is the same.
Marking as duplicate, because my patch on 8350 will solve this problem and the poorly defined if issues. *** This bug has been marked as a duplicate of bug 8350 ***