News:

Wondering if this will always be free?  See why free is better.

Main Menu

Error log filling up after 2.0.14 upgrade

Started by trailmyx, May 24, 2017, 11:00:13 AM

Previous topic - Next topic

trailmyx

Hi Guys,

I've worked very hard to get my SMF error log down to near zero in 2.x.  I had an out of control error problem in 1.x, so I've been extra vigilant in 2.x.  I've been doing well for months on 2.x without issue until I installed the 2.0.14 upgrade.  After that, my error log has just exploded.  After 3 days, it was up to over 80K errors.  Here are the associated 2 errors that pop up over and over again.  (BTW, I have MySQL version 5.5.51-38.2 - this is a shared host so I don't have control over this version)


http://www.scriptuo.com/index.php?topic=5878.msg110817
2: mysql_free_result() expects parameter 1 to be resource, object given
File: /xx/xx/xx/xx/Sources/Display.php
Line: 1049


and


http://www.scriptuo.com/index.php?topic=5878.msg110817
2: mysql_fetch_assoc() expects parameter 1 to be resource, object given
File: /xx/xx/xx/xx/Sources/Display.php
Line: 1043


code at line 1043:

1042: $temp = array();
==>1043: while($row = mysql_fetch_assoc($request))
1044: {
1045: $temp[$row['filename']] = $row;


code at line 1049:

1047: attachments['disabled_'.$row['id_msg']] = array();
1048: }
==>1049: mysql_free_result($request);
1050:
1051: ksort($temp);


I'm wondering what can be done to get my explosive log problem under control?

Thanks for your time!
TM

Illori

you need php 5.4 for this patch to work on your server.

vbgamer45

attach your display.php looks like either a bad mod install or. its smf 1.1.x
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Arantor

It's a mod that doesn't use $smcFunc for sure.

Replace mysql_fetch_assoc with $smcFunc['db_fetch_assoc'] and mysql_free_result with $smcFunc['db_free_result'] to make the errors go away.

trailmyx

Quote from: Arantor on May 24, 2017, 11:10:32 AM
It's a mod that doesn't use $smcFunc for sure.

Replace mysql_fetch_assoc with $smcFunc['db_fetch_assoc'] and mysql_free_result with $smcFunc['db_free_result'] to make the errors go away.
I'll give that a whirl tonight and see.  I'm running PHP 5.6 at the moment (had to get past the white screen issue).  I'll look at that part of the code in the full context to see if I can determine what mod may have contributed that code.  Thanks Arantor, vbgamer45 and Illori for your input.  I'll check back tonight to let you know how it went.

I'll also attach my Display.php for your viewing pleasure.

Colin

"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

Arantor

It's not a file from an SMF fork here. (The file header doesn't match for Eos Alpha)

It's a mod that's been installed regarding attachments, as evidenced by the indentation being off. Not to mention that the linked line has nothing to do with 'disabled attachments', so I'm going with a guest-attachment mod of some description being the culprit.

Colin

"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

Arantor

Still doesn't look like the code in the OP's file. And again, comparing an SMF fork to a modded SMF isn't going to get you anywhere because it's fundamentally different code.

Eos Alpha just decided to rip out $smcFunc and revert to bare mysql functions, the mod author here did something similar but that doesn't make it in any fashion the same code.

trailmyx

Quote from: Arantor on May 24, 2017, 11:49:52 AM
It's not a file from an SMF fork here. (The file header doesn't match for Eos Alpha)

It's a mod that's been installed regarding attachments, as evidenced by the indentation being off. Not to mention that the linked line has nothing to do with 'disabled attachments', so I'm going with a guest-attachment mod of some description being the culprit.

You're right Arantor, in this mod Attachment Notice

adds this code:

<search position="before"><![CDATA[ foreach ($temp as $row)
$attachments[$row['id_msg']][] = $row;
}]]></search>
<add><![CDATA[elseif(!empty($modSettings['attachmentEnable']) && !allowedTo('view_attachments'))
{
$request = $smcFunc['db_query']('','
SELECT
id_msg, filename
FROM {db_prefix}attachments
WHERE ID_MSG IN ({array_int:message_list})
AND attachment_type = {int:attachment_type}' . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : '
AND approved = {int:is_approved}'),
array(
'message_list' => $messages,
'attachment_type' => 0,
'is_approved' => 1,
));
$temp = array();
while($row = mysql_fetch_assoc($request))
{
$temp[$row['filename']] = $row;
if(!isset($attachments['disabled_'.$row['id_msg']]))
$attachments['disabled_'.$row['id_msg']] = array();
}
mysql_free_result($request);

ksort($temp);

foreach($temp as $row)
$attachments['disabled_'.$row['id_msg']][] = $row;
}]]></add>


Odd thing is this error wasn't being thrown before 2.0.14.  Like I said, I'm pretty diligent about my error log these days.  :)

Arantor

That's because the mod does it incorrectly and doesn't use the features in SMF to do this - which got changed as part of 2.0.14 - because in newer versions of PHP, mysql_fetch_assoc and friends don't exist.

Code (find) Select
while($row = mysql_fetch_assoc($request))

Code (replace) Select
while($row = $smcFunc['db_fetch_assoc']($request))

Code (find) Select
mysql_free_result($request);

Code (replace) Select
$smcFunc['db_free_result']($request);

The mod should be updated to include this.

vbgamer45

Also post in that mod's topic to let the author know to update it.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

trailmyx

Thank you guys for looking into this and the recommended solution.  Also thanks for the explanation about why it broke as well.  It's nice to know "why" something happens just as much as "how" to fix it.   Cheers!

Yes, I'll post in the appropriate thread this solution.  I should also share my other tweaks to get this mod to work in later versions of 2.x.

trailmyx

That was it and the patch worked swimmingly.  De-installed that mod, modified the delivery package and then re-installed.  If you didn't point to what type of mod that code might have been from, it would have taken me days to figure it out.  Worst is I'd have to modify the SMF source code directly instead of modifying the mod installer package.  I'm back to the normal errors once might expect.

So thanks once again!

TM

Advertisement: