Ostatnio po zainstalowaniu php 5.2 moj skrypt zaczał pracować niepoprawnie. Z początku zastanawiałem się dlaczego. Teraz wiem, że winowajcą jest wyrażenie regularne, w którym składnia inaczej działa na najnowszej wersji.

W changelgu znalazłem
Cytat
3. A nasty bug was discovered in the handling of recursive patterns, that is,
items such as (?R) or (?1), when the recursion could match a number of
alternatives. If it matched one of the alternatives, but subsequently,
outside the recursion, there was a failure, the code tried to back up into
the recursion. However, because of the way PCRE is implemented, this is not
possible, and the result was an incorrect result from the match.

In order to prevent this happening, the specification of recursion has
been changed so that all such subpatterns are automatically treated as
atomic groups. Thus, for example, (?R) is treated as if it were (?>(?R)).


Próbowałem przerobic wyrażenie na kilkanaście sposobów i wyszło że chyba jestem za głupi ;].
Czy ktoś jest w stanie poprawić ten kod?
  1. <?php
  2. // $AllowedTags to zmienna przechowująca tagi
  3. $AllowedTags = 'php|html|b|i|u|color|code|quote';
  4.  
  5. $code = preg_replace_callback('#[('.$AllowedTags.')(s=?.+?|=.+?|)] ( (?: (?>(?R)) | (?:.*?(?![/1])) )* )[/1]#mx',Array($this, 'parseTag'), $code);

Wszystko jest ok do momentu gdy użyję błędnego bbCode tj. np.
  1. <?php
  2. $code = 'dfgdfg fgdfgdf gdfsdfsdf';
  3. // lub
  4. $code = 'sfsfsf[i]sdfsdf';
  5. ?>

Wcześniej problem nie występował, kod po prostu sie nie parsował, teraz zamiast tej samej wartości funkcja preg_replace_callback() zwraca mi wartość pustą przez co cały bbCode znika.
Jakieś pomysły?