Error “preg_match_all” with WordPress SEO by Yoast plugin [closed]

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("https://wordpress.stackexchange.com/".$job["keyword"]."/msIU", $body, $res);

or whatever it may have to:

$keywordCount = preg_match_all("https://wordpress.stackexchange.com/".$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("https://wordpress.stackexchange.com/".preg_quote($job["keyword"], "https://wordpress.stackexchange.com/")."/msIU", $body, $res);