Fixed Template modification does not report anything if preg_match_all fails

Affected version


Well-known member
In file src\XF\Repository\TemplateModification.php at line 92
                        $status[$id] = preg_match_all($modification['find'], $template, $null);
Will set the status for template modification to false if \preg_match_all fails, as it should, but if it fails with the condition \preg_last_error() !== \PREG_NO_ERROR then no status is shown in the template modification log AND will cause the page to render nothing.

Fix would be to add this after src\XF\Repository\TemplateModification.php:92
                        if ($status[$id] === false && \preg_last_error() !== \PREG_NO_ERROR) 
                            $status[$id] = 'error_invalid_regex';

Result would be something like this:
Last edited by a moderator:

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.1.8).

Change log:
Check preg_last_error() when processing template modifications
There may be a delay before changes are rolled out to the XenForo Community.