We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25061
    • 3 Posts
    Hi everybody, I’m new here and this is my first post. I’m searching to find the "ultimate" CMS and I was steered here yesterday by an (excellent) interview with Mary which compared MODx with Drupal. I am currently evaluating your CMS and have a couple comments.

    First off I’m an engineer and have been programming since the mid-70’s (working with low level software in the aerospace and system software industries). I set high standards for myself and try to work with products and communities that share this philosophy. Also, I am an adherent to the KISS principle. One of the first things I do when checking out a new software package is navigate to their home page and apply Opera’s "three-finger-salute" (CTRL+ALT+V), which sends the page off to the W3C validator. Unfortunately, there are precious few websites that actually take validation seriously. Sites that validate get points in my book, but since most don’t I don’t penalize them too much. However, CMS projects in particular, are in the business of providing software that actually builds websites for people, so it makes sense that their flagship home web pages (which reflect the quality of their product), really should validate - especially for those CMSs that claim to be proponents of web standards. Well, your main page currently has 14 validation errors! But no biggie - you’re no worse than the others in this regard. In the past, when I pointed this out on the forums of various other CMS’s (i.e. Joomla, Drupal and EE) I got a variety of interesting responses (worth reading) and some of them went on to fix their home pages as a result (EE and Joomla) but some still haven’t (Drupal). Bottom line: I don’t mean to be critical here - just giving you a "head’s up" about your main page’s validation status. (please don’t shoot the messenger!)

    Secondly, I consider myself to be an expert with regular expressions and one of the first things I look at in a new package is all the preg_function() calls in the PHP source code. These functions, (and more importantly the regex patterns passed to them), are critical for the correct and efficient processing of web applications. And well crafted regular expressions are an important indication of the quality of the code in my eyes. So far, I’ve looked at a couple dozen of the regexes in the MODx 2.0.0-beta-5 code (out of approximately 259), and the good news is that most of these look pretty good so far. Most appear to be logically correct, although many can be improved with regard to efficiency. But I did come across one that has an error (and this is what prompted me to write this post):
    MODx: 2.0.0-beta-5; File: core/model/modx/filters/modoutputfilter.class.php; Line: 203
      case 'strip':
          /* Replaces all linebreaks, tabs and multiple spaces with just one space */
          $output= preg_replace("~([\n|\r|\t|\s]+)~", " ", $output);
          break;

    Do you see the problem? The pipe char ’|’ is being erroneously specified inside a character class. (the ’|’ does not work as an OR separator inside a char class.) So in addition to consolidating whitespace, this preg_replace operation is also converting pipe characters into spaces! Also, this regex reveals a fundamental misunderstanding of the ’\s’ whitespace specifier (and I see this same misunderstanding manifested in many of the regexes I’ve looked at so far). The ’\s’ metacharacter is a shorthand character class that includes all the other alternatives in this regex (i.e. \n,\r and \t), so specifying them in addition to the ’\s’ is redundant and inefficient. Also, the above regex uses capturing parentheses which is both unnecessary and inefficient (this problem was also evident with many of the other regexes I looked at). Thus this regex can be corrected and simplified like so:
    MODx: 2.0.0-beta-5; File: core\model\modx\filters\modoutputfilter.class.php; Line: 203
      case 'strip':
          /* Replaces all linebreaks, tabs and multiple spaces with just one space */
          $output= preg_replace("/\s+/", " ", $output);
          break;

    I’m sorry if this post comes across with a negative tone, but that’s just my nature as an engineer with a critical eye - I see the problems, but also offer solutions. (My degree is actually in Civil Engineering and in this profession it is really important to think of everything that can go wrong before it does - especially when dealing with such things as bridges, dams and skyscrapers because you don’t want these things falling down! They must be built right the first time.) Actually, so far I really like what I see with MODx. If I decide to stick around, I’ll be happy to provide some suggested improvements specifically with regard to the regular expressions in the code.

    Hi Everybody!
    Jeff Roberson
      • 8609
      • 607 Posts
      Hey Jeff

      Good to see you here, welcome aboard. Glad you enjoyed the interview, and thank you for the comments you left on my blog, I responded to them smiley

      The MODx community is very vibrant and open to ideas, comments, constructive criticisms, and the skills we all bring to the table. I’m sure one of the developers will be along soon to discuss your post with you.

      Just wanted to say welcome to the forums grin

      mary
        • 28215
        • 4,149 Posts
        Jeff, I’ll reply more later, but thanks much for the bug catch. We appreciate it.

        Could you, by chance, file that in our issue tracker? You can find it here:

        http://bugs.modxcms.com/
          shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
          • 3749
          • 24,544 Posts
          And please feel free to post any other bugs you find there too. grin

          On the validation, thanks again for pointing it out. Since the site is using MODx, it changes often and we’re shorthanded so re-checking to see if it still validates always seems to be lower on the list than fixing known bugs and adding new features to MODx. wink

          Be careful, you may end up being drafted. You can never have too many regex experts. tongue
            Did I help you? Buy me a beer
            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
            • 25061
            • 3 Posts
            Quote from: splittingred at Feb 26, 2010, 11:33 PM
            ... Could you, by chance, file that in our issue tracker? ...

            Done and done.
              • 25663 MODX Staff
              • 12,272 Posts
              Hello Jeff,

              Thanks indeed for pointing out the regex issue. We wholeheartedly welcome your experience and are tremendously open to new ideas and approaches. Please don’t hesitate to keep them coming!

                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me