Skip to content

Commit b2cfc38

Browse files
committed
Workaround for PHP 7.1.2 windows bug that caused segfault when removing related recfords due to an innocuous preg_replace call.
1 parent 4817dd9 commit b2cfc38

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/HTML/QuickForm/Renderer/Default.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,20 @@ function _prepareTemplate($name, $label, $required, $error)
246246
$html = str_replace('<!-- BEGIN required -->', '', $html);
247247
$html = str_replace('<!-- END required -->', '', $html);
248248
} else {
249-
$html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->(\s|\S)*<!-- END required -->([ \t\n\r]*)?/i", '', $html);
249+
$parts = explode('<!-- BEGIN required -->', $html);
250+
if (count($parts) > 1) {
251+
$parts2 = explode('<!-- END required -->', $parts[1]);
252+
if (count($parts2) > 1) {
253+
array_shift($parts2);
254+
$parts[1] = implode(' ', $parts2);
255+
}
256+
$html = implode(' ', $parts);
257+
}
258+
259+
// Had to remove this perfectly good preg_replace call because PHP 7.1.2 on windows
260+
// seemed to crash (hard crash - not fatal error - like segfault crash), on this preg
261+
// replace. Replaced with the explode/implode stuff above
262+
//$html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->(\s|\S)*<!-- END required -->([ \t\n\r]*)?/i", '', $html);
250263
}
251264
if (isset($error)) {
252265
$html = str_replace('{error}', $error, $html);

0 commit comments

Comments
 (0)