Skip to content

Commit c1bb73e

Browse files
authored
Fix error with plugins deactivation on install UI (#19774)
* Fix error with plugins deactivation on install UI * Skip plugins deactivation if there is nothing to deactivate * check table existence
1 parent 13fc2ac commit c1bb73e

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/Glpi/Kernel/KernelListenerTrait.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
namespace Glpi\Kernel;
3636

37+
use Config;
3738
use DBConnection;
3839
use Symfony\Component\HttpFoundation\Request;
3940
use Update;
@@ -77,6 +78,8 @@ protected function isSymfonyProfilerEndpoint(Request $request): bool
7778
*/
7879
protected function isDatabaseUsable(): bool
7980
{
80-
return DBConnection::isDbAvailable() && Update::isUpdateMandatory() === false;
81+
return DBConnection::isDbAvailable()
82+
&& Config::isLegacyConfigurationLoaded()
83+
&& Update::isUpdateMandatory() === false;
8184
}
8285
}

src/Glpi/Kernel/Listener/PostBootListener/DisablePluginsOnVersionChange.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434

3535
namespace Glpi\Kernel\Listener\PostBootListener;
3636

37+
use Config;
3738
use DBConnection;
39+
use DBmysql;
3840
use Glpi\Debug\Profiler;
3941
use Glpi\Kernel\ListenersPriority;
4042
use Glpi\Kernel\PostBootEvent;
@@ -53,7 +55,15 @@ public static function getSubscribedEvents(): array
5355

5456
public function onPostBoot(): void
5557
{
56-
if (!DBConnection::isDbAvailable()) {
58+
/** @var \DBmysql|null $DB */
59+
global $DB;
60+
61+
if (
62+
!DBConnection::isDbAvailable()
63+
|| !Config::isLegacyConfigurationLoaded()
64+
|| !($DB instanceof DBmysql)
65+
|| !$DB->tableExists(Plugin::getTable())
66+
) {
5767
return;
5868
}
5969

src/Plugin.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,10 @@ public function unactivateAll()
12181218
/** @var \DBmysql $DB */
12191219
global $DB;
12201220

1221+
if (countElementsInTable(static::getTable(), ['state' => self::ACTIVATED]) === 0) {
1222+
return;
1223+
}
1224+
12211225
$DB->update(
12221226
$this->getTable(),
12231227
[

0 commit comments

Comments
 (0)