PHP warnings and error in due of PHP 7.1.12 update

PHP warnings and error in due of PHP 7.1.12 update

by Adrian Perez Rodriguez -
Number of replies: 7

Hello @everybody

We're getting actually multiple failures running our actual moodle platform. 

  • CentOS 7 (3.10.0-693.5.2.el7.x86_64)
  • PHP 7.1.12 (cli) (built: Nov 28 2017 19:02:01) ( NTS )
    • Copyright (c) 1997-2017 The PHP Group
    • Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.12, Copyright (c) 1999-2017, by Zend Technologies
  • Apache 2.4 (Server version: Apache/2.4.6 (CentOS) Server built:   Oct 19 2017 20:39:16)
  • MariaDB 5.5 (mysql  Ver 15.1 Distrib 5.5.56-MariaDB, for Linux (x86_64) using readline 5.1)

They only occur when I'm updating from 7.1.11 to 7.1.12. Have somebody the similar problems? I've see too, that in this topic is mentioned a similar (narrow.PNG) thing.

You can see the failures on the screenshots. Here are the descriptions:

  • narrow.PNG - like on the linked topic above (Warning since PHP 7.1.12)
  • notifications.PNG - show's this errors when accessing "Site Administration -> Notifications", after pushing "F5" or reload, it works fine...
  • search-before-php7.1.11.PNG - it's the running output when searching something in "Site Administration"
  • search-after-php7.1.12.PNG - this is the broken version...

I hope you can help me. 

Thanks
Adrian
Average of ratings: -
In reply to Adrian Perez Rodriguez

Re: PHP warnings and error in due of PHP 7.1.12 update

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Adrian,
http://php.net/ChangeLog-7.php#7.1.12 tells that 7.1.12 fixes the issue but in https://bugs.php.net/bug.php?id=74980 someone is telling that the issue is still there: I'd suggest you to record there your "me too".

You could say the "me too" even in https://bugs.php.net/bug.php?id=75570 where a fix is supposed to be already done few days ago i.e. not released yet: could you test a nightly?

The SQL error looks like coming from the survey pro plug-in: could you enable the debugging at DEVELOPER level and provide the text of the stack trace here? Could you share your Moodle version too?

HTH,
Matteo

In reply to Matteo Scaramuccia

Re: PHP warnings and error in due of PHP 7.1.12 update

by Adrian Perez Rodriguez -

Hello Matteo

I apologise, the topic that I meant is this one https://moodle.org/mod/forum/discuss.php?d=362075.

Thanks for sharing the links with the php bugs, I will look at it later.

