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