Fixed Allowed memory size exhausted with admin cp search

dutchbb

Well-known member
Affected version
1.5
Sometimes i get this error when doing a search in the admin cp.

Code:
PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /home/bodyforum/public_html/library/Zend/Db/Statement/Mysqli.php on line 304
 
There wouldn't usually be an expectation for so many results to be returned that it would cause memory issues.

Can you narrow it down to something specific you're searching for? It could be that you've got an add-on which is adding a considerable amount of entries and your search is matching a lot of them and that is exhausting the memory limit trying to display them.
 
Did a few searches i did yesterday and can't recreate it at the moment. It only happens sometimes, so i will check from now on with every search i do what the results are and if it happens.
 
Ok, found it. When you search for 'mail' it gives the error. Does not return any results only 3 times an error.

Code:
ErrorException: Fatal Error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) - library/Zend/Db/Statement/Mysqli.php:304
Gegenereerd Door: bodybuilding.nl, 2 minuten geleden
Stack Trace
#0 [internal function]: XenForo_Application::handleFatalError()
#1 {main}
Aanvraagstatus
array(3) {
  ["url"] => string(47) "https://forum.bodybuilding.nl/admin.php?search/"
  ["_GET"] => array(1) {
    ["search/"] => string(0) ""
  }
  ["_POST"] => array(5) {
    ["q"] => string(4) "mail"
    ["_xfToken"] => string(8) "********"
    ["_xfRequestUri"] => string(10) "/admin.php"
    ["_xfNoRedirect"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}
 
Tested again today and no error in admin cp but in the error_log. I am on php 7.1 btw.

Code:
[16-Nov-2017 12:14:16 UTC] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /home/bodyforum/public_html/library/Zend/Db/Statement/Mysqli.php on line 304
[16-Nov-2017 12:14:16 UTC] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 32768 bytes) in /home/bodyforum/public_html/library/XenForo/Error.php on line 1
[16-Nov-2017 12:15:02 UTC] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /home/bodyforum/public_html/library/Zend/Db/Statement/Mysqli.php on line 304
[16-Nov-2017 12:15:02 UTC] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 32768 bytes) in /home/bodyforum/public_html/library/XenForo/Error.php on line 1
[16-Nov-2017 13:10:36 UTC] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /home/bodyforum/public_html/library/Zend/Db/Statement/Mysqli.php on line 304
[16-Nov-2017 13:10:36 UTC] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 32768 bytes) in /home/bodyforum/public_html/library/XenForo/Error.php on line 1
 
I guess that is a fairly common string that will appear across all admin search types, though I'm not certain it's enough to cause this. Certainly no installs I have access to seem to have any problem.

If it's specifically that word, can you account for any particular add-on which might be adding searchable content types where "mail" comes up a lot?

If you disable all add-ons, is it still reproducible?
 
I tried a lot of words and only the word "mail"

email, e-mail or other words with mail in it does not give the error.

I will disable all add-ons and try again.
 
All add-ons disabled and still the error. So only with the word "mail", if i put anything in front or after it does a search. With mail it shows no results but also not 'no results found'
 
I guess the problem with disabling the add-ons is it doesn't necessarily prevent the searchable data being there.

I guess if you create a ticket, this might be the easiest way for us to see what's going on. If you can provide FTP and Admin CP access that will be appreciated.
 
Indeed. I have some add-ons installed that are related to mail that could be the cause. If you can't reproduce the error on an other xf1 install (and nobody else reported this) then probably on of those or combination would be the problem.

It is not a pressing problem but i will create a ticket soon.
 
Indeed. I have some add-ons installed that are related to mail that could be the cause. If you can't reproduce the error on an other xf1 install (and nobody else reported this) then probably on of those or combination would be the problem.

It is not a pressing problem but i will create a ticket soon.
curious, does raising memory limit from 256M to 384M fix it ?
 
Yes that works ;) And gives a search result, i only see 1 add-on in it.

Code:
Admin-navigation  
Verbannen E-mails
E-mail Bounce-log
E-mail Gebruikers

Options  
Email From Username attachmentCheckEmailFromUsername
Email To attachmentCheckEmailTo
Forumtitel boardTitle
Bounced E-mailadres bounceEmailAddress
Allow Individual Option cel_individual_contact_option

Users   
!!~Franky~!!
!!~Pietje~!! 
!Bataat! 
!nge 
#1 Achilles 

Notifications  
E-mails
Templates   
notice_confirm_email
notice_email_bounce
two_step_email
watch_via_email
Frases   
administrator_email
admin_navigation_bannedEmails
admin_navigation_emailBouncesLog
admin_navigation_emailTemplateMods
admin_navigation_emailTemplates
 
Removed the add-on Attachmentcheck and set memory limit back to 256M, but still error.

Did the search again with higher limit, found another add-on that was disabled, will remove and test. I think to many add-ons referring to mail.
 
Last edited:
And still the error, now with autoloader.php also

"mai" also gives the error even on 384M. Will try removing some other add-ons.

Code:
[17-Nov-2017 19:55:37 UTC] PHP Fatal error:  Allowed memory size of 402653184 bytes exhausted (tried to allocate 20480 bytes) in /home/bodyforum/public_html/library/Zend/Db/Statement/Mysqli.php on line 304
[17-Nov-2017 19:55:37 UTC] PHP Fatal error:  Allowed memory size of 402653184 bytes exhausted (tried to allocate 73728 bytes) in /home/bodyforum/public_html/library/XenForo/Autoloader.php on line 119
 
Last edited:
@imthebest has reported this issue as well and he has a theory that I think is probably correct.

Ultimately it looks like the "User" admin search handler doesn't actually contain a limit on the user query so something like "mail" which will appear in many of your user's emails (hotmail, gmail, etc) will end up hitting memory limits.

Could you find the file library/XenForo/AdminSearchHandler/User.php and change:
PHP:
array('adminQuickSearch' => $searchText)
To:
PHP:
array('adminQuickSearch' => $searchText), array('limit' => XenForo_Application::getOptions()->adminSearchMaxResults)

That should solve it, I think.
 
Back
Top Bottom