BobRay / UpgradeMODX

A dashboard widget that detects upgrades and (optionally) installs them from within the MODX Manager
https://bobsguides.com/upgrade-modx-package.html
22 stars 14 forks source link

Error 500, incorrect snippet caching #49

Closed Ruslan-Aleev closed 6 years ago

Ruslan-Aleev commented 6 years ago

Error 500 when installing / upgrading UpgradedMODX (It is noticed since MODX Revo 2.6.1, UpgradeMODX 1.5.5):

[08-09-2018 10:35:46 Europe/Moscow] PHP Fatal error: Cannot redeclare rrmdir() (previously declared in .../public_html/core/cache/includes/elements/modsnippet/51.include.cache.php:57) in .../public_html/core/cache/includes/elements/modsnippet/51.include.cache.php on line 76

Technical support advised to wrap the definition of a function in a condition to verify its existence:

if (! function_exists ('rrmdir')) {
function rrmdir ($ dir) {
    if (is_dir ($ dir)) {
        $ objects = scandir ($ dir);
        foreach ($ objects as $ object) {
            if ($ object! = "." && $ object! = "..") {
                if (filetype ($ dir. "/". $ object) == "dir") {
                    $ prefix = substr ($ object, 0, 4);
                    $ this-> rrmdir ($ dir. "/". $ object);
                } else {
                    $ prefix = substr ($ object, 0, 4);
                    if ($ prefix! = '.git' && $ prefix! = '.svn') {
                        @unlink ($ dir. "/". $ object);
                    }
                }
            }
        }
        reset ($ objects);
        $ success = @rmdir ($ dir);
    }
}
}
BobRay commented 6 years ago

Thanks. This is a duplicate of #37

It's fixed in the dev. branch.