We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18668
    • 25 Posts
    One of my MODx-powered sites recently developed a problem with MaxiGallery causing parse errors. This was after an upgrade to MODx 0.9.6.2 (not sure if that’s connected or not), and appears to be an issue with the bit of MaxiGallery that checks the $output string for illegal characters using the php htmlentities function. This is the error that’s being thrown up:

    « MODx Parse Error »

    MODx encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »

    PHP error debug
    Error: htmlentities() [function.htmlentities]: Invalid multibyte sequence in argument
    Error type/ Nr.: Warning - 2
    File: /home/canoness/public_html/assets/snippets/ditto/classes/phx.parser.class.inc.php
    Line: 243
    Line 243 source: case "htmlent": $output = htmlentities($output,ENT_QUOTES,$modx->config[’etomite_charset’]); break;

    I’ve gone into the offending file and I’ve been able to comment out the line that calls htmlentities, and then the page loads correctly. Well, almost correctly - there are illegal characters slipping into the image titles and descriptions, because those characters aren’t being parsed out by the line I’ve just commented out.

    I’ve had a look around, and it looks like this function is being called a lot, i.e. every time something is outputted to the page. This seems like overkill to me - surely we only need to check for and remove those illegal characters when they’re being added? Clearly I can’t just remove the :htmlent PHx bit from all the templates, because those illegal characters are stored in the database. Is there a way of doing the htmlentities bit when we’re adding the title and description to the db instead, so we only have to do it once?

    Simple solution is for me to just go into the image descriptions and manually remove the illegal characters, probably introduced from the client pasting from Word or something... but it would be good to have a proper solution too. Any thoughts?
      ******************
      Matthew Dawkins
      www.matthewdawkins.co.uk
      We make web sites for churches
      Follow me on Twitter: twitter.com/chapter9
      ******************
      • 7923
      • 4,213 Posts
      Quote from: matthewdawkins at Dec 05, 2008, 05:43 AM

      I’ve had a look around, and it looks like this function is being called a lot, i.e. every time something is outputted to the page. This seems like overkill to me - surely we only need to check for and remove those illegal characters when they’re being added? Clearly I can’t just remove the :htmlent PHx bit from all the templates, because those illegal characters are stored in the database. Is there a way of doing the htmlentities bit when we’re adding the title and description to the db instead, so we only have to do it once?
      Yes, you could put it in the code where MaxiGallery put’s data to the database. But I cannot force it to do that, because some may want html content in the database and shown in frontend. If you use cached snippet call in your maxigallery installation, it’s not a problem even if htmlentities is called for each text output. But yes, I haven’t spent much time in optimizing MaxiGallery and I suggest to always use cached output for that reason. Of course with some display types, you cannot use caching (normal display mode or with paging).

      But the root problem that you are having is that why PHx :htmlent modifier stopped working. And that’s probably because when you updated to new MODx version, you updated your Ditto version too and the PHx in that doesn’t work for you. You might want to try and install PHx as a plugin, so the versions from different components are not used and see where that gets you. Some plugin version should work for you if it has been working previously.

      It could be also that your server provider updated PHP version and that made this happen. I’m not also sure if $modx->config[’etomite_charset’] is valid any more, you might want to change it to

      I’m betting that if you change the line in assets/snippets/ditto/classes/phx.parser.class.inc.php:

      $output = htmlentities($output,ENT_QUOTES,$modx->config[’etomite_charset’]); break;

      to some of these, it’ll work (start from the top):

      $output = htmlentities($output,ENT_QUOTES,$modx->config[’modx_charset’]); break;
      $output = htmlentities($output,ENT_QUOTES,’UTF-8’); break;
      $output = htmlentities($output,ENT_QUOTES); break;
      $output = htmlentities($output); break;


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."