/
3.5.1-b1.php
48 lines (42 loc) · 2.02 KB
/
3.5.1-b1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Filesystem;
use Piwik\Notification;
use Piwik\Plugin\Manager;
use Piwik\SettingsServer;
use Piwik\Updater;
use Piwik\Updates as PiwikUpdates;
class Updates_3_5_1_b1 extends PiwikUpdates
{
public function doUpdate(Updater $updater)
{
// try to deactivate and remove the GeoIP2 plugin from marketplace,
// which causes problems with GeoIp2 plugin included in core
// Skip if new file `isoRegionNames.php` is detected within `GeoIP2` directory, as that means filesystem is case
// insensitive and GeoIP2 plugin has been partially overwritten by GeoIp2 plugin
try {
if (is_dir(PIWIK_INCLUDE_PATH . '/plugins/GeoIP2') && !file_exists(PIWIK_INCLUDE_PATH . '/plugins/GeoIP2/data/isoRegionNames.php')) {
// first remove the plugin files, as trying to deactivate would load the plugin files resulting in a fatal error
Filesystem::unlinkRecursive(PIWIK_INCLUDE_PATH . '/plugins/GeoIP2', true);
// if plugin was activated, trigger deactivation to remove the config entry and set a notification
if (Manager::getInstance()->isPluginActivated('GeoIP2')) {
@Manager::getInstance()->deactivatePlugin('GeoIP2');
$notification = new Notification('GeoIP2 plugin from Marketplace has been removed due to compatibility issues. Please check your geolocation settings.');
$notification->context = Notification::CONTEXT_WARNING;
$notification->type = Notification::TYPE_PERSISTENT;
Notification\Manager::notify('GeoIP2_update_warning', $notification);
}
// uninstall the plugin to remove it from config
@Manager::getInstance()->uninstallPlugin('GeoIP2');
}
} catch (\Exception $e) {
}
}
}