For the moment here a few more informations:

  • We have two instaces running the same setup with the moodle release Moodle 3.2.5+ (Build: 20170928).
  • One of the platform doesn't show any errors like on the other platform. And they have installed the same php version/packages.
  • The stacktrace of the failing platform is:
    • Notice: Undefined offset: 0 in /var/www/html/<path>/lib/accesslib.php on line 3665

      Warning: array_keys() expects parameter 1 to be array, null given in /var/www/html/<path>/lib/accesslib.php on line 3665

      Warning: implode(): Invalid arguments passed in /var/www/html/<path>/lib/accesslib.php on line 3665

      Notice: Undefined offset: 0 in /var/www/html/<path>/lib/accesslib.php on line 3670

      Warning: array_keys() expects parameter 1 to be array, null given in /var/www/html/<path>/lib/accesslib.php on line 3670

      Warning: implode(): Invalid arguments passed in /var/www/html/<path>/lib/accesslib.php on line 3670
      Debug info: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')
      AND userid NOT IN (
      ' at line 5
      SELECT u.id, u.username, u.firstnamephonetic,u.lastnamephonetic,u.middlename,u.alternatename,u.firstname,u.lastname
      FROM mdl_user u
      JOIN (SELECT DISTINCT userid FROM ( SELECT userid
      FROM mdl_role_assignments
      WHERE contextid IN (1) AND roleid IN ()
      AND userid NOT IN (
      SELECT userid
      FROM mdl_role_assignments
      WHERE contextid IN (1)
      AND roleid IN ()
      ) ) us) ra ON ra.userid = u.id
      WHERE u.deleted = 0 AND u.id <> ?
      ORDER BY u.lastname, u.firstname, u.id
      [array (
      0 => '1',
      )]
      Error code: dmlreadexception

      Stack trace:
      • line 479 of /lib/dml/moodle_database.php: dml_read_exception thrown
      • line 1190 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      • line 3699 of /lib/accesslib.php: call to mysqli_native_moodle_database->get_records_sql()
      • line 3811 of /lib/adminlib.php: call to get_users_by_capability()
      • line 3178 of /lib/adminlib.php: call to admin_setting_users_with_capability->load_choices()
      • line 1408 of /lib/adminlib.php: call to admin_setting_configmultiselect->is_related()
      • line 856 of /lib/adminlib.php: call to admin_settingpage->search()
      • line 856 of /lib/adminlib.php: call to admin_category->search()
      • line 7861 of /lib/adminlib.php: call to admin_category->search()
      • line 64 of /admin/search.php: call to admin_search_settings_html()


The error is because the array is NULL and then the roleid is not set! I've noticed yesterday when I was debugging in the accesslib.php, that the capabilities array is set different. Most time there's only the "moodle/site:approvecourse" capability set! The search was only working when in the caps array, the capability with "moodle/site:config" is set too.

PS: When I disable opcache in the broken platform It runs well!!! But the healthy platform has the same opcache configurations like the others one. Can it be, that something in the "mdl_config" is misconfigured?

Kind Regards
Adrian

In reply to Adrian Perez Rodriguez

Re: PHP warnings and error in due of PHP 7.1.12 update

by Adrian Perez Rodriguez -
Hello Moodlers

Did somebody of you have some idea where's the dog is buried? It's really frustrating because I'm not progressing in this case. In the mean time there's a new php built:

  • PHP 7.1.12 (cli) (built: Dec  1 2017 13:53:12) ( NTS )
    • php-7.1.12-4.el7.remi.x86_64

The old built was the 7.1.12-3 one! But the errors still exists.

Thanks for helping out!
Adrian

In reply to Adrian Perez Rodriguez

Re: PHP warnings and error in due of PHP 7.1.12 update

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Adrian,
please follow MDL-60987.

In the mean time try to revert to PHP 7.0.x, 7.1.13 is coming (08/01/2018) and maybe - not sure at all right now - it will fix your issue; RC1 is already available: https://github.com/php/php-src/blob/049f993190d73ded614d84291412aabc8600daf6/NEWS#L3 => https://blog.remirepo.net/post/2017/12/08/PHP-version-7.0.27RC1-and-7.1.13RC1 .

HTH,
Matteo

In reply to Matteo Scaramuccia

Re: PHP warnings and error in due of PHP 7.1.12 update

by Adrian Perez Rodriguez -

Hello Matteo

Thanks for your post! I've tested it with the 7.1.13RC and now both, the error and the warning are gone! 


What's interesting, is following:

  • The search on https://<FQDN>/admin/search.php works on a clean moodle 3.3.5+ setup with php 7.1.12 
  • The same works on the "broken existing platform" (moodle 3.3.5+) only with php 7.1.11 or 7.1.13
  • I've 1:1 the same application environment and only changed the database configuration.


The second thing, the "narrowing..." and "notifications" warning, it's a bug in PHP 7.1.12 because:

  • It occurs when debugging is enabled on a clean moodle and on the existing broken platform running  php 7.1.12
  • Running on PHP 7.1.11 or 7.1.13 doesn't gives this warning.
  • But the first error must be something in our database, maybe in the mdl_config table? It's strange that this sql statement query is running false with the PHP 7.1.12 version.


We'll stay now on 7.1.11 on the productive platform until 7.1.13 is released!

Kind regards
Adrian

In reply to Adrian Perez Rodriguez

Re: PHP warnings and error in due of PHP 7.1.12 update

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
It's strange that this sql statement query is running false with the PHP 7.1.12 version

The broken SQL is the result not the root cause, mostly (guessing) due to opcache and function calls.

HTH,
Matteo

In reply to Matteo Scaramuccia

Re: PHP warnings and error in due of PHP 7.1.12 update

by Adrian Perez Rodriguez -
The broken SQL is the result not the root cause, mostly (guessing) due to opcache and function calls.

As I say here https://moodle.org/mod/forum/discuss.php?d=362349#p1461346, the problem ist that the caps array has not the right capabilities and then the roleid is "NULL". And the strange thing is, that the error must come from the database (I explain it in the previous comments, what I've done...). 

So what I think is, that moodle can't access the right capabilities from the database and then this "SELECT ... statemenet" for search through the site administration gives an error. 

Why this behaviour happened only with PHP 7.1.12 is also dubious.