Support » Plugin: Crayon Syntax Highlighter » Fatal error when usen PHP7.3+

  • Hi

    The plugin (version 2.8.4) is causing a fatal error with PHP7.3 and PHP7.4:

    PHP Fatal error: Uncaught Error: Call to a member function id() on array in /usr/home/******.com/web/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php:36

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    TL;DR
    Edit crayon_langs.class.php, search for :
    return preg_replace(‘/[^\w-+#]/msi’, ”, $id);
    (should be around line 340)
    Replace it with :
    return preg_replace(‘/[^\w\-+#]/msi’, ”, $id);

    Explanation :
    PHP 7.3 handles regular expressions more strictly than older PHP version, due to the upgrade to PCRE2 library.
    In a character class expression (between [] in the regexp), – is a special char, used for writing chars ranges, so it must be escaped.
    PCRE1 was more tolerant, and considered – to be the – character when used in a context where the preceding data cannot be a start of range (\w is itself a group of chars, all alphanumeric chars plus underscore, so it cannot be a start of range).

    See : https://stackoverflow.com/questions/24764212/preg-match-compilation-failed-invalid-range-in-character-class-at-offset

    axew3

    (@axewww)

    These are not the only things to change.
    I need it for my test site, so i resumed this plugin to work on Php 7.4>, Gutenberg and last Wp:
    https://www.axew3.com/w3/forums/viewtopic.php?f=10&t=1555

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.