version 1.5: Warning: asort() expects parameter 1 to be array...lib.php.....line 315

version 1.5: Warning: asort() expects parameter 1 to be array...lib.php.....line 315

by webmaster gerhard -
Number of replies: 8
  1. Warning: asort() expects parameter 1 to be array, null given in /www/htdocs/xxxxx/moodle/course/lib.php on line 315
  2. i tried for 2 times to install 1.5+ and i got this error warning
  3. why?
  4. any ideas?

thanks


Average of ratings: -
In reply to webmaster gerhard

Re: version 1.5: Warning: asort() expects parameter 1 to be array...lib.php.....line 315

by Alan Wolf -

I too have this problem and have no idea what to do. 

When I try to use Logs, I get the following message:

Warning: asort() expects parameter 1 to be array, null given in /home/workitou/public_html/course/lib.php on line 315

My hosting company has says it is a database corruption problem.  As suggested somewhere else on the Moodle boards, they have tried fixing MYSQL but (after an hour run) it didn't work.

I notice that on the logs screen  (sitename/Administration/Logs), the field to the left of "My Participants" appears blank.  There is a pull down window, but no information in it.

When I click on the "Show these logs" button, a new page with the following error message appears "A required parameter was missing."

I'd appreciate any help you might provide.  Thanks!

In reply to Alan Wolf

Re: version 1.5: Warning: asort() expects parameter 1 to be array...lib.php.....line 315

by Mikael Ekblom -
Same problem here. I ran a database check and it found no corrupt indexes or anything else. Alla tables where fine.

This occurs only if you are logged in as an admin user. I got rid of the warning message by defining the $courses variable as an array at line 306 in /courser/lib.php

This doesn't solve the problem though...I do not know where this comes from. I can view the logs normally as an instructor but not as an admin...strange. It simply doesn't fins any courses to view data for.
In reply to Mikael Ekblom

Re: version 1.5: Warning: asort() expects parameter 1 to be array...lib.php.....line 315

by Lisa Wise -
Thanks Mikael for your monologue - it was very helpful in terms of understanding the problem a bit better.

I tried to work out where to use ini_set() to change the persistence of mysql connections. In the end, I found that the error only occurs for me when using the database to store sessions. Changing to dbsessions=no fixed my problem.

Regards
Lisa
In reply to Alan Wolf

Re: version 1.5: Warning: asort() expects parameter 1 to be array...lib.php.....line 315

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
What version of PHP and MySQL are you using? This sounds similar to an issue that I was running into with PHP5 with arrays. 
In reply to Anthony Borrow

Re: version 1.5: Warning: asort() expects parameter 1 to be array...lib.php.....line 315

by Mikael Ekblom -
We're using Php 5.0.4, Mysql 4.1.10,hmm, now I recall that you can set the option register_long_arrays in php.ini to "on". I wonder if this would help?On the other hand, I do not have this option enabled on my test server and one should use the super-duper gobals instead.

The difference is that on my test server I made a clean install to version 1.5.2 and an upgrade from version 1.5.1 to 1.5.2 on my production server. No error reports during install.

This problem just suddenly occured, from nowhere. The mdl_log MUST somehow be corrupt, but this is not detected by mysqlcheck...I must have a ghost in my system, but I will find from where this problem originates.   
In reply to Mikael Ekblom

Re: version 1.5: Warning: asort() expects parameter 1 to be array...lib.php.....line 315

by Mikael Ekblom -
OK, routine work done, back to Moodle-kapoodle.After some research I found out that this line never will return true in lib.php within my installation when I use logs as an admin user:

 if ($ccc = get_records("course", "", "", "fullname","id,fullname,category")) {

 so, I got rid of the warning by moving the line asort($courses) up one line for it to be within this block of code. If it fails, well, no array will be sorted either due to the failing of the precondition listed in the beginning of this post.. So, the problem must be within the get_records funtion then.
In reply to Mikael Ekblom

Re: version 1.5: Warning: asort() expects parameter 1 to be array...lib.php.....line 315

by Mikael Ekblom -
Hmm, I seem to keep a monologue heresmile Well, I now found out that the function _query in moodle\lib\adodb\drivers\adodb-mysql.inc.php will generate the following error message:

PHP Warning: mysql_query(): 7 is not a valid MySQL-Link resource in E:\moodle\lib\adodb\drivers\adodb-mysql.inc.php on line 470

Hmm,time to switch on persistent database connections?


In reply to Mikael Ekblom

Re: version 1.5: Warning: asort() expects parameter 1 to be array...lib.php.....line 315

by Mikael Ekblom -
So, problem solved, mysql.allow_persistent = On set in php.ini

This means that I can get rid of my debugging-mode code in datalib.php and adodb-filessmile