Error “preg_match_all” with WordPress SEO by Yoast plugin

I hope someone could realy help me…

I get this error message :

Read More
"error Warning: preg_match_all() [function.preg-match-all]: Unknown modifier 'I' in /home/sulistyo/public_html/wp-content/plugins/wordpress-seo/admin/linkdex/linkdex.php on line 476" 

when I enter/write a focus keyword on wordpress seo meta box.

I don’t know what to do to solve the error. I hope someone or the developer of the plugin (Joost de Valk) could help me with this error – thanks.

I really need your help…

Related posts

Leave a Reply

2 comments

  1. I browsed through all the versions available here http://plugins.trac.wordpress.org/browser/wordpress-seo/tags/ and nowhere is there any “I” modifier. The “I” modifier is obviously invalid, thus the error. Updating the plugin will most certainly solve the issue. Or at least, if updates are not possible, edit line 476 of /wp-content/plugins/wordpress-seo/admin/linkdex/linkdex.php and turn

    $keywordCount = preg_match_all("/".$job["keyword"]."/msIU", $body, $res);
    

    or whatever it may have to:

    $keywordCount = preg_match_all("/".$job["keyword"]."/msiU", $body, $res);
    

    An update:

    After you mentioned ‘P’ being an invalid modifier, it suddenly struck me that the keyword is not escaped and that you may be using a backslash / inside of there, breaking the regular expression.

    While you’re waiting for an update you can rewrite the line to:

    http://plugins.trac.wordpress.org/browser/wordpress-seo/trunk/admin/linkdex/linkdex.php#L476

    $keywordCount = preg_match_all("#".$job["keyword"]."#msIU", $body, $res);
    

    Note how I changed the / to # delimiters, you’re probably not going to use those, so your expression will not fail.

    http://php.net/manual/en/regexp.reference.delimiters.php

    Alternatively you can use preg_quote like so:

    $keywordCount = preg_match_all("/".preg_quote($job["keyword"], '/')."/msIU", $body, $res);
    
  2. Thanks Soulseekah for your answer. i’ve checked on my /wp-content/plugins/wordpress-seo/admin/linkdex/linkdex.php and what is written there is just exactly the same as you mention/write above, i have : $keywordCount = preg_match_all(“/”.$job[“keyword”].”/msiU”, $body, $res); and i don’t know what and where the problem is. I try to copy and replace and still nothing happen, the second time i try to re-save my fokus keyword on my post the error was still occur but with different message : “error Warning: preg_match_all() [function.preg-match-all]: Unknown modifier ‘p’ in /home/sulistyo/public_html/wp-content/plugins/wordpress-seo/admin/linkdex/linkdex.php on line 476”. For information : this error only occur on one of post only, while the plugin seem to be work well on my others posts. btw, thanks for your answer.. , thank very much…