01461: PHP 8

Summary: PHP 8
Created: 2020-12-01 06:14
Status: InProgress
Category: PHP Compatibility
Priority: 4
Version: 2.2.135

Description: PHP 8 has made a number of breaking changes, so code that previously worked fine now needs to be rewritten.

On this page we keep track of the work done and pending to update the core codebase for PHP 8.

Note: reports should be made for the latest release or for the nightly snapshot. If you use an older version, please upgrade first.

Pending issues

Please add new reports below this line.

On my wiki with AuthUser enabled, I get the following warnings after login (subsequent pages load without displaying the warnings):

  • Warning: Undefined variable $authlist in /usr/local/var/www/Default/public_html/pmwiki/scripts/authuser.php on line 76
  • Warning: Undefined array key "htgroup" in /usr/local/var/www/Default/public_html/pmwiki/scripts/authuser.php on line 89

I was able to fix these by adding $authlist to function AuthUserId()'s globals declaration and adding a null coalescing operator to line 89:

  if ($auth['htgroup'] ??= NULL) {

Thanks for your report. Just 2 notes: $authuser is not intended to be global but passed by reference, and the core needs to work with PHP 5. For these reasons, see my fix below. --Petko May 05, 2021, at 04:57 PM

Index: scripts/authuser.php
--- scripts/authuser.php	(revision 3719)
+++ scripts/authuser.php	(working copy)
@@ -70,6 +70,7 @@

+  $authlist = array();
   if (func_num_args()==2) $authid = $id;
     foreach($AuthUserFunctions as $k => $fn) 
@@ -86,7 +87,7 @@
     $authlist[$g] = 1;
   foreach(preg_grep('/^@/', array_keys($auth)) as $g) # useless? PITS:01201
     if (in_array($authid, $auth[$g])) $authlist[$g] = 1;
-  if ($auth['htgroup']) {
+  if (@$auth['htgroup']) {
     foreach(AuthUserHtGroup($pagename, $id, $pw, $auth['htgroup']) as $g)
       $authlist["@$g"] = 1;

Closed issues

If $LinkWikiWords = 1; is set I get warnings like the following on pages which contains CamelCase words:

  Warning: Undefined array key "EximCfgMain" in /home/www/pmwiki/scripts/wikiwords.php on line 66

Thanks, this was fixed for the next version (due in a few days). --Petko April 13, 2021, at 03:25 PM

Click to toggle past issues

Under php 8.0 pmwiki enters in infinite loop. It's because of change of comparing rules in php 8.0.

In pmwiki.php (line 1580) instead of

  if ($depth == 0) $depth = strlen($depth);
  if ($icol == 0) $icol = strlen($icol);

must be

  if (!is_numeric($depth)) $depth = strlen($depth);
  if (!is_numeric($icol)) $icol = strlen($icol);

Yury Finkel? December 01, 2020, at 06:14 AM

Made this change manually on my system as php 8 just dropped on Arch linux. pmwiki works with these changes...

...thanks Yury.

...Roy H

well - the pages render and load (which they didn't before) - but editing still doesn't work. Uncaught TypeError: Unsupported operand types int & arry line 2182 of pmwiki.php. Probably several more things to fix for the new version of PHP.


I'll publish the next version that fixes these and a few other compatibilities (Forms) in the next few days, this week or early next week. --Petko January 28, 2021, at 08:30 PM

What a blessing to have you.

MFWolff January 29, 2021, at 07:08 AM

All the above, and a few I found myself, were fixed. If there are any others, please report them in the "Pending issues" section. --Petko January 31, 2021, at 05:19 PM