Posted by Boobaa on November 2, 2011 at 7:37am
20 followers
| Project: | Messaging |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
Using messaging-6.x-2.4 and token-6.x-1.17, I am getting these:
warning: preg_match_all() expects parameter 2 to be string, array given in …/sites/all/modules/contrib/token/token.module on line 701.
This is related to the fact that messaging uses token_replace_multiple() in a way that was never supported (see #1307890: token_replace() performance when there are no tokens).
Comments
#1
Attached is a patch to solve this.
#2
+++ messaging.module 2011-11-02 08:32:26.896992847 +0100@@ -896,9 +896,21 @@ function messaging_text_replace($text, $
+ if (is_array($text)) {
+ foreach ($text as &$line) {
+ $line = token_logic_replace_multiple($line, $objects);
Note that this foreach by reference is not supported on PHP 4. Is PHP 5 a dependency for Messaging? It doesn't look like it in the .info file.
#3
Patch updated to avoid foreach by reference.
#4
Thanks - that patch sorted out my problems...
#5
token_logic accepts array $text argument
https://devseed.svn.cvsdude.com/sandbox/drupal-6/token_logic/token_logic...
#6
Marked #1336892: token replacement doesn't work for e-mail notifications after latest update as duplicate.
#7
I've committed a much cleaner (IMHO) version of #3 to 6.x-2.x and 6.x-4.x:
http://drupal.org/commitlog/commit/5046/4cb5f834e1b36b3e3df1f986fccf8826...
http://drupal.org/commitlog/commit/5046/e6012b401e8edbcd4e2457cc437ffaa6...
Please try the development releases that roll tonight and make sure that these work.
#8
I can confirm that the problem is solved in dev.
#9
This is marked as "fixed", but it's only fixed in the dev version. Shouldn't this remain open until the fix has been made in production? I don't feel comfortable putting a dev module on my production sites.
Thanks.
#10
'Fixed' is the appropriate status. A new release might be warranted, but I think that would be webflo's call... he's the only maintainer who has access to both Notifications and Messaging AFAIK.
You can always apply the appropriate patch to your otherwise stable release. Just follow the links I posted, click on the commit number to view the changes, and click 'patch'. For instance, here's the patch for 6.x-4.x: http://drupalcode.org/project/messaging.git/patch/e6012b4
#11
Thanks Dane,
I don't know how to apply patches, tried searching for a how-to, but never found one. If you have a link to such a thing I'd be grateful.
#12
@Steel Rat: it depends on your working environment. If you have Git, just go to the root directory of the messaging module and run
git apply -v [patchname.patch].If you are using Drush Make files to build your site (which I HIGHLY recommend), you can just include lines like the following:
projects[messaging][version] = 2.4projects[messaging][patch][] = http://drupalcode.org/project/messaging.git/patch/e6012b4
#13
I don't have git or drush but I do have this problem.
Is 6.x-2.x-dev 2011-Nov-12 safe to use without any other consequences?
#14
@Vayira - I can't really say, I don't use 6.x-2.x. Looking through the commit history for the 2.x branch might help you determine if it's safe. I would also recommend learning how to apply patches - if you Google it you'll find plenty of info. Git/Drush aren't necessarily required, although I'd recommend checking them out as well.
#15
I'm using 2.x versión in a production drupal with 23 sites and it's working fine with no related issues from my users (more than 2000)
#16
I have only had the issue on Forum, the patch worked. Thank you.
#17
I tried running "patch" which I already had installed in my ubuntu but it didn't like that file. In the end I just patched it by hand removed the two wrong lines & pasted in the others. It seemed less work than installing programs, learning how to use them etc etc.
I didn't get any error messages but messages were blank so I installed the dev version & that seems to work for me.
#18
Looks like the patch is fairly small, so I'll do it by hand as Vayira did. I do appreciate the help, though.
#19
Ok, I'm confused (big surprise there!).
The patch here: http://drupalcode.org/project/messaging.git/patch/e6012b4 appears to be for messaging_template.module, not messaging.module. The lines to delete don't exist in the version I've got, 6.x-2.4
What am I missing?
#20
Never mind. I eventually found the 6.x-2.4 patch by clicking through the commit link higher up the thread. I've manually made the patch and all seems well in the universe.
Sorry for my confusion and clogging up the issue!
Thanks !!!
Jeff
#21
I changed version as the fix is not done in 6.x-2.4 which confuses people.
(I'd like to make it critical as our open atrium is now behaving badly)
The commit from http://drupalcode.org/project/messaging.git/commitdiff/e6012b401e8edbcd4... is bad code
<?php$text[$part] = call_user_func_array($function, $param_arr);
?>
and not inline with the patch from #3
I suppose this is to obfuscate reviewers :p
But seriously it is neither clear nor useful. Performance wise it's bad too.
+++ messaging.module 2011-11-04 10:32:32.912570145 +0100@@ -896,9 +896,21 @@ function messaging_text_replace($text, $
+ $text[$no] = token_logic_replace_multiple($line, $objects);
This code is much better.
So 'needs work'.
#22
Can anyone explain what is the current status of this?
The 6.x-2.x-dev release fixes the watchdog messages for us.
But comment #21 raises questions.
#23
I am running OpenAtrium 1.2 with everything up to date. Messaging.module is 6.x-2.4.
I am getting the following error when posting blog with notification:
I tried applying #3 above -- the patch: http://drupal.org/files/messaging-1329024-3.patch.
I also tried #7 above --http://drupalcode.org/project/messaging.git/blobdiff/d7b0e675e8e47dd1a8be30a1830ec2031d84d987..4cb5f83:/messaging.module
No luck with either one.
Haven't tried message.template changes mentioned above as the discussion seems to indicate that the problem must be in messaging.modules.
Still getting same notice x3 for each blog post with notifications.
Other suggestions?
#24
eric_sea
It's only a user notice. I think token module is only giving you a warning but everything is ok... Just hide theses warning.
#25
@dblais this is a real API change done by token module.
See #1327960: Invalid use of token_replace API - causes preg_match_all errors in token module #27 http://drupal.org/node/1327960#comment-5220700 where Dave Reid explains his err.
See also http://drupal.org/project/issues/token?text=called+token+replacement+wit...
So messaging needs to fix this.
Set to needs review as a developer needs to check why patch versus commit do not match as commented in #21 :)
#26
I'm sorry, but I'm pretty confused by all of the different posts, etc. as I have no clue as to how to apply patches. Not that I would want to do this on a production site anyway, but my users are asking for some kind of fix to get rid of all of the MySQL errors being triggered on the site whenever content is generated (because of notices being sent). Is the current dev release the one we're supposed to be using to get rid of this problem?
#27
@Irene Kraus
For information about patches in general (outdated but I think still relevant) see: https://drupal.org/node/60108
Without checking: You should be able to hide the message here: /admin/settings/error-reporting which I think is generally a good idea for production sites. However I am not sure weather this applies to this message.