Comment 3 for bug 692898

Revision history for this message
rg1024 (rg1024) wrote :

the code:
The problem is widget.php line 861.
$numMatches = preg_match_all( '/\(\#\(inherent\:(.*)\)\#\)/', $widget, $matches);

must be replaced by:
$numMatches = preg_match_all( '/\(\#\(inherent\:(.*)\)\#\)/Us', $widget, $matches);

the explanation.
the original regular expression catch two inherit as one only because the bigger match the expression too. You must change greedy of regular expression /U, ( and add multiline /s for more robust code).

example:
$widget='(#(inherit:66|select count(id) from apps_photo_archive
where "((username))" = published_by)#)(#(inherit:82|select * from apps_photo_archive where "((username))" =published_by)#)';

echo preg_match_all( '/\(\#\(inherit\:(.*)\)\#\)/sU', $widget,$matches); // return 2
echo preg_match_all( '/\(\#\(inherit\:(.*)\)\#\)/s', $widget,$matches); // return 1
echo preg_match_all( '/\(\#\(inherit\:(.*)\)\#\)/', $widget,$matches); //return 0 (the is a new line character..)