Skip to content
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

Add legacy autoloader for 2.x-dev for smoother upgrades #16070

Merged
merged 5 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions LegacyAutoloader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

class LegacyAutoloader
{
public function __construct()
{
spl_autoload_register(array($this, 'load_class'));
}

public static function register()
{
new LegacyAutoloader();
}

public function load_class($className)
{
if (strpos($className, 'Matomo\\') === 0) {
$newName = 'Piwik' . substr($className, 6);
if (class_exists($newName) && !class_exists($className, false)) {
@class_alias($newName, $className);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was added in 5.3.0 so that should be fine https://www.php.net/manual/en/function.class-alias.php

}
} elseif (strpos($className, 'Piwik\\') === 0) {
$newName = 'Matomo' . substr($className, 5);
if (class_exists($newName) && !class_exists($className, false)) {
@class_alias($newName, $className);
}
}
}
}

LegacyAutoloader::register();
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
"HTML_": "libs/",
"PEAR_": "libs/",
"Archive_": "libs/"
}
},
"files": ["LegacyAutoloader.php"]
},
"autoload-dev": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion core/Plugin/ControllerAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private static function notifyIfEAcceleratorIsUsed()
*/
private static function getNextRequiredMinimumPHP()
{
return '5.5.9';
return '7.2.5';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

benefit is that users will get a better warning

}

private static function isUsingPhpVersionCompatibleWithNextPiwik()
Expand Down
2 changes: 1 addition & 1 deletion core/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class Version
* The current Piwik version.
* @var string
*/
const VERSION = '2.18.0';
const VERSION = '2.18.1';

public function isStableVersion($version)
{
Expand Down