Prevent upgrade error should a plugin get disabled during the Matomo 4 upgrade #16468
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.
Could probably also remove the file again from
core/API/NoDefaultValue.php
and simply always define it here. This prevents showing an error likeclass Proxy already defined
.What happened?
PluginManager.pluginDeactivated
Request::processRequest
Proxy::getInstance()
new Proxy()
__constructor
inProxy
class.$this->noDefaultValue = new NoDefaultValue()
Proxy.php
defined two classes in one file.class Proxy
andclass NoDefaultValue
.'Piwik\\API\\NoDefaultValue' => $baseDir . '/core/API/Proxy.php',
Proxy class
from the Matomo 4 code which does no longer containNoDefaultValue
in the same file but in a separate filecore/API/NoDefaultValue.php
.NoDefaultValue
class did not exist yet as it's no longer in the same file asProxy.php
'Piwik\\API\\NoDefaultValue' => $baseDir . '/core/API/Proxy.php',
because the autoloader was loaded with Matomo 3 configuration. It should have done'Piwik\\API\\NoDefaultValue' => $baseDir . '/core/API/noDefaultValue.php',
core/API/Proxy.php
again. Not to load the Proxy class but to load theNoDefaultValue
class.Cannot redeclare class Piwik\API\Proxy, because the name is already in use
.The only workaround was to add the class back to
Proxy.php
. Then the updated no longer resulted in an error. I verified this by patching the Proxy.php as in this PR, building a custom release zip, and then testing the upgrade.Here's the backtrace that led to this error: