Page MenuHomePhabricator

phan and taint-check weird interactions: PhanUndeclaredThis
Closed, ResolvedPublic

Description

Similar to T248742. For instance:

includes/libs/Message/MessageValue.php:48 PhanUndeclaredThis Variable $this is undeclared

Note, this is not the same as PhanUndeclaredThis in other code paths.

Event Timeline

So, this one was harder than the other, and reproducing the issue wasn't easy, either. The problem arises when we try to compute the objects that a function could possibly return, but doing that from outside that function. To do that, we basically backup the variable map when first analyzing the function (from the inside), save it in the object representing the function, and retrieve it later when we need to collect the return values. This is because phan deletes the variable map in between, and this fix was explicitly suggested as a stable workaround (https://github.com/phan/phan/issues/2963). The problem is: for some reason, phan deletes the object where we saved the scope, hence we'll later receive another copy of that function, without the original scope, and actually, with no variables at all (including $this, which triggers the issue).

Change 586386 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/tools/phan/SecurityCheckPlugin@master] Fix another edge case interaction with phan

https://gerrit.wikimedia.org/r/586386

Daimona triaged this task as High priority.Apr 6 2020, 4:34 PM
Daimona renamed this task from phan and taint-check weird interactions: PhanUndeclaredVariable, part 2 to phan and taint-check weird interactions: PhanUndeclaredThis.Apr 6 2020, 4:47 PM
Daimona updated the task description. (Show Details)

Change 586386 merged by jenkins-bot:
[mediawiki/tools/phan/SecurityCheckPlugin@master] Fix another edge case interaction with phan

https://gerrit.wikimedia.org/r/586386

Daimona removed a project: Patch-For-Review.