Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ceinmart opened this issue Sep 26, 2017 · 2 comments

Comments

@ceinmart
Copy link

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

@jradwan
Copy link

jradwan commented Oct 25, 2017

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);
  }
}

@plegall
Copy link
Member

plegall commented Dec 4, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants