Page MenuHomePhabricator

Mustache/TemplateParser should emit warning if property doesn't exist
Open, MediumPublic

Description

Issues such as https://gerrit.wikimedia.org/r/#/c/266662/6/includes/specials/SpecialContributions.php shouldn't be possible without leaving something behind in the PHP error log. It's essentially a PHP Notice for undefined variable, except that it's through indirection of TemplateParser (and LightNCandy).

These are still immature and shows in lack of error handling.

It seems LightNCandy has some error options. Not sure which ones to use and how we'll forward it to the appropiate logs.

Event Timeline

Krinkle created this task.Mar 4 2016, 3:20 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 4 2016, 3:20 PM
Krinkle added a comment.EditedApr 2 2019, 3:45 AM

Having actual error detection for this run-time failure would have prevented T219359: lang attribute of page title is empty.

Krinkle renamed this task from Template engine should emit warning if unconditional property doesn't exist to Mustache/TemplateParser should emit warning if property doesn't exist.Apr 2 2019, 3:45 AM
Krinkle triaged this task as Medium priority.
Krinkle moved this task from Unsorted to Add / Create on the Technical-Debt board.
Krinkle added a project: Wikimedia-Incident.
Krinkle moved this task from On-going to Follow-up prevention on the Wikimedia-Incident board.

So I suppose we'd be checking variables are defined. It would mean we'd have to ensure certain template values were defined as null (and not undefined) as null is a perfectly valid template value.

For this to be feasible we'd need a way to access the variable names used inside a template.
I have another use case for that - see addMessagesToTemplateData - but the solution I came up with there didn't seem very optimal:
https://gerrit.wikimedia.org/r/c/mediawiki/core/+/584068/18/includes/skins/SkinMustache.php#71

I think having access to that information is the difficult part here. If that's in place however such complaints should be easy to deal with.

I came across this today - https://github.com/zordius/lightncandy#template-debugging - seems this should be built into Lightncandy.

Jdlrobson moved this task from Incoming to Needs Prioritization on the Readers-Web-Backlog board.