ezpublish-legacy
ezpublish-legacy copied to clipboard
Fix EZP-21913: ezpublish:legacy:script break with usage of globals in scripts
https://jira.ez.no/browse/EZP-21913 https://jira.ez.no/browse/EZP-21941
Replaces #826 . Complementary PR: #831
This PR replaces usage of flawed global
keyword by closures. This allows to import context from inside the script.
Reason: These variables are not global anymore when scripts are executed via ezpublish:legacy:script.
Scripts to fix up
- [x] changelog2xmltext.php
- [x] clusterize.php
- [x] convertprice2multiprice.php
- [x] ezconvertdbcharset.php
- [x] ezflowupgrade.php
- [x] ezwebincommon.php
- [x] ezwebininstall.php
- [x] ezwebinupgrade.php
One note... I've thought about it, and I don't really see the point of using a closure to pass objects we have singletons for... we don't love singletons anymore, but they're here, and we might as well use them, right ?
In many cases, I also find that adding an argument is easier than changing the code (and the ordering, not cool for diffs).
I might of course be missing a point here.
@bdunogier Your right, it was mostly because it makes it easier to read the code later. But if you use closure you have to make sure variable is already declared, and use statement needs to be by reference in cases variable is not object..
All scripts have been fixed, ready for review !
IMHO there should be no need for an eZDir global... there are two chdirs() in the script, a good solution is to use
$eZDir = getcwd();
// ... chdir and do stuff
chdir($eZDir);
Then just remove it completely from the showError()
the other places...
There is a mode change (10755 -> 10644) in some files scripts, is this intended?
- bin/php/ezconvertdbcharset.php
- bin/php/ezflowupgrade.php
@joaoinacio: Good catch, it is not.
@andrerom @bdunogier Should this be merged or closed ?
I assume this is still an issue, so with mode change and eZDir fix we should merge this.