Subscribe: RSS
  • Hello!

    I wanted to upgrade my current version 2.6.5 to 2.7.0 on a shared hosting service, and did it the way I always do it. Download the ZIP and repackage it to get rid of the first directory level (so that the main directory content of the ZIP is core, manager, setup, etc. and not modx-2.7.0-pl/core, modx-2.7.0-pl/manager, etc.).

    I then uploaded the new ZIP to the webserver, extracted it there and called the setup. At the point where you normally see the summary page before the upgrade really starts, I got this error message:

    Parse error: syntax error, unexpected '[' in /usr/www/users/mysite/core/model/modx/modx.class.php on line 283
    


    I checked that file and found this section:

        /**
         * Keeps an in-memory representation of what deprecated functions have been logged
         * for this request, to avoid spamming the log too often. See the `deprecated` method.
         *
         * @var array
         */
        private $loggedDeprecatedFunctions = [];
    


    It seemed correct to me, but when I changed the "[]" to "array()" (which should be the same difference), the setup went through without a hitch. And the new installation is running smoothly now.

    But I'd like to know: What has happened there? Did I do something wrong to have caused this? Have I shot myself in the foot somehow by changing the modx.class.php in the described manor? Or am I good to go?

    This question has been answered by BobRay. See the first response.

    • discuss.answer
      You have an older version of PHP. The [] array syntax requires PHP >= 5.4.

      I don't know why people are switching to the new syntax. AFAIK, the old syntax is not deprecated (and may not ever be), the new syntax is not any faster or more efficient -- and, as in your case, it breaks things for people with older versions of PHP.
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/MODx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
      • Thanks. It didn't occur to me to check for EOL PHP because it's a shared hosting environment. I don't control the software, and simply assumed the hoster would not run unmaintained PHP versions on their servers for their own security. But it seems like they do. Maybe to not break customer installations, idk.

        There was an option in their web frontend to select which PHP gets used. I changed it to 7.2 (newest available), just to be sure (security and all that). Hopefully, that should prevent any problems with "[]" and its ilk on future updates.
        • And your website should be *way* faster. smiley
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/MODx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting