We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33983 ☆ A M B ☆
    • 181 Posts
    Hi all,

    I just installed MODX 2.2.13pl on a new CentOS with PHP 5.5.10 and MySQL 5.5.*. As I was setting up some packages I discovered that I could not install one that had snippets, Databackup. Since that is an extra I wrote I rebuilt it, thinking maybe the file was corrupt. And then tried to reinstall but it failed again with the same error. I did a web search and only saw one person with a similar error. I then tried to manually create some test snippets, then chunks and TVs.
    And this is the error I got:
    [2014-03-18 16:14:31] (ERROR @ core/xpdo/validation/xpdovalidator.class.php : 82) PHP warning: preg_match(): Compilation failed: invalid range in character class at offset 38
    


    Very similar to the install log errors:
    /*
    * MODX Console Output
    *
    * @date 2014-03-18 15:47:05
    */
    Attempting to install package with signature: databackup-1.1.7-pl
    
    Package found...now preparing to install.
    
    Grabbing package workspace...
    
    Workspace environment initiated, now installing package...
    
    PHP warning: preg_match(): Compilation failed: invalid range in character class at offset 38
    PHP notice: Array to string conversion
    
    snippet_err_createArray
    
    Error saving vehicle object of class modSnippet; criteria: Array
    (
        [name] => backup
    )
    
    PHP warning: preg_match(): Compilation failed: invalid range in character class at offset 38
    PHP notice: Array to string conversion
    snippet_err_createArray
    
    Error saving vehicle object of class modSnippet; criteria: Array
    (
        [name] => backupmany
    )
    
    Could not install related objects with locally owned keys for vehicle object of class modCategory; criteria: Array
    (
        [category] => Databackup
    )
    
    Successfully installed package databackup-1.1.7-pl
    
    /* EOF */
    


    Not sure if this is a bug in MODX or something I need to adjust in MySQL. Note I have mostly worked in windows and I am just getting familiar with setup in linux. Any help would be great! Thanks
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      This is an issue that pops up from time to time in PHP's regex handling. I've seen some other questions about that version of PHP.

      In most cases, it seems to be a problem when validating a range of characters that includes the - character like "a-z-_"; the - needs to be at the beginning or at the end of the expression, or escaped, so that the regex doesn't see it as a range indicator, like in the range a-z.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 33983 ☆ A M B ☆
        • 181 Posts
        Thanks Susan, I also found this: https://forums.modx.com/thread/89312/chunk-name-is-invalid

        I am not a regex expert but if the regex provided above does the same then it should be updated in the core. Found in these files:
        /**
          /^(?!\\s)[a-zA-Z0-9\\x2d-\\x2f\\x7f-\\xff_-\\s]+(?!\\s)$/ TO BECOME: /^(?!\\s)[a-zA-Z0-9\\x2d-\\x2f\\x7f-\\xff-_\\s]+(?!\\s)$/
        */
        modchunk.map.inc.php
        modsnippet.map.inc.php
        modtemplatevar.map.inc.php
        /** 
          and for the build 
          /^(?!\s)[a-zA-Z0-9\x2d-\x2f\x7f-\xff_-\s]+(?!\s)$/ TO BECOME: /^(?!\s)[a-zA-Z0-9\x2d-\x2f\x7f-\xff-_\s]+(?!\s)$/
        */
        core/model/schema/modx.mysql.schema.xml
        


        I will post an issue on Git.
          • 33983 ☆ A M B ☆
          • 181 Posts
            • 9674
            • 170 Posts
            Had the same problem that disappeared with update to 2.2.14