When I try to view messages using any of the modules that display messages, I get a fatal error page returned instead, and the dblogs give me the following error:

Recoverable fatal error: Object of class Message could not be converted to string in DatabaseStatementBase->execute() (line 2139 of /path-to-drupal-folder/includes/database/database.inc).	

For example, this happens when I view Activities in RedHen CRM, the Order view in Drupal Commerce with Commerce Backoffice installed, etc. It only happens if the Order, Contact, etc. entity has any Messages associated with it. (If you go to a Contact Activities page, an Order, etc. with no messages, the page displays just fine.)

It also occurs when I manually create a message; for example, using the "order notes" entry form provided by Commerce Backoffice on a Commerce Order: When the message is saved, it returns that same fatal error.

I have looked in Commerce, RedHen, Entity modules issue queues, etc. and can't find an answer. Please note, this error occurs even if Commerce Backoffice is not installed, if RedHen isn't, etc. It appears to occur with any module that uses/posts Messages. I have tried installing and uninstalling Message module multiple times.

This means the Message module is useless and dangerous for our site until we find an answer, and many modules we need to install require the Message module, so I'm hoping there's a quick answer to this problem.

CommentFileSizeAuthor
#10 1851478-privatemsg-collision-fix.patch589 byteskalistos
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

Do you have private-messages installed?

somatics’s picture

Oh, that's what I forgot to mention! Yes, I did have it installed, but I found the issue about Privatemsg and I uninstalled it and any related modules. I also went into the database and deleted all existing messages, just in case something about them was fundamentally damaged. (I did all this in a development environment, so I could break anything I wanted to).

Even with Privatemsg disabled, I got the exact same results I described with creating and viewing Messages.

amitaibu’s picture

Category: bug » support
Priority: Critical » Normal

You'll have to start from a clean installation, and start adding your modules.

somatics’s picture

So, there are no other known conflicts with this module other than Privatemsg?

amitaibu’s picture

Status: Active » Fixed

The only one I know off is uuid -- whihc needs to be on the dev version. If it's not that, you'll have to check one by one.

dewolfe001’s picture

This is a dump of the Message object passed to database.inc (like 2139).
In searching for this problem, I have found other database.inc problems. Is this a problem with the Message module or a case of ingestion by the database.inc's execute function?

