Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
44.44% covered (danger)
44.44%
4 / 9
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
disable_extensions
44.44% covered (danger)
44.44%
4 / 9
66.67% covered (warning)
66.67%
2 / 3
6.74
0.00% covered (danger)
0.00%
0 / 1
 depends_on
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 update_data
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 disable_enabled_extensions
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14namespace phpbb\db\migration\data\v400;
15
16use phpbb\db\migration\container_aware_migration;
17
18class disable_extensions extends container_aware_migration
19{
20    /**
21     * @var array List of extensions included with phpBB
22     */
23    public static array $default_extensions = [
24        'phpbb/viglink',
25    ];
26
27    public static function depends_on(): array
28    {
29        return ['\phpbb\db\migration\data\v400\v400a1'];
30    }
31
32    public function update_data(): array
33    {
34        return [
35            ['custom', [[$this, 'disable_enabled_extensions']]],
36        ];
37    }
38
39    /**
40     * Disable all enabled extensions except those included with phpBB.
41     * This is a safety measure to prevent possible PHP fatal errors
42     * caused by extensions that are not compatible with the changes
43     * introduced with phpBB 4.0.0-a2.
44     */
45    public function disable_enabled_extensions(): void
46    {
47        $ext_manager = $this->container->get('ext.manager');
48
49        $enabled_extensions = array_keys($ext_manager->all_enabled());
50        $enabled_extensions = array_diff($enabled_extensions, self::$default_extensions);
51
52        foreach ($enabled_extensions as $extension)
53        {
54            $ext_manager->disable($extension);
55        }
56    }
57}