Pimcore update from build 228 -> 299


#1

Hi,

I tried to update our Pimcore instance from build 228 to the latest stable release v5.4.0 (build 299).

I used the pimcore:update --update 5.4.0 --verbose console command to perform the update.

At some stage I had to reinitiate the update as it was aborted due to php out of memory error (I fixed that, no problem here). At this stage most of the build updates were already performed and along with this a new Update.php was introduced. This new Update.php breaks the composer-invalidate-classmap job when reinitiating the update procedure. To my understanding, after reinitiating, the update process first runs the invalidation job, then it picks from where it left, and continues the build updates. The problematic change I’m talking about is located in the function invalidateComposerAutoloadClassmap at line 505 in Update.php.

 /**
 * @return array
 */
public static function invalidateComposerAutoloadClassmap()
{
    // we don't invalidate anymore here, this would break the final update to Pimcore 5.4.0
    // this doesn't matter anymore since this class is gone anyway in 5.4.0
    return;

While the job is being executed, this function returns NULL which leads to an error in the UpdateCommand.php at line 201. The result is being evaluated and due to the fact that NULL is returned, the IF query returns false on array type check, flags the job as an error and exits the update procedure.

$return = Console::runPhpScript($script, 'internal:update-processor --ignore-maintenance-mode ' . escapeshellarg(json_encode($job)));**strong text**

            $return = trim($return);

            $returnData = @json_decode($return, true);
            if (is_array($returnData)) {    <-- here it checks for array type but returnData is NULL
             ...
            } else {
                $stoppedByError = true;
                break;                              <-- leaves the for loop
            }

When I modify this function to return an array such as

 /**
 * @return array
 */
public static function invalidateComposerAutoloadClassmap()
{
    // we don't invalidate anymore here, this would break the final update to Pimcore 5.4.0
    // this doesn't matter anymore since this class is gone anyway in 5.4.0
    return [
            'success' => true
        ];

everything is ok.

Next thing is the preupdate script from build 298. The contents are

<?php
echo '<b>You\'ve reached the end of the traditional update process!</b><br />';
echo 'Please have a look at the <a href="https://pimcore.com/docs/5.x/Development_Documentation/Installation_and_Upgrade/Upgrade_Notes/Within_V5.html#page_Version-5-4-0">upgrade notes for version 5.4.0</a> to continue the update.';
echo '<br><div style="text-align:center"><iframe class="giphy-embed" frameborder="0" height="150" src="https://giphy.com/embed/zoiKvXZOiRijC" width="150"></iframe></div>';
exit;

As you can see, it exits the script directly using exit command. This leads to a problem as the calling function executeScript in Update.php has no chance to return a value hence the UpdateCommand.php again evaluates NULL and exits the update process as shown earlier.

 /**
 * @param $revision
 * @param $type
 *
 * @return array
 */
public static function executeScript($revision, $type)
{

...

try {
 if (!self::$dryRun) {
   include($script);    <-- invoke script
  }
 } catch (\Exception $e) {
        Logger::error($e);
        $outputMessage .= 'EXCEPTION: ' . $e->getMessage();
        $outputMessage .= '<br>For details please have a look into the log files in /var/logs<br>';
 }

...

        return [   <--- this will never be reached due to the hard exit in the preupdate script
        'message' => $outputMessage,
        'success' => true
    ];
}

I’ve removed the exit command so the executeScript function returned a valid array to the UpdateCommand.php script.

Another thing is that build 299 is introducing a new Version.php which should bump the pimcore version to build 299 version 5.4.0. However, the Version.php from build 299 is a copy of Version.php from build 298.

https://liveupdate.pimcore.org/download-files?for=298&offset=0&limit=50
MD5: e1301b5aaea2c143b4619626e049b463

https://liveupdate.pimcore.org/download-files?for=299&offset=0&limit=50
MD5: e1301b5aaea2c143b4619626e049b463

Both hashes are a match.

This means you cannot get rid of the “Updates available” notification in the pimcore backend as due to the fact you’ll never reach build 299 from Version.php perspective.

As of now I completed all update tasks successfully, however, get stuck at build 298 as build 299 introduces the Version.php from build 298.

Please advice if I do something wrong with the update process. Am I’m missing something here?

Many thanks