Skip to content

Commit

Permalink
always throw in autoload_set_paths()
Browse files Browse the repository at this point in the history
Summary: Anything that breaks is an outstanding migration TODO

Reviewed By: jthemphill

Differential Revision: D43214849

fbshipit-source-id: d39e41c5c64ea90d4a57925d81cefdb602834f65
  • Loading branch information
edwinsmith authored and facebook-github-bot committed Apr 3, 2023
1 parent 35405fc commit d419828
Showing 1 changed file with 3 additions and 39 deletions.
42 changes: 3 additions & 39 deletions hphp/runtime/ext/hh/ext_hh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,45 +76,9 @@ bool HHVM_FUNCTION(autoload_is_native) {
return autoloadMap && autoloadMap->isNative();
}

bool HHVM_FUNCTION(autoload_set_paths,
const Variant& map,
const String& root) {
// If we are using a native autoload map you are not allowed to override it
// in repo mode
if (RuntimeOption::RepoAuthoritative) {
return false;
}

if (!RuntimeOption::AutoloadUserlandEnabled) {
SystemLib::throwInvalidOperationExceptionObject(
"Attempted to call HH\\autoload_set_paths() when "
"Autoload.UserlandEnabled is false. HH\\autoload_set_paths() will soon "
"be deleted so HHVM internals can start depending on native "
"autoloading.");
} else if (HHVM_FN(autoload_is_native)()) {
raise_notice(
"Attempted to call HH\\autoload_set_paths() while the native autoloader "
"is enabled. HH\\autoload_set_paths() disables the native autoloader, "
"putting us on a deprecated code path that will soon stop working.");
}

if (map.isArray()) {
return AutoloadHandler::s_instance->setMap(map.asCArrRef(), root);
}
if (!(map.isObject() && map.toObject()->isCollection())) {
return false;
}
// Assume we have Map<string, Map<string, string>> - convert to
// array<string, array<string, string>>
//
// Exception for 'failure' which should be a callable.
auto as_array = map.toArray();
for (auto it = as_array.begin(); !it.end(); it.next()) {
if (it.second().isObject() && it.second().toObject()->isCollection()) {
as_array.set(it.first(), it.second().toArray());
}
}
return AutoloadHandler::s_instance->setMap(as_array, root);
bool HHVM_FUNCTION(autoload_set_paths, const Variant&, const String&) {
SystemLib::throwInvalidOperationExceptionObject("NF FTW!");
return false;
}

namespace {
Expand Down

0 comments on commit d419828

Please sign in to comment.