Array ( [:db_condition_placeholder_0] => 33 )
Array ( [:name] => Message [:type] => class )
Array ( [:cids_0] => field:message:33 )
Array ( [:name] => Messaging_Simple [:type] => class )
Array ( [:name] => Messaging_Send_Method [:type] => class )
Array ( [:mgid_33] => Message Object ( 
	[type] => example_create_node 
	[timestamp] => 1354469607 
	[arguments] => Array ( [@{message:user:name}] => SuperAdmin ) 
	[data] => Array ( ) 
	[entityType:protected] => message 
	[entityInfo:protected] => Array ( 
		[label] => Message 
		[controller class] => EntityAPIController 
		[entity class] => Message 
		[base table] => message 
		[fieldable] => 1 
		[access callback] => message_access 
		[entity keys] => Array ( 
			[id] => mid 
			[label] => 
				[bundle] => 
					type [revision] => ) 
		[bundles] => Array ( 
			[example_create_comment] => Array ( 
				[label] => Example - Create comment 
				[admin] => Array ( 
					[path] => admin/structure/messages/manage/%message_type 
					[real path] => admin/structure/messages/manage/example_create_comment 
					[bundle argument] => 4 
					[access arguments] => Array ( 
						[0] => administer message types ) ) 
					[rdf_mapping] => Array ( ) ) 
					[example_create_node] => Array ( 
						[label] => Example - Create node 
						[admin] => Array ( 
							[path] => admin/structure/messages/manage/%message_type 
							[real path] => admin/structure/messages/manage/example_create_node 
							[bundle argument] => 4 
							[access arguments] => Array ( 
								[0] => administer message types ) ) 
							[rdf_mapping] => Array ( ) ) 
							[example_user_register] => Array ( 
								[label] => Example - User register 
								[admin] => Array ( 
									[path] => admin/structure/messages/manage/%message_type 
									[real path] => admin/structure/messages/manage/example_user_register 
									[bundle argument] => 4 
									[access arguments] => Array ( 
										[0] => administer message types ) ) 
									[rdf_mapping] => Array ( ) ) 
									[og_new_content] => Array ( 
										[label] => OG new content 
										[admin] => Array ( 
											[path] => admin/structure/messages/manage/%message_type 
											[real path] => admin/structure/messages/manage/og_new_content 
											[bundle argument] => 4 
											[access arguments] => Array ( 
												[0] => administer message types ) ) 
											[rdf_mapping] => Array ( ) ) 
											[comment_insert] => Array ( 
												[label] => Comment insert 
												[admin] => Array ( 
													[path] => admin/structure/messages/manage/%message_type 
													[real path] => admin/structure/messages/manage/comment_insert 
													[bundle argument] => 4 
													[access arguments] => Array ( 
														[0] => administer message types ) ) 
													[rdf_mapping] => Array ( ) ) 
													[example_og_post_in_group] => Array ( 
														[label] => Example - OG post in group 
														[admin] => Array ( 
															[path] => admin/structure/messages/manage/%message_type 
															[real path] => admin/structure/messages/manage/example_og_post_in_group 
															[bundle argument] => 4 
															[access arguments] => Array ( 
																[0] => administer message types ) ) 
															[rdf_mapping] => Array ( ) ) 
															[example_og_user_membership] => Array ( 
																[label] => Example - OG user membership 
																[admin] => Array ( 
																	[path] => admin/structure/messages/manage/%message_type 
																	[real path] => admin/structure/messages/manage/example_og_user_membership 
																	[bundle argument] => 4 
																	[access arguments] => Array ( 
																		[0] => administer message types ) ) 
																		[rdf_mapping] => Array ( ) ) ) 
																		[bundle keys] => Array ( 
																			[bundle] => name ) 
																		[view modes] => Array ( 
																			[full] => Array ( 
																				[label] => Full [custom settings] => ) 
																			[message_notify_email_subject] => Array ( 
																				[label] => Notify - Email subject 
																				[custom settings] => 1 ) 
																				[message_notify_email_body] => Array ( 
																					[label] => Notify - Email body 
																					[custom settings] => 1 ) 
																				[token] => Array ( 
																					[label] => Tokens [custom settings] => ) ) 
																				[module] => message 
																				[metadata controller class] => MessageMetadataController 
																				[views controller class] => MessageViewsController 
																				[static cache] => 1 
																				[field cache] => 1 
																				[load hook] => message_load 
																				[translation] => Array ( ) 
																				[schema_fields_sql] => Array ( 
																					[base table] => Array ( 
																						[0] => mid 
																						[1] => type 
																						[2] => arguments 
																						[3] => uid 
																						[4] => timestamp 
																						[5] => language ) ) 
																					[token type] => message [configuration] => ) 
																					[idKey:protected] => mid 
																					[nameKey:protected] => mid 
																					[statusKey:protected] => status 
																					[mid] => 33 
																					[uid] => 66 
																					[language] => en 
																					[field_node_ref] => Array ( 
																					[und] => Array ( 
																						[0] => Array ( 
																							[target_id] => 202 ) ) ) 
																						[field_published] => Array ( 
																							[und] => Array ( 
																								[0] => Array ( 
																									[value] => 1 ) ) ) 
																					[rdf_mapping] => Array ( ) ) ) 





I looked at a sample of other statements passed into the execute function:

Array ( [:db_condition_placeholder_0] => 202 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => message )
Array ( [:db_condition_placeholder_0] => 33 )
Array ( [:name] => Message [:type] => class )
Array ( [:cids_0] => field:message:33 )
Array ( [:name] => Messaging_Simple [:type] => class )
Array ( [:name] => Messaging_Send_Method [:type] => class ) 

All these are simple arrays and the [:mgid_33] is really over packed so it cannot be parsed. That's the execute() indigestion. And, by passing this into execute(), the Message function causes the indigestion.

dewolfe001’s picture

Status: Fixed » Needs review

Here's what I think needs to happen:

messaging/messaging_simple/messaging_simple.api ca. line 65 should be passing only an integer into the SELECT statement.

public static function load($mgid) {
    if ($message = db_query("SELECT * FROM {messaging_simple} WHERE mgid = :mgid", array(':mgid' => $mgid))->fetchObject()) {
      return self::build_object($message); 
    }
  }

works if you check for the integer:

  public static function load($mgid) {
	if (!(is_int($mgid))) {
		$mgid_key = array_keys($mgid);
		$mgid = intval($mgid_key[0]);
	}
    if ($message = db_query("SELECT * FROM {messaging_simple} WHERE mgid = :mgid", array(':mgid' => $mgid))->fetchObject()) {
      return self::build_object($message); 
    }
  }
amitaibu’s picture

Status: Needs review » Active

No Patch

andypost’s picture

The collision caused by privatemsg's module api function privatemsg_message_load() which wrongly supposed as hook_ENTITY_TYPE_load()

