CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Validate Hook causing PHP memory errors
Pages: [1]

Author Topic: Validate Hook causing PHP memory errors  (Read 1896 times)

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Validate Hook causing PHP memory errors
June 21, 2013, 09:59:22 am
I'm stumped on this one, primarily because it was working earlier today and now its not. I've gone back to backups, and still nothing.

I use the validate hook to validate certain form entries in profiles (such as phone number). Today, when I start submitting forms with errors, I am getting a Server Error, which is showing up in my logs as:

Code: [Select]
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 62914560 bytes) in /sites/all/modules/civicrm/packages/Log.php on line 554, referer: https://example.com/civicrm/contribute/transact?reset=1&id=2
I've gone back to basics to find out what the cause is.

This works fine, as it should, and processes the form.
Code: [Select]
function nbla_hooks_civicrm_validateForm( $formName, &$fields, &$files, &$form, &$errors ) {
    return $errors;
}


This doesn't, and gives me the Server Error noted above.
Code: [Select]
function nbla_hooks_civicrm_validateForm( $formName, &$fields, &$files, &$form, &$errors ) {
    $errors['postal_code-1'] = ts( 'Please enter a valid postal code' )
    return $errors;
}

If I put in a backtrace right before Line 554 in Log.php, I get the following. I have greatly shortened the queries as they are actually several thousand lines long. Also not sure why the backtrace is being displayed twice.

Code: [Select]
Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -1
    [message] => DB Error: unknown error
    [mode] => 16
    [debug_info] => UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_CRM_Contribute_Controller_Contribution_7938418aac73906cf45bc5e26245a546_2477' , data = 'a:27:{s:5:\"qfKey\";s:37:\"7938418aac73906cf45bc5e26245a546_2477\";s:2:\"id\";s:1:\"2\";s:6:\"action\";i:1;s:5:\"bltID\";i:5;s:17:\"paymentProcessors\";a:1:{i:1;a:18:{s:2:\"id\";s:1:\"1\";s:4:\"name\";s:33......
    [type] => DB_Error
    [user_info] => UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_CRM_Contribute_Controller_Contribution_7938418aac73906cf45b.......
    [to_string] => [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::handle prefix="" info="UPD.....[nativecode=1153 ** Got a packet bigger than 'max_allowed_packet' bytes]"]
)
backTrace

#0 /persistent/html/sites/all/modules/civicrm/packages/Log.php(547): CRM_Core_Error::backtrace()
#1 /persistent/html/sites/all/modules/civicrm/packages/Log/file.php(295): Log->_format("%1$s %2$s [%3$s] %4$s", "Jun 21 13:44:16", 6, "$Fatal Error Details = Array\n(\n    [callback] => Array\n        (\n        ...")
#2 /persistent/html/sites/all/modules/civicrm/CRM/Core/Error.php(508): Log_file->log("$Fatal Error Details = Array\n(\n    [callback] => Array\n        (\n        ...")
#3 /persistent/html/sites/all/modules/civicrm/CRM/Core/Error.php(489): CRM_Core_Error::debug_log_message("$Fatal Error Details = Array\n(\n    [callback] => Array\n        (\n        ...", FALSE, "")
#4 /persistent/html/sites/all/modules/civicrm/CRM/Core/Error.php(195): CRM_Core_Error::debug_var("Fatal Error Details", (Array:8))
#5 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
#6 /persistent/html/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
#7 /persistent/html/sites/all/modules/civicrm/packages/DB.php(969): PEAR_Error->PEAR_Error("DB Error: unknown error", -1, 16, (Array:2), "UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_C...")
#8 /persistent/html/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-1, 16, (Array:2), "UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_C...")
#9 /persistent/html/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -1, NULL, NULL, "UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_C...", "DB_Error", TRUE)
#10 /persistent/html/sites/all/modules/civicrm/packages/DB/mysql.php(898): DB_common->raiseError(-1, NULL, NULL, NULL, "1153 ** Got a packet bigger than 'max_allowed_packet' bytes")
#11 /persistent/html/sites/all/modules/civicrm/packages/DB/mysql.php(327): DB_mysql->mysqlRaiseError()
#12 /persistent/html/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_C...")
#13 /persistent/html/sites/all/modules/civicrm/packages/DB/DataObject.php(2425): DB_common->query("UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_C...")
#14 /persistent/html/sites/all/modules/civicrm/packages/DB/DataObject.php(1324): DB_DataObject->_query("UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_C...")
#15 /persistent/html/sites/all/modules/civicrm/CRM/Core/DAO.php(284): DB_DataObject->update()
#16 /persistent/html/sites/all/modules/civicrm/CRM/Core/BAO/Cache.php(131): CRM_Core_DAO->save()
#17 /persistent/html/sites/all/modules/civicrm/CRM/Core/BAO/Cache.php(199): CRM_Core_BAO_Cache::setItem((Array:27), "CiviCRM Session", "CiviCRM_CRM_Contribute_Controller_Contribution_7938418aac73906cf45bc5e26245a5...")
#18 /persistent/html/sites/all/modules/civicrm/CRM/Core/Session.php(539): CRM_Core_BAO_Cache::storeSessionToCache((Array:2), TRUE)
#19 /persistent/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(295): CRM_Core_Session::storeSessionObjects()
#20 /persistent/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(70): CRM_Core_Invoke::runItem((Array:15))
#21 /persistent/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
#22 /persistent/html/sites/all/modules/civicrm/drupal/civicrm.module(436): CRM_Core_Invoke::invoke((Array:3))
#23 [internal function](): civicrm_invoke("contribute", "transact")
#24 /persistent/html/includes/menu.inc(517): call_user_func_array("civicrm_invoke", (Array:2))
#25 /persistent/html/index.php(21): menu_execute_active_handler()
#26 {main}
backTrace

