We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30100
    • 58 Posts
    After my friends web hosting company one.com upgraded thier PHP to version 5.3 MODx started to save the documents in a way so that all " became \" like this <a href=\"http://google.se\">text</a>. This breaks every element that has an attribute value. How could this be? I was using directresize on the site but it gave me en error page about not being able to combine two arrays while one was empty or something like that so I turned directresize off. This had no impact on the quotation marks.

    I allso tried upgrading from evolution 1.0.0 to 1.0.2 but that did not help either. Everytime I change the document, with or without TinyMCE the same \ is added before the "s.

    Does this has something to do with htmlentities() or some regular expression?

    Would appreciate and hints on what is different with PHP 5.3 and 5.2 that could break the formatting so I can repair the site.
      • 26931
      • 2,314 Posts
      Hi tirithen,

      could be a problem with magic_quotes_gpc being enabled
      -> http://modxcms.com/forums/index.php?topic=40996.0
        • 30100
        • 58 Posts
        Thanks for the fast answer!

        Since this is not my server I cannot do anything about this?

        Strange that they added magic_quotes_gpc when they upgraded since it’s marked for removal...
          • 26931
          • 2,314 Posts
          not sure, maybe you can turn it off ( if mq was the cause ) by placing
          php_flag magic_quotes_gpc off

          in your .htaccess

          ...but as i said, not sure smiley
            • 30100
            • 58 Posts
            Thanks for the tip but I got Internal Server Error when I added php_flag magic_quotes_gpc off so I guess I’m out of luck. I have contacted one.com about the problem with magic_quotes_gpc so I hope they can turn it off for me.

            Agai, thanks for the tips. smiley
              • 26931
              • 2,314 Posts
              good luck smiley maybe someone else here in the forum jumps in to help/explain in the meantime as well
                • 3749
                • 24,544 Posts
                You should be able to disable magic quotes in a php.ini in the site root or programmatically in index.php if your host won’t allow php.ini (most good hosts will allow it).

                http://php.net/manual/en/security.magicquotes.disabling.php
                  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
                  • 30100
                  • 58 Posts
                  Now I’ve gotten response from one.com and they claim that they allways have had magic quotes on, strange thing is that MODx did not stop working until they made the upgrade from PHP 5.2 to 5.3, if they are right, they must have changed something else that made PHP or MODx add additional \ to all SQL INSERT querys.

                  Anyway, they won’t allow me to turn magic quotes off so I need to work around it. Could I make a plugin for the site that uses regular expressions to remove the extra \ before insertion into database or in worst case before the page is viewed.

                  Which event could this plugin run at?
                  • Right, the problem is magic_quotes are now deprecated features in 5.3 and MODx changes were made to address this. Unfortunately, at the current time, if you use 5.3 you need these settings disabled. Can you not do this in your .htaccess file?
                      • 3749
                      • 24,544 Posts
                      Your plugin should listen for OnWebPagePrerender.

                      It would look something like this:

                      <?php
                      $source = &$modx->documentOutput;
                      $source = str_replace('\"','"', $source);
                      ?>


                      or for MODx Revolution:

                      <?php
                      $output = &$modx->resource->_output;
                      $source = str_replace('\"','"', $source);
                      ?>



                        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