Homec4science

Don't throw `PhutilMissingSymbolException` from `class_exists` or…

Authored by Joshua Spence <josh@freelancer.com> on Nov 29 2015, 21:39.

Description

Don't throw PhutilMissingSymbolException from class_exists or interface_exists

Summary:
Fixes T1116. Currently we throw a PhutilMissingSymbolException from the libphutil autoloader function (__phutil_autoload) if the following criteria are met:

  • The class/interface being loaded does not exist.
  • __phutil_autoload is the last registered autoloader.

This causes problems with some third-party code which does class_exists($some_class) where $some_class doesn't exist. This function causes the autoloader to be invoked, which thus throws PhutilMissingSymbolException. This is clearly undesirable and, as such, a rather hacky fix is to inspect the output of debug_backtrace() and look for a call to class_exists, interface_exists or trait_exists anywhere in the stacktrace. If any of these functions are found in the stacktrace, we simply return false instead of throwing a PhutilMissingSymbolException.

Test Plan: Ran ./scripts_update_compat_info.php without error.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T1116

Differential Revision: https://secure.phabricator.com/D14523

Details

Committed
Joshua Spence <josh@freelancer.com>Nov 29 2015, 21:50
Pushed
aubortMar 17 2017, 12:03
Parents
rPHUf0881b37049c: Fix an issue with parsing `n_USE_LIST`
Branches
Unknown
Tags
Unknown

Event Timeline

Joshua Spence <josh@freelancer.com> committed rPHUe65ffd33db02: Don't throw `PhutilMissingSymbolException` from `class_exists` or… (authored by Joshua Spence <josh@freelancer.com>).Nov 29 2015, 21:50