New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds update script to remove GeoIP2 plugin from marketplace #12897
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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) { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?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\Plugins\GeoIp2\tests\Integration; | ||
|
||
/** | ||
* @group GeoIp2 | ||
*/ | ||
class UpdateTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testEnsureFileForUpdateIsPresent() | ||
{ | ||
// In update Updates_3_5_1_b1 the file `plugins/GeoIp2/data/isoRegionNames.php` is used to check file system | ||
// case sensitivity. Therefor we need to ensure this file is present unless the update script isn't changed | ||
$this->assertFileExists(PIWIK_INCLUDE_PATH . '/plugins/GeoIp2/data/isoRegionNames.php'); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we would need to add a test that makes sure this file exists? Just to be safe... if we otherwise ever remove the file, the plugin will be removed when someone updates from say an older Matomo version to a much newer. Be good to name the test clear to indicate what happens if the file does not exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. Will add the test now