ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: Adrek on September 24, 2014, 05:14:32 pm

Title: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: Adrek on September 24, 2014, 05:14:32 pm
I'm reporting it here, because I have nothing installed (just clean ElkArte 1.0).

RSS is working fine for me, but from some time I see in error log this two entries:

URL: index.php?action=.xml;type=atom;limit=5
Code: [Select]
2: mysqli_free_result() expects parameter 1 to be mysqli_result, null given
File: /sources/database/Db-mysql.class.php
Line: 543
Code: [Select]
540:		public function free_result($result)
541: {
542: // Just delegate to MySQL's function
==>543: mysqli_free_result($result);
544: }


URL: index.php?action=.xml;type=atom;limit=5
Code: [Select]
2: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given
File: /sources/database/Db-mysql.class.php
Line: 554
Code: [Select]
551:		public function num_rows($result)
552: {
553: // Simply delegate to the native function
==>554: return mysqli_num_rows($result);
555: }
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: emanuele on September 24, 2014, 07:05:47 pm
hmm...

Can you see a "pattern"?
Maybe only registered members of some kind?
Or just guests?
Or something else?
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: Adrek on September 25, 2014, 01:55:34 am
It was once generated by me and once by Guest,  but I think that it was me anyway,  because I set up RSS feed in my browser.
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: Spuds on September 25, 2014, 07:50:00 am
This is an odd one.  Are there any other db errors before those errors?  For the result object to be null it would seem like the db connection is gone.
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: Adrek on September 25, 2014, 11:12:44 am
No, this are only errors related to DB, I don't have any other errors.
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: emanuele on September 25, 2014, 12:49:59 pm
Judging from the errors, I think it can happen only here:
https://github.com/elkarte/Elkarte/blob/v1.0.0/sources/subs/News.subs.php#L206
that is a function that has both free_result and num_rows.
The function grab the messages of the feeds.

That's quote an odd error.
Could you try removing the "@" before mysqli_query in Db-mysql.class.php, query method?
If there is an error that should expose it a little bit better...
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: Adrek on September 25, 2014, 12:53:47 pm
Sure, I'll do it today.
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: Spuds on September 25, 2014, 03:50:58 pm
I thought it might be this function (recent posts), its almost the same as the above
https://github.com/elkarte/Elkarte/blob/v1.0.0/sources/subs/News.subs.php#L275

Either way, remove the suppression from that as well to see if we get more information, I guess a broken query with @ suppression may return a null response
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: emanuele on September 25, 2014, 04:44:02 pm
oh... yes, you are right... :-[
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: emanuele on October 01, 2014, 09:44:28 am
@phantom did the error appear again?
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: Adrek on October 01, 2014, 04:20:09 pm
So far I have no new entries in error log, but it's important to add that host updated server and it's running new version of MySQL.
Before it was 5.0.92-log and now I have 5.5.38-35.2-log.
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: emanuele on October 14, 2014, 03:22:26 pm
Well, if nothing else appears it's difficult to investigate.
Anyway, I wonder if it is worth adding a check just before using the mysqli_* functions to be sure the resource passed is actually a resource or not.
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: Spuds on October 14, 2014, 04:35:24 pm
like a
Code: [Select]
if (mysqli_ping($connection))
  ....
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: emanuele on October 14, 2014, 05:56:15 pm
I was more thinking about something like:
Code: [Select]
	public function free_result($result)
{
if (!is_object($result))
return false;
// Just delegate to MySQL's function
mysqli_free_result($result);
}

[...]

public function num_rows($result)
{
if (!is_object($result))
return false;

// Simply delegate to the native function
return mysqli_num_rows($result);
}

O:-)
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: Spuds on October 15, 2014, 08:31:26 am
Thats a cheat :P  We could just for empty on the result and that makes some sense ... but why is it getting passed a null to begin with, any ideas? 
Title: Re: Two RSS errors: mysqli_free_result() and mysqli_num_rows()
Post by: emanuele on February 04, 2015, 04:55:08 pm
Apparently the error didn't popup any more, so not having more info I guess it's not possible to find a meaningful fix. ;)