Closed (fixed)
Project:
Privatemsg
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 Nov 2011 at 13:53 UTC
Updated:
1 Mar 2014 at 15:47 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
ronald_istos commentedCame across this error myself. The problem pops up when you have the two modules activated because of a namespace collision that makes Drupal think that Private Message's entity load function is a hook to call when Message loads an entity as well :-)
Private message has an entity load function as
privatemsg_message_loadwhile Message has
message_load.This namespace affinity makes privatemsg_message_load fire whenever a Message entity loads with ensuing hilarity.
Now the problem is really Private Message's - one should avoid function names that can cause this problems. A larger issue is whether Drupal core should check these things - or maybe Coder.
Will post in Private Message with a short term patch - long term solution is to change the function name.
Comment #2
jbrown commentedtagging
Comment #3
davidcsonka commentedDid you ever post in the PrivateMsg issues queue? Can you list the issue link here so I can check on it?
Comment #4
berdyshev commentedI have debbuged this problem and find the place where it fails.
Handler for views (message_handler_field_message_render) calls
message_load()function inincludes/views/message_handler_field_message_render.inc:75. This will call theattachLoad()method of theDrupalDefaultEntityControllerclass. In this method there is such code (includes/entity.inc:332):where
$this->entityInfo['load hook']is equal tomessage_load. So, theprivatemsg_message_load()function will be called.As solution,
privatemsg_message_load()function should be renamed to something likeprivatemsg_msg_load(). But this will cause changes in privatemsg's API and I don't sure if this is possible.But I have attached patch which is applying this renaming to privatemsg module.
Comment #6
berdyshev commentedComment #7
berdyshev commented#4: privatesmg_1355342_renaming-private_message_load-and-private_message_load_muliple-4.patch queued for re-testing.
Comment #8
berdyshev commentedand here it's the patch for the latest dev version of the 2.x branch
Comment #9
berdyshev commentedchanged version
Comment #11
berdyshev commentedrenaming applied to the test files.
Comment #13
berdirThis doesn't make sense. I see the problem, but things aren't abbreviated like that in Drupal and there is much more that is called privatemsg_message, like all of our hooks, the privatemsg_message entity and more.
There is a much simpler solution for this problem. Add a check to that function that looks if the argument is an object and if so, do nothing.
Comment #14
berdyshev commentedOh, sorry, I was trying to fix this issue globally and missed this simple solution.
Patch attached.
Comment #15
berdirYeah, that's much more sane :)
Let's format that comment according to the guidelines (first character upper case, no longer than 80 characters, end with a "." and I'm happy to commit this change.
See http://drupal.org/node/1354#inline
Comment #16
berdyshev commentedThanks for review. revised patch attached.
Comment #17
omar commented#14: privatemsg_1355342_fixing-conflict-with-message-module_14.patch queued for re-testing.
Comment #18
Michsk commentedThis does not fix it. The following error keeps appearing http://drupal.org/node/1659228
Comment #19
Michsk commentedDon't we also need something for
privatemsg_message_load_multiple(). Since the Message module also usesmessage_load_multiple(array_keys($check_mids);.Comment #20
berdirNo, there is no such hook. Commited the patch, fix looks valid to me. If you still experience this issue, please reopen with a detailed error report (backtrace).
Comment #22
ajmartin commentedWill this patch be committed to version 7.x-1.3, or is the 2.x-dev stable enough for a production site?
Comment #23
berdirIt has been commited to 7.x-1.x-dev. Fixed releases are never updated.
Comment #24
ajmartin commentedGreat. Thanks for clarifying. I assume it will be part of 7.x-1.4 when that's released.
Comment #25
snehi commented#16 works for me
Thanks for the patch :)
Comment #26
Anonymous (not verified) commentedThank you for this patch. #16 worked for me, too!
Comment #27
maximpodorov commented@Berdir
Please make a new stable release (7.x-1.4) with this fix. We need it badly. :)
Comment #28
kalistos commentedYes, please, make new stable release for 7.x-1.x.
A lot of people are faced with this problem #1851478-13: Object of class Message could not be converted to string in DatabaseStatementBase (Private Message integration)
Comment #29
Connoropolous commentedThanks so much for this. #16 worked like a charm.
Comment #30
Anonymous (not verified) commentedWe ran into this problem as well with commerce sp paypal module since it relies on the message module. in the process of testing with 7.x-1.4 version of private message.
And to clarify: the problem is caused by private message inadvertently implementing the core hook_TYPE_load (see entity.inc around line 350). core entity supports 2 hooks:
- hook_entity_load
- hook_TYPE_load
and unfortunately the message module defines an entity of type "message"
Seems best practise is to never use _load as the end of a function name.