#0 /persistent/html/sites/all/modules/civicrm/packages/Log.php(547): CRM_Core_Error::backtrace()
#1 /persistent/html/sites/all/modules/civicrm/packages/Log/file.php(295): Log->_format("%1$s %2$s [%3$s] %4$s", "Jun 21 13:44:16", 6, "$Fatal Error Details = Array\n(\n    [callback] => Array\n        (\n        ...")
#2 /persistent/html/sites/all/modules/civicrm/CRM/Core/Error.php(508): Log_file->log("$Fatal Error Details = Array\n(\n    [callback] => Array\n        (\n        ...")
#3 /persistent/html/sites/all/modules/civicrm/CRM/Core/Error.php(489): CRM_Core_Error::debug_log_message("$Fatal Error Details = Array\n(\n    [callback] => Array\n        (\n        ...", FALSE, "")
#4 /persistent/html/sites/all/modules/civicrm/CRM/Core/Error.php(195): CRM_Core_Error::debug_var("Fatal Error Details", (Array:8))
#5 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
#6 /persistent/html/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
#7 /persistent/html/sites/all/modules/civicrm/packages/DB.php(969): PEAR_Error->PEAR_Error("DB Error: unknown error", -1, 16, (Array:2), "UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_C...")
#8 /persistent/html/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-1, 16, (Array:2), "UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_C...")
#9 /persistent/html/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -1, NULL, NULL, "UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_C...", "DB_Error", TRUE)
#10 /persistent/html/sites/all/modules/civicrm/packages/DB/mysql.php(898): DB_common->raiseError(-1, NULL, NULL, NULL, "1153 ** Got a packet bigger than 'max_allowed_packet' bytes")
#11 /persistent/html/sites/all/modules/civicrm/packages/DB/mysql.php(327): DB_mysql->mysqlRaiseError()
#12 /persistent/html/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_C...")
#13 /persistent/html/sites/all/modules/civicrm/packages/DB/DataObject.php(2425): DB_common->query("UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_C...")
#14 /persistent/html/sites/all/modules/civicrm/packages/DB/DataObject.php(1324): DB_DataObject->_query("UPDATE  civicrm_cache  SET group_name = 'CiviCRM Session' , path = 'CiviCRM_C...")
#15 /persistent/html/sites/all/modules/civicrm/CRM/Core/DAO.php(284): DB_DataObject->update()
#16 /persistent/html/sites/all/modules/civicrm/CRM/Core/BAO/Cache.php(131): CRM_Core_DAO->save()
#17 /persistent/html/sites/all/modules/civicrm/CRM/Core/BAO/Cache.php(199): CRM_Core_BAO_Cache::setItem((Array:27), "CiviCRM Session", "CiviCRM_CRM_Contribute_Controller_Contribution_7938418aac73906cf45bc5e26245a5...")
#18 /persistent/html/sites/all/modules/civicrm/CRM/Core/Session.php(539): CRM_Core_BAO_Cache::storeSessionToCache((Array:2), TRUE)
#19 /persistent/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(295): CRM_Core_Session::storeSessionObjects()
#20 /persistent/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(70): CRM_Core_Invoke::runItem((Array:15))
#21 /persistent/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
#22 /persistent/html/sites/all/modules/civicrm/drupal/civicrm.module(436): CRM_Core_Invoke::invoke((Array:3))
#23 [internal function](): civicrm_invoke("contribute", "transact")
#24 /persistent/html/includes/menu.inc(517): call_user_func_array("civicrm_invoke", (Array:2))
#25 /persistent/html/index.php(21): menu_execute_active_handler()
#26 {main}
T
T

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: Validate Hook causing PHP memory errors
June 21, 2013, 10:59:32 am
Update, it only appears to apply to CiviContribute. I see someone else with a similar problem.
http://forum.civicrm.org/index.php/topic,28808.0.html

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Validate Hook causing PHP memory errors

This forum was archived on 2017-11-26.