5.6 Package Upgrade
PermalinkSee core/controllers/extend/update.php:
$p->upgradeCoreData();
$p->upgrade();
In this situation it's not possible to use version_compare, right? Also, if the upgrade fails, it doesn't restore the original version number.
Any thoughts?
Maybe the updater for eCommerce has some clues. That's about the longest and most complex updater I know of.
That said, you can actually keep the old version number stored if you just override the upgradeCoreData() method.
Here's one (hacky) solution I've come up with:
public function upgradeCoreData() { $packages = Package::getLocalUpgradeablePackages(); foreach ($packages as $pkg) { if ($pkg->getPackageHandle() === $this->getPackageHandle()) { // Store the old version number $this->pkgCurrentVersion = $pkg->pkgCurrentVersion; break; } } parent::upgradeCoreData(); }
And then in your upgrade() method:
public function upgrade() { if (version_compare($this->pkgCurrentVersion, "1.1", '<')) { // Do stuff... } }
But try to avoid that as far as possible. As mentioned, you should search for features/lacking features instead.
Op Vr jul 18 2014, om 06:42 schreef concrete5 Community:
Install is a much easier scenario to manage - the package ends up installed or not installed.