01560: MarkupExpressions do not work in PmWiki 2.7.1

Summary: MarkupExpressions do not work in PmWiki 2.7.1
Created: 2026-07-26 16:02
Status: Closed, fixed for 2.7.3
Category: Bug
Assigned:
Priority: 3
Version: PmWiki-2.7.1
OS: Debian 12

Description:
MarkupExpressions do not work in PmWiki 2.7.1
Calling PmWiki.DocumentationIndex in my TestWiki (without config.php) results in various errors in scripts/markupexpr.php

<b>Fatal error</b>:  Uncaught ArgumentCountError: substr() expects at least 2 arguments, 1 given in /mnt/www/pmwiki-2.7.1/scripts/markupexpr.php:100
Stack trace:
#0 /mnt/www/pmwiki-2.7.1/scripts/markupexpr.php(100): substr(Array)
#1 [internal function]: ME_core('PmWiki.Document...', 'substr', Array, Array, '/\x1C\x1C(\\d+P)\x1C\x1C/', ' \x1C\x1C130P\x1C\x1C 0 -5')
#2 /mnt/www/pmwiki-2.7.1/pmwiki.php(729): ReflectionFunction-&gt;invokeArgs(Array)
#3 /mnt/www/pmwiki-2.7.1/scripts/markupexpr.php(153): CallbackWithArgs('ME_core', Array)
#4 /mnt/www/pmwiki-2.7.1/scripts/markupexpr.php(76): MarkupExpression('PmWiki.Document...', '(substr \x1C\x1C130P\x1C...')
#5 [internal function]: MarkupMarkupExpression(Array)
#6 /mnt/www/pmwiki-2.7.1/pmwiki.php(3057): preg_replace_callback('/\\{(\\(\\w+\\b.*?\\...', 'MarkupMarkupExp...', '\n(:Summary PmW...')
#7 /mnt/www/pmwiki-2.7.1/pmwiki.php(3141): MarkupToHTML('PmWiki.Document...', '[=(:=]groupheader:)...', Array)
#8 /mnt/www/pmwiki-2.7.1/pmwiki.php(672): HandleBrowse('PmWiki.Document...', 'read')
#9 /mnt/www/pmwiki-2.7.1/pmwiki.php(653): HandleDispatch('PmWiki.Document...', 'browse')
#10 {main}
  thrown in <b>/mnt/www/pmwiki-2.7.1/scripts/markupexpr.php</b> on line <b>100</b><br />

Michael Engelke

Thanks, fixed, new version will be out shortly. --Petko

First of all, thank you very much for the very quick fix, but I really don't want to be a bother—though, as much as I regret to say, there's another bug in MarkupExpressions. When I access the PmWiki.ChangeLog page in my TestWiki (pmwiki-2.7.2 without config.php), I’m getting various errors from scripts/markupexpr.php again.

<b>Fatal error</b>:  Uncaught ArgumentCountError: substr() expects at least 2 arguments, 1 given in /mnt/www/pmwiki-2.7.2/scripts/markupexpr.php:100
Stack trace:
#0 /mnt/www/pmwiki-2.7.2/scripts/markupexpr.php(100): substr('...')
#1 [internal function]: ME_core('PmWiki.ChangeLo...', 'substr', Array, Array, '/\x1C\x1C(\\d+P)\x1C\x1C/', ' ...')
#2 /mnt/www/pmwiki-2.7.2/pmwiki.php(729): ReflectionFunction-&gt;invokeArgs(Array)
#3 /mnt/www/pmwiki-2.7.2/scripts/markupexpr.php(153): CallbackWithArgs('ME_core', Array)
#4 /mnt/www/pmwiki-2.7.2/scripts/markupexpr.php(76): MarkupExpression('PmWiki.ChangeLo...', '(substr ...)')
#5 [internal function]: MarkupMarkupExpression(Array)
#6 /mnt/www/pmwiki-2.7.2/pmwiki.php(3057): preg_replace_callback('/\\{(\\(\\w+\\b.*?\\...', 'MarkupMarkupExp...', '(:groupheader:)...')
#7 /mnt/www/pmwiki-2.7.2/pmwiki.php(3141): MarkupToHTML('PmWiki.ChangeLo...', '(:groupheader:)...', Array)
#8 /mnt/www/pmwiki-2.7.2/pmwiki.php(672): HandleBrowse('PmWiki.ChangeLo...', 'read')
#9 /mnt/www/pmwiki-2.7.2/pmwiki.php(653): HandleDispatch('PmWiki.ChangeLo...', 'browse')
#10 {main}
  thrown in <b>/mnt/www/pmwiki-2.7.2/scripts/markupexpr.php</b> on line <b>100</b><br />

P.S.: I’ve now gone through all the pages in the guide; it seems to only affect the ChangeLog page.

Oh, thank you again, indeed my fix was insufficient if arguments were missing. Can you test the prerelease from PmWiki:ChangeLog and report? --Petko

I can confirm that all pages from PmWiki/... and Site/... open without error in the current PmWiki pre-release of my TestWiki.
Thank you again for your very quick response. Michael Engelke

Thank you Michael for the reports and testing -- it is good that we caught it this weekend. This is a big release, many changes, let me know if you notice any other problems -- see also PmWiki:ReleaseNotes and PmWiki:Upgrades. --Petko

No problem, I'd be happy to do that. Right now I’m still cursing because I want to upgrade my website from version 2.6 to 2.7.x. It took me hours to figure out that the errors weren’t my fault, but were caused by MarkupExpressions. Now I have to dig through code that’s in some cases 15 years old to complete the migration. – If I find anything else, I’ll let you know. Michael Engelke