Support » Plugin: Crayon Syntax Highlighter » Failed to open stream error when creating new post

  • WARNING: wp-content/plugins/crayon-syntax-highlighter/util/crayon_util.class.php:81 - file_get_contents(default/default.txt): failed to open stream: No such file or directory
    get_default_post_to_edit, wp_insert_post, apply_filters('wp_insert_post_data'), WP_Hook->apply_filters, CrayonWP::filter_post_data, CrayonTagEditorWP::init_settings, CrayonLangs->extensions_inverted, CrayonLangs->extensions, CrayonLangs->fetch, CrayonResourceCollection->load, CrayonLangs->load_process, CrayonResourceCollection->load_process, CrayonLangs->add_default, CrayonParser::parse, CrayonUtil::lines, CrayonUtil::file, file_get_contents

    I switched my site to PHP 7.1 and have noticed that Crayon is one of the plugins that has problems. It’s ironic that my code highlighter has code issues, and I’d really rather be able to keep using the plugin than find something else.

    In addition to the above, I get an endless stream of PHP notices in my php_errorlog file:

    [21-Dec-2016 13:44:15 UTC] PHP Notice: A non well formed numeric value encountered in /home/rhymesw6/public_html/ on line 118

    I haven’t a clue what a non-well-formed numeric value is, but clearly PHP 7 is unhappy with it. (I didn’t check to see whether I got any of these notices in PHP 5.6, sorry.)

    Any light you can shed on this problem would be helpful.

Viewing 4 replies - 1 through 4 (of 4 total)
  • For the first warning, check that /home/rhymesw6/public_html/ exists and has read permission. Though it could be because it’s using a relative path…

    As for the second, the plug-in is using a string as numeric value. This line:

    $toolbar_height = $font_size * 1.5 . 'px !important;';

    should be

    $toolbar_height = $_font_size * 1.5 . 'px !important;';

    By some miracle, the code as it is still works (only in PHP), but the latter is what it should, and will get rid of the notice. I don’t think you would have got this notice in PHP 5.6.

    There are numerous other incidences where the plug-in is doing something similar. In any case where $font_size is used as a numerical value it should really be $_font_size.

    Thanks, Stephen. I ended up switching plugins to avoid the error, but maybe I’ll get a chance to try out your fix.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Failed to open stream error when creating new post’ is closed to new replies.