This one is rather hard to debug, because it's in effect in a schedules Rule Component during cron. The situation is, the whole scheduled component fails, the message is not being sent, but the user gets an email "You've got new messages" on each cron run (once per hour) again and again, besides flooding the log.

The least task resulting from this bug for Privatemsg would be, to ensure notifications only be sent in case a message was really put into the inbox. The maximum task would be to find out, if it's in the responsibility of Privatemsg or of Rules, why the whole thing explodes.

At the bottom you find the backtrace making _privatemsg_send() fail and rollback the transaction, so not sending the Privatemsg.

To me it looks like all is find, but during RulesState->cleanUp() it attemps to save the guest account. This really looks like a Rules issue, but it only happens after Privatemsg tried to send the email. So I expect something to be wrong with the rules handler, like changing some parts of the anonymous user.

Backtrace:

#0 /includes/database/database.inc(2139): PDOStatement->execute(Array) 
#1 /includes/database/database.inc(664): DatabaseStatementBase->execute(Array, Array) 
#2 /includes/database/mysql/query.inc(36): DatabaseConnection->query('INSERT INTO {us...', Array, Array) 
#3 /includes/common.inc(7106): InsertQuery_mysql->execute() 
#4 /modules/user/user.module(577): drupal_write_record('users', Object(stdClass)) 
#5 /sites/all/modules/entity/modules/callbacks.inc(798): user_save(Object(stdClass), Array) 
#6 /sites/all/modules/entity/entity.module(190): entity_metadata_user_save(Object(stdClass)) 
#7 /sites/all/modules/entity/includes/entity.wrapper.inc(830): entity_save('user', Object(stdClass)) 
#8 /sites/all/modules/rules/includes/rules.state.inc(229): EntityDrupalWrapper->save() 
#9 /sites/all/modules/rules/includes/rules.state.inc(74): RulesState->saveNow('site:current_us...') 
#10 /sites/all/modules/rules/includes/rules.plugins.inc(696): RulesState->cleanUp(Object(RulesEventSet)) 
#11 /sites/all/modules/rules/rules.module(833): RulesEventSet->executeByArgs(Array) 
#12 /sites/all/modules/privatemsg/privatemsg_rules/privatemsg_rules.module(14): rules_invoke_event('privatemsg_inse...', Object(stdClass), Object(stdClass)) 
#13 [internal function]: privatemsg_rules_privatemsg_message_insert(Object(stdClass)) 
#14 /includes/module.inc(857): call_user_func_array('privatemsg_rule...', Array) 
#15 /sites/all/modules/privatemsg/privatemsg.module(1868): module_invoke_all('privatemsg_mess...', Object(stdClass)) 
#16 /sites/all/modules/privatemsg/privatemsg.module(1610): _privatemsg_send(Object(stdClass)) 
#17 /sites/all/modules/privatemsg/privatemsg_rules/privatemsg_rules.rules.inc(209): privatemsg_new_thread(Array, 'Welcome', 'Dear User, welcome...', Array) 
#18 [internal function]: privatemsg_rules_new(Array, Object(RulesAction), 'execute') 
#19 /sites/all/modules/rules/includes/faces.inc(123): call_user_func_array('privatemsg_rule...', Array) 
#20 /sites/all/modules/rules/includes/rules.core.inc(297): FacesExtendable->__call('execute', Array) 
#21 /sites/all/modules/rules/includes/rules.plugins.inc(20): RulesExtendable->__call('execute', Array) 
#22 /sites/all/modules/rules/includes/rules.core.inc(1570): RulesAction->executeCallback(Array, Object(RulesState)) 
#23 /sites/all/modules/rules/includes/rules.core.inc(2215): RulesAbstractPlugin->evaluate(Object(RulesState)) 
#24 /sites/all/modules/rules/includes/rules.plugins.inc(598): RulesActionContainer->evaluate(Object(RulesState)) 
#25 /sites/all/modules/rules/includes/rules.core.inc(2215): RulesLoop->evaluate(Object(RulesState)) 
#26 /sites/all/modules/rules/includes/rules.plugins.inc(216): RulesActionContainer->evaluate(Object(RulesState)) 
#27 /sites/all/modules/rules/includes/rules.core.inc(2215): Rule->evaluate(Object(RulesState)) 
#28 /sites/all/modules/rules/modules/rules_core.eval.inc(35): RulesActionContainer->evaluate(Object(RulesState)) 
#29 [internal function]: rules_element_invoke_component(Array, Object(RulesAction), 'execute') 
#30 /sites/all/modules/rules/includes/faces.inc(123): call_user_func_array('rules_element_i...', Array) 
#31 /sites/all/modules/rules/includes/rules.core.inc(297): FacesExtendable->__call('execute', Array) 
#32 /sites/all/modules/rules/includes/rules.plugins.inc(20): RulesExtendable->__call('execute', Array) 
#33 /sites/all/modules/rules/includes/rules.core.inc(1570): RulesAction->executeCallback(Array, Object(RulesState)) 
#34 /sites/all/modules/rules/includes/rules.core.inc(2215): RulesAbstractPlugin->evaluate(Object(RulesState)) 
#35 /sites/all/modules/rules/includes/rules.plugins.inc(216): RulesActionContainer->evaluate(Object(RulesState)) 
#36 /sites/all/modules/rules/includes/rules.core.inc(2215): Rule->evaluate(Object(RulesState)) 
#37 /sites/all/modules/rules/rules_scheduler/rules_scheduler.module(64): RulesActionContainer->evaluate(Object(RulesState)) 
#38 /includes/common.inc(5243): rules_scheduler_run_task(Array) 
#39 /cron.php(25): drupal_cron_run() 
#40 {main}

Comments

Anonymous’s picture

Title: Sending message via Rules throws Exception » Don't fail sending PM, if a privatemsg_message_insert hook crashes
Component: Code (privatemsg_rules) » Code

The original issue was more a conglomerate of Rules and Fields... however, PrivateMsg was sending the notification email although the PM wasn't sent. Actually, it was able to store the PM, but rolled back all the way when the Rules handler for private_message_insert crashed.

Would it be possible in _privatemsg_send() to seperate module_invoke_all('privatemsg_message_insert', $message) from the actual sending process, so hooks wouldn't in the future disturb PrivateMsg in such a harmful way?

ivnish’s picture

Status: Active » Closed (outdated)