Pmwiki: preg_replace error

32 views
Skip to first unread message

MassimoA

unread,
Apr 30, 2020, 5:38:19 AM4/30/20
to Simple Groupware
Hello,
I have a new error that does not allow me to view the contents of the Wiki folder:

Php 8192: 30/04/20 10:59:22 am preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead /var/www/html/sgs/bin/lib/pmwiki/pmwiki.php 1502

Now, the line 1502 is inside the function MarkupToHTML:
...
[line 1486] function MarkupToHTML($pagename, $text, $opt = NULL) {
# convert wiki markup text to HTML output
global $MarkupRules, $MarkupFrame, $MarkupFrameBase, $WikiWordCount,
$K0, $K1, $RedoMarkupLine;
StopWatch('MarkupToHTML begin');
array_unshift($MarkupFrame, array_merge($MarkupFrameBase, (array)$opt));
$MarkupFrame[0]['wwcount'] = $WikiWordCount;
foreach((array)$text as $l)
$lines[] = $MarkupFrame[0]['escape'] ? PVSE($l) : $l;
$lines[] = '(:closeall:)';
$out = '';
while (count($lines)>0) {
$x = array_shift($lines);
$RedoMarkupLine=0;
$markrules = BuildMarkupRules();
foreach($markrules as $p=>$r) {
[line 1502] if ($p{0} == '/') $x=preg_replace($p,$r,$x);
#
# if ($p{0} == '/') $x=preg_replace_callback(
# $p,
# function($m) {return $r;},
# $x);
elseif (strstr($x,$p)!==false) $x=eval($r);
if (isset($php_errormsg))
{ echo "ERROR: pat=$p $php_errormsg"; unset($php_errormsg); }
if ($RedoMarkupLine) { $lines=array_merge((array)$x,$lines); continue 2; }
}
if ($x>'') $out .= "$x\n";
}
foreach((array)(@$MarkupFrame[0]['posteval']) as $v) eval($v);
array_shift($MarkupFrame);
StopWatch('MarkupToHTML end');
return $out;
}
...

I tried to modified the line 1502 with a new block (lines 1503->1507), ma do not work.

Any suggestions?

Grazie
Massimo

Patrick Pliessnig

unread,
May 1, 2020, 3:55:30 AM5/1/20
to Simple Groupware
Hi Massimo

Please note that such errors appear with unsupported versions of PHP. The highest version supported is PHP 5.3.29 as much as I know. Having said that, my suggestion is to try this:

In your modification you replaced the variable $r in preg_replace($p,$r,$x) with the anonymous function function($m) {return $r;}.

This anonymous function uses $r which was declared in the parent scope foreach{}.

Therefore you probably need to import $r with the use statement. Hence try this function($m) use($r) {return $r;}

Buona Salute
Patrick


PS2: I wonder how many installations need to use PHP versions above 5.3.29

Massimo Arnaudo

unread,
May 1, 2020, 11:13:44 AM5/1/20
to simple-g...@googlegroups.com
Ciao Patrick!
I modified the block as you suggested (I also found documentation based on your suggestions), but the problem remains:

     #        if ($p{0} == '/') $x=preg_replace($p,$r,$x);                                                              
        if ($p{0} == '/') $x=preg_replace_callback(                                                                      
            $p,                                                                                                          
            function($m) use($r) {return $r;},                                                                            
            $x);

I have verified, my php is:
php -v
PHP 5.6.40 (cli) (built: Oct 31 2019 20:35:16)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

So, to resolve all this boring error you think it is better to return to a previous version?

Buona festa del 1 Maggio!

--
You received this message because you are subscribed to the Google Groups "Simple Groupware" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-groupwa...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/simple-groupware/6d1c08e8-0114-4756-85e8-97d3fb0233ba%40googlegroups.com.

Patrick Pliessnig

unread,
May 2, 2020, 2:38:20 AM5/2/20
to Simple Groupware
Buon Giorno Massimo

So probably the /e modifier is in your $p string.

Next try suppressing the error reporting. Either in the php.ini file or directly in the program code. See [1] below.

The e/modifier is one of the things that started to be deprecated after php version 5.3.x. So this particular error should not show up with php 5.3.x.

The newer a php version is the more you will have errors. Stick with php 5.3.29.

The other strategy I could imagine is migrating SGS to higher levels of php as Vlad suggested some time ago. This might ensure the longer term operation of SGS. Is anyone a fan of such a strategy?


[1]



On Thursday, 30 April 2020 11:38:19 UTC+2, MassimoA wrote:

Massimo Arnaudo

unread,
May 2, 2020, 6:57:59 AM5/2/20
to simple-g...@googlegroups.com
Buongiorno Patrick,
first of all thank you for your suggestions!
The solution of placing the @ symbol before has effectively solved the problem.
As far as SGS upgarde to a recent version of PHP is concerned, it frightens me as I am not a programmer and I am not able, at this moment, to devote time even just to solve trivial problems (if not with the help of others); I hope that this summer, with all the problems that people's mobility will reserve, I will be able to 'play' at the computer wizard, or more simply a low-level workforce to whom they have indicated what to do.
If you think it can be done, and not try as Master Yoda said, we can certainly talk about it.

