ryancramerdesign / ProcessWireUpgrade

Upgrade ProcessWire core to latest master or dev version automatically in the admin.
16 stars 6 forks source link

PHP warnings while upgrading ProcessWire #33

Closed matjazpotocnik closed 3 years ago

matjazpotocnik commented 3 years ago

Hi, @ryancramerdesign! Thank you for working on this module again.

I was trying to upgrade PW from 3.0.174 to the latest dev 3.0.177 and got this warrings:

PHP Warning: file_get_contents(C:/inetpub/wwwroot/site/assets/cache/ProcessWireUpgrade/index.php): Failed to open stream: No such file or directory in ...\ProcessWireUpgrade.module:539
PHP Warning: file_get_contents(C:/inetpub/wwwroot/site/assets/cache/ProcessWireUpgrade/htaccess.txt): Failed to open stream: No such file or directory in ...\ProcessWireUpgrade.module:545

This line throws a warning:

$newIndexData = file_get_contents($rootTempPath . 'index.php');

since downloaded zip file contains a folder 'processwire-dev' and $rootTempPath is still pointing to C:/inetpub/wwwroot/site/assets/cache/ProcessWireUpgrade/ instead of C:/inetpub/wwwroot/site/assets/cache/ProcessWireUpgrade/processwire-dev/

I think the check for this situation should be done right after assigning $rootTempPtah and $wireTempPath:

        if(!$error && !is_dir($wireTempPath)) {
            // adjust paths according to where they were unzipped, as needed
            // need to drill down a level from extracted archive
            // i.e. files[0] may be a dir like /ProcessWire-dev/
            $rootTempPath = $this->tempPath . trim($files[0], '/') . '/';
            $wireTempPath = $rootTempPath . "wire/";
        }
ryancramerdesign commented 3 years ago

Thanks @matjazpotocnik I've moved that block of code up per your suggestion. It's unclear to me why sometimes it's in a ProcessWire-dev/master directory and sometimes not. I don't recall running into that particular case when testing, but I (or someone) must have at some point since the code check was there, but just in the wrong spot. Thanks for letting me know.

matjazpotocnik commented 3 years ago

Thanks. Closing.