We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36426
    • 197 Posts
    Hi I unfortunately had to upgrade my server but my Evolution 1.1 site is now showing Jot errors:
    ErrorType[num] 	WARNING[2]
    File 	/home/public_html/assets/snippets/jot/includes/phx.parser.class.inc.php
    Line 	254
    Source 	$output = preg_replace("~(\b\w+\b)~e","wordwrap('\\1',\$wrapat,' ',1)",$output);
    Current Snippet 	Jot
    

    Error : preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
    


    Any easy way to fix this?

    This question has been answered by multiple community members. See the first response.

      Yorkshire UK based hosting provider: https://www.simulant.uk
    • discuss.answer
      • 38850
      • 110 Posts
      You'll have to fix the code yourself!
      Everything you need is there.
      Change `preg_replace` to `preg_replace_callback`.
      Then remove the `e` from the regex.
      Then move the "wordwrap" portion into an anonymous function and `return` the text.

      Basically it needs to look something like this:

      ```
      $output = preg_replace_callback("~(\b\w+\b)~", function($matches) { return wordwrap($matches[0], $wrapat, ' ', 1) }, $output);
      ```

      The middle is just a callback function, whatever you `return` will be set to $output. There is no eval, so that's ok, it's just looking for the first match which will be `$matches[0]` in the returned matches array.

      I can't test this but it should be good, or close!
      • discuss.answer
        • 13226
        • 953 Posts
        May I suggest you post this on GitHub, the EVO DEV team look there first, they are hardly on the forum
          • 36426
          • 197 Posts
          Hi thanks Vigilante,

          I updated the line on 254 to your suggestion:

          $output = preg_replace_callback("~(\b\w+\b)~", function($matches) { return wordwrap($matches[0], $wrapat, ' ', 1); }, $output);


          which got me a bit further. I also posted on Github for extra help there, but now I'm faced with more errors:

          DocumentParser->executeParser()
          index.php on line 145
          DocumentParser->prepareResponse()
          manager/includes/document.parser.class.inc.php on line 1803
          DocumentParser->outputContent()
          manager/includes/document.parser.class.inc.php on line 1906
          DocumentParser->parseDocumentSource(string $var1)
          manager/includes/document.parser.class.inc.php on line 634
          DocumentParser->evalSnippets(string $var1)
          manager/includes/document.parser.class.inc.php on line 1655
          DocumentParser->_get_snip_result(string $var1)
          manager/includes/document.parser.class.inc.php on line 1172
          DocumentParser->evalSnippet(string $var1, array $var2)
          manager/includes/document.parser.class.inc.php on line 1195
          eval()
          manager/includes/document.parser.class.inc.php on line 1120
          CJot->Run()
          manager/includes/document.parser.class.inc.php(1120) : eval()'d code on line 60
          CJot->getOutputDefault()
          assets/snippets/jot/jot.class.inc.php on line 305
          CJot->getOutputComments()
          assets/snippets/jot/jot.class.inc.php on line 357
          CChunkie->Render()
          assets/snippets/jot/jot.class.inc.php on line 444
          PHxParser->Parse(string $var1)
          assets/snippets/jot/includes/chunkie.class.inc.php on line 57
          PHxParser->ParseValues(string $var1)
          assets/snippets/jot/includes/phx.parser.class.inc.php on line 60
          PHxParser->Filter(string $var1, ':wordwrap:esc:nl2br')
          assets/snippets/jot/includes/phx.parser.class.inc.php on line 165
          preg_replace_callback('~(\b\w+\b)~', Closure $var2, string $var3)
          assets/snippets/jot/includes/phx.parser.class.inc.php on line 254
          PHxParser->{closure}(array $var1)
          on line
          wordwrap('We', NULL, ' ', 1)
          assets/snippets/jot/includes/phx.parser.class.inc.php on line 254
          
          [ed. note: jonahnaylor last edited this post 7 years, 7 months ago.]
            Yorkshire UK based hosting provider: https://www.simulant.uk
          • discuss.answer
            • 36426
            • 197 Posts
            The guys on Github are pretty awesome too!! Thanks to Vigilante & Deesen we have a fix:

            https://github.com/modxcms/evolution/issues/716
              Yorkshire UK based hosting provider: https://www.simulant.uk