Thanks again!
Massimo

--
You received this message because you are subscribed to the Google Groups "Simple Groupware" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-groupwa...@googlegroups.com.

Patrick Pliessnig

unread,
May 3, 2020, 3:11:24 AM5/3/20
to Simple Groupware
Hi Massimo

As Master Yoda would say, we should certainly talk about it. It is not really a big deal but needs some work do be done and you would be certainly able to assist in this process.

The question is more, is it worth the effort and what exactly should be the goal? Sooner or later an upgrade will be mandatory. But when? And will there be interest in this effort? Who is still using SGS that could be interested?

Not to forget that sooner or later some modules need to be updated - if used - like eg GDrive, Funambol, etc.

Maybe we should invite people to show their interest and see what happens.

Cheers
Patrick

On Thursday, 30 April 2020 11:38:19 UTC+2, MassimoA wrote:

Massimo Arnaudo

unread,
May 3, 2020, 11:11:20 AM5/3/20
to simple-g...@googlegroups.com
Hi Patrick,
you're right, you need to understand if the effort required to maintain and / or develop the modules is supported by a large audience or if it is reserved for a hobbyist activity of some passionate survivor.
We can create a form on Google to understand how many users there can be, how they use it and what they would like to improve.
It could be interesting, although I have some doubts about the number of answers, having taken note of the vitality of this group ...

Massimo

--
You received this message because you are subscribed to the Google Groups "Simple Groupware" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-groupwa...@googlegroups.com.

Volker Löwer

unread,
May 3, 2020, 11:52:57 AM5/3/20
to Simple Groupware
Hi Patrick, Massimo,

good to hear you are doing well and still working on using SG.

I just wanted to let you know we are still using it productively as our general administration tool (behind a vpn).
And it is now more worthy than ever, as we are forced doing coordinated a bunch of remote work during physical distancing times.

BTW, hope you are doing fine and ll the best. And thanks for all the supply during the last years and let us know how you want to proceed in developing or patching.

Cheers, Volker

Patrick Pliessnig

unread,
Sep 15, 2020, 12:58:11 PM9/15/20
to Simple Groupware
Hi

I managed to run SGS with the latest version of PHP (7.4).

So you should be able to run it on the newest releases of Debian and Ubuntu and probably other OS. I only test it with MySQL V5.

However, there are currently 3 parts that still need rework:

1) the CMS module is not usable at the moment. It is based on PMWiki which offers an actualized version. This version needs to be integrated with SGS (work in progress).
2) the browser.php is usable but ugly. This also needs upgrades
3) the installer.php needs to be adapted to the new situation.

Also, I only did superficial testing. Not structured testing. I expect some nags to popup in the future.

What's more:
The code is a big ball of mud and really hard to maintain and to extend. Luckily with the latest PHP techniques for structuring code, there is an opportunity to slowly add good structure. I tested some ideas on this directly in the code. They seem to work fine. In my opinion restructuring should really be done before extending. For the Italians: it's like turning a plate of Spaghetti into a plate of Lasagne. With the Lasagne you can then easily add layers ;-)

In short, if you are in a hurry and don't need the CMS module, you can already use it if you want or you wait till the first round of upgrading is finished. It seems that SGS will live longer.

Cheers
Patrick

Massimo Arnaudo

unread,
Sep 16, 2020, 9:19:20 AM9/16/20
to simple-g...@googlegroups.com
Hi Patrick!
sincere congratulations!

When you can give us the details on how to upgrade, I will be happy to have a nice plate of lasagna ... al Pesto!
https://www.google.com/url?sa=i&url=https%3A%2F%2Fcucina.fidelityhouse.eu%2Fprimi-piatti%2Flasagne-al-pesto-184650.html&psig=AOvVaw0LXBN-AoOZ-ikkGtjC5bGv&ust9673=1700&ust=16003 images & cd = vfe & ved = 0CAIQjRxqFwoTCOD7t8jh7esCFQAAAAAdAAAAABAJ

😉

Massimo

--
You received this message because you are subscribed to the Google Groups "Simple Groupware" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-groupwa...@googlegroups.com.

Patrick Pliessnig

unread,
Sep 17, 2020, 2:31:24 AM9/17/20
to Simple Groupware
Hmm...

Your initial preg_replace error appeared exaclty in the CMS module which is based on PMWiki and which still doesn't work as expected. I guess you won't be happy with the current state of work.

I think, next I will work on the installer. Then I can give the details on how to upgrade for those that do not need the CMS module.

Grazie per le ricette. I diversi piatti sembrano deliziosi!

Patrick
Reply all
Reply to author
Forward
0 new messages