rainerborene/youtube_videos — Issue #4: Field throws an error when saving in PHP 5.2.17
Author: kanduvisla
Created: 2011-10-13 13:49:48+00:00
State: open

When saving the entry in PHP 5.2.17. The following error occurs:

preg_match() [function.preg-match]: Compilation failed: unrecognized character after (?< at offset 5

An error occurred in [...]/public_html/extensions/youtube_videos/fields/field.youtube_video.php around line 313

Perhaps changing to an alternate regular expression? I changed the code to:

$urlStr = $url['scheme'].'://'.$url['host'].$url['path'].'?'.$url['query'];
if (is_array($url) && preg_match('/youtube\.com/i', $url['host'])){
if (preg_match('%(?:youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $urlStr, $match)) {
return $match[1];
}
}

Fixed the problem. So I think there is a parsing difference in regular expressions accross PHP versions.