The latest beta version of XAMPP (1.7.5-beta 1) appears to have a bug with preg_replace. As I don't have any other PHP 5.3.5 installs running right now I don't know whether the problem is a PHP bug, a regex library bug, or a problem with the XAMP build.
I am running XAMP 1.7.5-beta 1 on Windows 7.
Below is a minimal script to produce the error. If you run this script it will produce a segmentation fault and Apache will crash.
[code]
<?php
$html = <<<END
<tr id="copy-replace-field-product_name-row" style="display: none">
<td id="copy-replace-field-product_name-label-cell" class="copy-replace-field-label-cell" valign="top" align="right">
<label>Product name</label>
</td>
<td id="copy-replace-field-product_name-widget-cell" class="copy-replace-field-widget-cell" valign="top" align="left">
<!-- BEGIN required --><span style="color: #ff0000" class="fieldRequired" title="required"> </span><!-- END required -->
<!-- BEGIN error --><div class="fieldError" style="color: #ff0000">{error}</div><!-- END error -->
{element}
(<input type="checkbox" name="-copy_replace:blank_flag[product_name]" label="Leave Blank"><label for="-copy_replace:blank_flag[product_name]">Make Blank</label>)
</td>
</tr>
END;
$html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->(\s|\S)*<!-- END required -->([ \t\n\r]*)?/i", '', $html);
echo "success";
[code]
I haven't had a chance to narrow it down too much further, but I do know the following:
1. Works fine running on PHP 5.3.2, 5.2.8, 5.2.6, and 5.1 on other setups.
2. This will work if you change the regex from
"/([ \t\n\r]*)?<!-- BEGIN required -->(\s|\S)*<!-- END required -->([ \t\n\r]*)?/i"
to
"/([ \t\n\r]*)?<!-- BEGIN required -->.*?<!-- END required -->([ \t\n\r]*)?/i"
If anyone has PHP 5.3.5 running on something other than XAMPP can you try this test and see if it fails?
-Steve