v2.6.6 (Lyra): Essential plugins altijd laden (forceer in core)

Bug: beschermde/essentiële plugins (Dashboard, Navigation) konden niet
meer geactiveerd worden als ze uit enabled_plugins raakten. Core forceert
nu laden van essential plugins (plugin.json essential: true); admin-UI
toont ze altijd als Actief; toggle-handler staat aanzetten wél toe,
uitzetten blijft geblokkeerd; isProtectedPlugin() dekt nu ook essential.
This commit is contained in:
2026-08-27 19:43:42 +00:00
parent 0e345c96d7
commit f7e8837a1c
7 changed files with 166 additions and 22 deletions
+42 -13
View File
@@ -179,7 +179,7 @@ function getSidebarColor($config) {
*
* @since 2.6.5
*
* @return array<int,string> Namen van beschermde plugins (bijv. ['Navigation']).
* @return array<int,string> Namen van beschermd geworden plugins (bijv. ['Navigation']).
*/
// Essential plugins that cannot be disabled or deleted
function getProtectedPlugins(): array {
@@ -187,7 +187,34 @@ function getProtectedPlugins(): array {
}
/**
* Controleert of een pluginnaam op de lijst van beschermde plugins staat.
* Controleert of een plugin in zijn plugin.json `essential: true` heeft.
*
* Essential plugins worden altijd geladen en kunnen niet worden uitgeschakeld,
* bewerkt of verwijderd via de admin. De check is pad-onafhankelijk en leest
* de plugin.json uit de standaard plugins-directory.
*
* @since 2.6.6
*
* @param string $pluginName Naam van de plugin om te controleren.
* @return bool True wanneer de plugin essential is, anders false.
*/
function isEssentialPluginByName(string $pluginName): bool {
if ($pluginName === '') {
return false;
}
$pluginJsonFile = __DIR__ . '/../plugins/' . $pluginName . '/plugin.json';
if (!file_exists($pluginJsonFile)) {
return false;
}
$data = json_decode(file_get_contents($pluginJsonFile), true);
return is_array($data) && ($data['essential'] ?? false) === true;
}
/**
* Controleert of een plugin beschermd is (niet uit te schakelen/verwijderen).
*
* Een plugin is beschermd wanneer deze op de hardcoded lijst staat
* (getProtectedPlugins()) OF in zijn plugin.json `essential: true` heeft.
*
* @since 2.6.5
*
@@ -195,7 +222,7 @@ function getProtectedPlugins(): array {
* @return bool True wanneer de plugin beschermd is, anders false.
*/
function isProtectedPlugin(string $pluginName): bool {
return in_array($pluginName, getProtectedPlugins(), true);
return in_array($pluginName, getProtectedPlugins(), true) || isEssentialPluginByName($pluginName);
}
/**
@@ -3795,7 +3822,7 @@ function handlePlugins($auth, $config, $twig, $user, $csrf): void
$pluginData = [
'name' => $pluginName,
'enabled' => in_array($pluginName, $enabledPlugins),
'enabled' => in_array($pluginName, $enabledPlugins) || isProtectedPlugin($pluginName),
'protected' => isProtectedPlugin($pluginName),
'type' => 'content',
];
@@ -5216,19 +5243,21 @@ function handlePluginsToggle($auth, $config): void
$plugin = $_POST['plugin'] ?? '';
$plugin = preg_replace('/[^a-zA-Z0-9_-]/', '', $plugin);
// Block toggling protected plugins
if (isProtectedPlugin($plugin)) {
$configFile = $config['config_json'];
$siteConfig = file_exists($configFile) ? json_decode(file_get_contents($configFile), true) : [];
$enabledPlugins = $siteConfig['enabled_plugins'] ?? [];
$currentlyEnabled = in_array($plugin, $enabledPlugins, true);
// Protected/essential plugins mogen niet uitgeschakeld worden (maar wel
// aangezet worden als ze per ongeluk uit enabled_plugins zijn geraakt).
if (isProtectedPlugin($plugin) && $currentlyEnabled) {
adminLog($config, 'warning', $user['username'] . ' probeerde essentiële plugin ' . $plugin . ' te deactiveren');
header('Location: /admin/plugins');
exit;
}
$configFile = $config['config_json'];
$siteConfig = file_exists($configFile) ? json_decode(file_get_contents($configFile), true) : [];
$enabledPlugins = $siteConfig['enabled_plugins'] ?? [];
if (in_array($plugin, $enabledPlugins)) {
if ($currentlyEnabled) {
$enabledPlugins = array_diff($enabledPlugins, [$plugin]);
adminLog($config, 'info', $user['username'] . ' deactiveerde plugin ' . $plugin);
} else {