Related #1704516: Conflicts with other modules

EDIT: suppose it needs changes in privatemsg module or implements a hook_module_implements_alter() to unset this

kalistos’s picture

Status: Active » Needs review
FileSize
589 bytes

Here's a simplest fix

kalistos’s picture

Version: 7.x-1.6 » 7.x-1.x-dev

Patch was about 7.x-1.x

andypost’s picture

Category: support » bug
Status: Needs review » Reviewed & tested by the community

Filed #1860320: Collision with message module - rename privatemsg_message_load

Suppose this change is required because privatemsg has a big user base and it possible to take a time to bikeshed about new function name

kalistos’s picture

amitaibu’s picture

Since #1353342: Private messages and messages not working well together was already committed in Private-message, I don't think Message needs to fix it as-well.

somatics’s picture

I've gotten confused about the progression of this issue: Maybe I'm not understanding some of this, so I hope someone can help clarify this for me:

I reported having this problem, and that it persists even with Private Message disabled. Starting in post 6, dewolfe001 reported some details that indicate the source of the crash in Messages -- and the way I understood it, he was referring to errant behavior of the Messages module itself, not Private Message. Then some fixes were suggested, and then finally Amitaibu concluded that it doesn't need to be fixed because it's already fixed in the Private Messages module.

So, that's where I'm confused: I thought dewolfe001 and many of the follow up posts were referring to problems occurring within Messages module, regardless of interaction with the Private Messages modules. Isn't there a behavior that needs to be corrected in the Messages module itself?

amitaibu’s picture

Title: Message module returns Fatal error: Object of class Message could not be converted to string in DatabaseStatementBase » Object of class Message could not be converted to string in DatabaseStatementBase (Private Message integration)
Status: Reviewed & tested by the community » Closed (duplicate)

Closing as per #14

somatics’s picture

Hi,
I would really appreciate an answer to my question, in #15.

amitaibu’s picture

> and then finally Amitaibu concluded that it doesn't need to be fixed because it's already fixed in the Private Messages module.

Isn't that the answer? :)

somatics’s picture

Well, that's where I'm still confused -- since I'm still encountering the error, even without the Private Messages module enabled (and I thought dewolfe001 was also reporting his errors independent of the Private Messages module).

Thanks for your replies, and in advance for any further clarifications you can provide to me :)
Sorry to be so clueless about this matter.

betz’s picture

I can confirm the same problem.
I don't have privatemsg even in my installation, i tried with and without uuid (latest dev).

When i open admin/content/message i get

Recoverable fatal error: Object of class Message could not be converted to string in DatabaseStatementBase->execute() (line 2139 of /www/includes/database/database.inc).

I have locale and entity translation enabled, maybe this has to do something with it?

Tom

betz’s picture

Status: Closed (duplicate) » Active

reopening, as privatemsg has nothing to do with it.

betz’s picture

In views, i can see the message id's and timestamps, but when i add the rendered message as field, i get an error.

betz’s picture

Project: Message » Messaging

The changes to messaging module in comment #7 do work for me.
So moving this issue to messaging module...

dewolfe001’s picture

Like you, I didn't have PrivateMsg in the mix, so that has nothing to do with the actual issue. There were many reports from different sources about an error at line 2139. The function I made changes to had a problem because the input could not be parsed by function as it was.

somatics’s picture

Any chance there's progress on this?

We are completely unable to use Message module -- and so many other contrib modules are starting to rely on the Message module to provide best functionality. it really is handicapping our site.

amitaibu’s picture

Category: bug » support
Status: Active » Fixed

Just follow what's written in Message's homepage and get Private message --dev version.

somatics’s picture

Status: Fixed » Active

Hi, thanks for the quick response.

Unfortunately, we have been using the latest Dev version of Private Message module since we encountered this problem and filed this issue last November -- yet we have had this problem any time we have tried to use Message.

The current version of the Private Message module we have on our site is 7.x-1.3+10-dev (2013-May-24).

bramface’s picture

Another vote for #7.

antoinetooley’s picture

#7 worked for me. Thanks!

bramface’s picture

Getting this error when viewing a message after applying #7 above:

Messaging_Simple::load()
Warning: array_keys() expects parameter 1 to be array, string given

And am unable to delete the message. So: #7 not ready for prime time yet. Any ideas?

hanksterr7’s picture

# 7 worked for me. I have 7.x-1.0-alpha2+2-dev installed for messaging and messaging_simple_mail. I do not have Private Message installed.

File to touch was messaging/messaging_simple/messaging_simple.inc (not messaging/messaging_simple/messaging_simple.api as mentioned in #7).