• When I tried to install a some theme to a host with limited resources, the site did not work. Instead of the normal operation there was a message about a fatal error – out of memory via file wp-includes / compat.php on line 30.
    Trying to solve the problem led to the long download error (more 30 second) in same place.

    Line 30:

    preg_match_all (‘/./us’, $ str, $ match);

    function belongs _mb_substr, which invoke a function of mb_substr, located in the same file, line 17.

    In comments to function _mb_substr written:
    // The solution below, works only for utf-8, so in case of a different
    // Charset, just use built-in substr

    For solve the problems I emulate function _mb_substr for other encodings.

    Replacing line 18
    return _mb_substr ($ str, $ start, $ length, $ encoding);
    on the line
    return is_null ($ length)? substr ($ str, $ start): substr ($ str, $ start, $ length);

    As a result, the site is up and started working.

    Actually the question:
    This is the core file of WordPress, and it is included in version 4.0. Errors occur for more than 2 years. Maybe we should correct the mistake? or explain what the function does and how to get around this bottleneck in the subject, without making changes to the kernel.

Viewing 7 replies - 1 through 7 (of 7 total)
  • What is the theme you installed? Does the error occur with any other theme you tried? It may just be an issue with the theme (and how it handles that substring call) and not an actual issue with WordPress.

    Thread Starter Oleksandr Budnytskyy

    (@oleksandr-budnytskyy)

    You’re right, WordPress reacts on specific themes, and this in particular. Current theme is not written by me, I involved to installation theme on hosting only.
    But this theme has not call of function mb_substr. So, I think, this function is called by another kernel functions (I’ll try to dig later).

    This theme was successfully start on server apache under windows, under wordpress 3.9.2 and wordpress 4.0 Trouble apear at hosting by *nix.

    I think, it may be an issue with combination: theme, wordpress and hosting/servers resource (may be version apache, its modules or php).

    My interest – to understand the cause and not to step on a rake in the future.

    Thread Starter Oleksandr Budnytskyy

    (@oleksandr-budnytskyy)

    function mb_substr is different from function substr by the presence of utf8-string manipulation only. Main part is

    preg_match_all( ‘/./us’, $str, $match );

    Modificator /u have to filter illegal utf-8 characters.

    It looks strange declaration of this function

    17 function mb_substr( $str, $start, $length=null, $encoding=null )
    22 function _mb_substr( $str, $start, $length=null, $encoding=null )

    $encoding parameter is not used in the function _mb_substr

    However, this function is called once the core files of WordPress:

    – /wp-includes/post.php: function get_sample_permalink_html (string 1209)
    – /wp-includes/formating.php: function wp-html-excerpt (3640)
    – /wp-includes/pomo/streams.php: internal class function substr with parameter $encoding=”ascii” (64)
    – /wp-includes/class_phpmailer: function base64EncodeWrapMD with parameter $encoding=”$this->Charset (2304)
    – /wp-includes/class-json.php: function substr8 with parameter $encoding=”8bit” (902)

    None of these function is not called by current theme direct.

    Oleksandr, hi!
    I have the same issue while trying to install commercial theme on MP4.1 – stop in wp-includes / compat.php on line 30. Theme itself and rest of WP functions are firking fine. I see error whet I’m trying to save Theme Options.

    Error occurred only on server, running under FreeBSD – Mac OS, UBUNTU, Debian – working fine. I have a production server running under FreeBSD 10.1, and I won’t migrate to Linux.

    Did you solve that error in your case? Any clue?

    Thanx!

    Thread Starter Oleksandr Budnytskyy

    (@oleksandr-budnytskyy)

    Yes, I haven’t been able to install extension to hosting, so I change string 18 in file compat.php

    return _mb_substr($str, $start, $length, $encoding);

    to

    return substr($str, $start, $length);

    It make positive effect and theme work. But due limited resources it was very slow.
    Because of this, the customer replaced the bulky theme for the simpler.

    Thread Starter Oleksandr Budnytskyy

    (@oleksandr-budnytskyy)

    My solution is temporary, because it lost after upgrading WP. This is reason, which I do not share my vaariant of solution.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘error in compat.php on line 30’ is closed to new replies.