Piwigo / AMenuManager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Warning: A non-numeric value encountered in...template.class.php on line 1791

ceinmart opened this issue · comments

When I activated the plugin in my site , got lot of errors :

Warning: A non-numeric value encountered in /home/imartins/public_html/fotos/include/template.class.php on line 1791
Maybe some incompatibility with PHP 7 ?

Piwigo 2.9.1
Operating system: Linux
PHP: 7.1.9 (Show info) [2017-09-25 21:37:36]
MySQL: 5.6.36-cll-lve [2017-09-25 21:37:36]
Graphics Library: ImageMagick 6.9.4-10

I'm now seeing the same problem after I upgraded to Ubuntu 17.10, which included PHP 7.1.

Piwigo 2.9.2
Operating system: Linux
PHP: 7.1.8-1ubuntu1 (Show info) [2017-10-24 21:59:12]
MySQL: 5.7.19-0ubuntu1 [2017-10-24 21:59:12]
Graphics Library: External ImageMagick 6.9.7-4

Line in template.class.php causing the warning seems to be this one:

$ret = $s1->load_mode - $s2->load_mode;

  /**
   * Callback for scripts sorter.
   */
  private static function cmp_by_mode_and_order($s1, $s2)
  {
    $ret = $s1->load_mode - $s2->load_mode;
    if ($ret) return $ret;

    $ret = $s1->extra['order'] - $s2->extra['order'];
    if ($ret) return $ret;

    if ($s1->extra['order']==0 and ($s1->is_remote() xor $s2->is_remote()) )
    {
      return $s1->is_remote() ? -1 : 1;
    }
    return strcmp($s1->id,$s2->id);
  }
}

I had not seen this bug with PHP 7. While testing AMM with PHP 8 (and Piwigo 14), I stumbled upon a problem with the load parameter. The GrumPluginClasses (used by plugin AMM) plugin "registers" the javascript files to load this way:

$template->scriptLoader->add($id, 'header', $require, $file, 0);

But here 'header' is not correct. scriptLoader->add is expecting an int, not a string. To add the script to the header, we must set the load parameter to 0. With PHP 8, the bug remains silent and the script is just not loaded, which causes many troubles afterwards.

See correction on Piwigo/GrumPluginClasses@d0f8292