[pmwiki-users] preg_replace (RFC)
Hans Bracker
design at softflow.co.uk
Sat Dec 6 07:47:53 CST 2014
Hello Patrick,
Friday, December 5, 2014, 6:05:51 PM, you wrote:
> For example, perhaps something like the following in PmWiki's Markup()
> function (this is completely untested!):
> function Markup($id, $when, $pat=NULL, $rep=NULL) {
> global $MarkupTable, $EnableMarkupDiag;
> if ($EnableMarkupDiag && preg_match('!/[^/]*e[^/]*$!', $pat)) {
> var_dump(debug_backtrace());
> }
> # ...
> So, when a recipe calls Markup() with a pattern containing an 'e'
> modifier after the last slash, it produces a backtrace showing the
> file and line that called Markup(). I'm sure the output can be
> vastly improved beyond doing a simple var_dump, but I'll leave
> that to others to work out. :)
Something like this gives an easy readable output, when
$EnableMarkupDiag = 1;
in config. These error messages appear ahead of the PHP error messages,
which can be numerous:
function Markup($id, $when, $pat=NULL, $rep=NULL) {
global $MarkupTable, $EnableMarkupDiag;
if ($EnableMarkupDiag && preg_match('!/[^/]*e[^/]*$!', $pat)) {
$er = debug_backtrace();
echo "<b>ERROR:</b> markup definition with regex /e modifier ";
echo "in <b>".$er[0]['file']."</b> on line <b>".$er[0]['line']."</b> pattern=<b>".$er[0]['args'][2]."</b><br/>";
}
.................
Best regards,
Hans
mailto:design at softflow.co.uk
www.softflow.co.uk
More information about the pmwiki-users
mailing list