1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Fix static variable usage in Lisk

Summary:
See comment.
This can reveal some pretty bad bugs but HPHP handles this correctly so we already know about them.

Test Plan:
Added `phlog()` to `__call()` and observed what is defined for each method (under PHP). Also:

  class C {
    function __call($name, $args) {
      static $class;
      if (!$class) {
        $class = get_class($this);
      }
      return $class;
    }
  }

  class D extends C {
  }

  class E extends C {
  }

  $d = new D;
  $e = new E;
  var_dump($d->x());
  var_dump($e->x()); // Prints D under PHP!

See also D3754.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1261

Differential Revision: https://secure.phabricator.com/D3753
This commit is contained in:
vrana 2012-10-19 17:43:11 -07:00
parent 7b0c608df8
commit fd87a88d71

View file

@ -1695,6 +1695,16 @@ abstract class LiskDAO {
*/
public function __call($method, $args) {
// NOTE: PHP has a bug that static variables defined in __call() are shared
// across all children classes. Call a different method to work around this
// bug.
return $this->call($method, $args);
}
/**
* @task util
*/
final protected function call($method, $args) {
// NOTE: This method is very performance-sensitive (many thousands of calls
// per page on some pages), and thus has some silliness in the name of
// optimizations.