A misfunctioning extension can easily make a Joomla website inaccessible.
If it is a system plugin the administrator will fail too, making it impossible to fix the problem.
wrap booting an extension (especially plugins) in a try - catch
public function bootPlugin($plugin, $type): PluginInterface
{
// Normalize the plugin name
$plugin = strtolower($plugin);
$plugin = str_starts_with($plugin, 'plg_') ? substr($plugin, 4) : $plugin;
// Path to look for services
$path = JPATH_SITE . '/plugins/' . $type . '/' . $plugin;
try {
return $this->loadExtension(PluginInterface::class, $plugin . ':' . $type, $path);
} catch (\Error $e) {
Factory::getApplication()->enqueueMessage($e->getMessage(),'error');
//behave like plugin not found.
$dispatcher = $this->getContainer()->get(DispatcherInterface::class);
return new DummyPlugin($dispatcher);
}
}
Labels |
Added:
No Code Attached Yet
|