Kym Gilham
Kym Gilham

Reputation: 133

PHP preg_replace error wordpress

I have the following wordpress code

function shortcode_parse_atts($text) {
    $atts = array();
    $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
    $text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text);
    if ( preg_match_all($pattern, $text, $match, PREG_SET_ORDER) ) {
        foreach ($match as $m) {
            if (!empty($m[1]))
                $atts[strtolower($m[1])] = stripcslashes($m[2]);
            elseif (!empty($m[3]))
                $atts[strtolower($m[3])] = stripcslashes($m[4]);
            elseif (!empty($m[5]))
                $atts[strtolower($m[5])] = stripcslashes($m[6]);
            elseif (isset($m[7]) and strlen($m[7]))
                $atts[] = stripcslashes($m[7]);
            elseif (isset($m[8]))
                $atts[] = stripcslashes($m[8]);
        }
    } else {
        $atts = ltrim($text);
    }
    return $atts;
}

After I execute the function with a path, I get this error:

Warning: preg_replace() [function.preg-replace]: Compilation failed: unknown option bit(s) set at offset -1 in /PATH/wp-includes/shortcodes.php on line 258

Line 258 marked here

$text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text); //<--- LINE 258

can anyone provide any help with this?

would be appreciated

Cant downgrade php version...

Upvotes: 0

Views: 1033

Answers (1)

Matheus Loureiro
Matheus Loureiro

Reputation: 101

That happens because your PCRE is outdated. After updating PHP to 5.3 version, you need to manually update the PCRE of your server.

Run the following code in your SSH:

pcretest -C

It will show you the version your running of it. The last version is 8.32.

Here is a relation of the PCRE version you should use with each PHP version: http://php.net/manual/en/pcre.installation.php

Upvotes: 1

Related Questions