After having saved an Activity Log rule ("Log activity for the acting user") with the CCK token for an imagefield ([node:field_image-filefield-view]) I get the following warning:

warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /Users/thomascermak 2/Sites/log/includes/database.mysql.inc on line 329.

Also, activity logs for any content type that contain the CCK imagefield will not display in the "activities" (activity log) view as long as their rule contains the mentioned imagefield token. I will test to see if I can duplicate this with other tokens today.

Comments

icecreamyou’s picture

Status: Active » Postponed (maintainer needs more info)

Can you put this code before line 329 in database.mysql.inc so we can see what is triggering that error?

  if (is_array($text)) {
    drupal_set_message(print_r($text, TRUE)); // dsm() is nicer than drupal_set_message(print_r()) if you have devel installed
  }
pribeh’s picture

Array ( [web] => web ) is what gets printed. I'm not sure what's up but to be even clearer I'm getting this after saving any default Activity Log rule regardless whether I change it. So, if I save a pre-existing rule without making any changes I get the same result (with both vanilla and non-vanilla setups).

icecreamyou’s picture

Interesting. Line 419 of activity_log.rules.inc should be this:


'display_type' => $v['display_type'],

Try changing it to this:


'display_type' => reset($v['display_type']),

I think that should make new Rules work but it might cause other problems with default Rules. But it's mysterious why the display type would be an array -- its value comes from a select list which should only return a single value.

pribeh’s picture

Seems to fix this issue at least. Lets' hope it won't cause too many other ones.

pribeh’s picture

Wait a sec. I'm still getting the same warning every time I try to flush the cache (after having changed the respective lines you mentioned). Also:

- whenever I flush the activity log cache the logs for nodes (probably those rules that I've resaved) disappear. Plus, I get the same warning.
- then, if I try to regenerate the activity log I get the following:

2 activity messages generated for the event After saving new content.
0 activity messages generated for the event User subscribes to group.
2 activity messages generated for the event User saves a status.
Finished regenerating activity messages.

- However, the activity log view still does not show the node logs. Clearing cache again does not change this.
- then, as soon as I resave one of the elements of the rule for the activity log for nodes returns (is displayed within the activity log view).

pribeh’s picture

Whenever attempting to save an Activity Log rule ("Log activity when a node is created") using the latest August 6th dev of Activity Log, on a vanilla Drupal install, I get the following warning:

mysql_real_escape_string() expects parameter 1 to be string, array given in /Users/thomascermak 2/Sites/log/includes/database.mysql.inc on line 333.

Along with:

Array ( [web] => web )

I also can't get it to display CCK file tokens after adding them. I'm experiencing pretty much the same symptoms.

pribeh’s picture

Hmm, I'm not experiencing any of the bugs I'm reporting here running Activity Log within the very latest beta of Drupal Commons out of the box. I'm going to copy over the entire module suite from Drupal Commons into a vanilla site, turn on all the modules that come switched on with Drupal Commons install, see if that gets rid of the errors, then turn them off one by one to see if this is related to an undeclared dependency.

icecreamyou’s picture

Well your error about call_user_func_array() is almost certainly related to an accidental dependency. However I'm really not sure why that would still come up since there should be code that checks for those situations.

The particular error this issue is about is much more mysterious. You should be getting a string; that's what a "select" form element returns. I'm not sure why it would be happening.

pribeh’s picture

Well, I have a dilema. I'm not sure the mysql.inc on line 333 is actually caused by a CCK token inserted into a Activity Log rule. I get it trying to clear the cache no matter what. I don't seem to get this warning anywhere else anymore though.

icecreamyou’s picture

Clearing which cache? Just the general Drupal cache or the "Clear all message caches" button at admin/settings/activity_log?

pribeh’s picture

Just the Activity Log cache.

icecreamyou’s picture

Hmm, well this is with your custom rule though right? So it would be the same problem as when creating the rule -- it's expecting a string and getting an array. Still not sure why that would occur.

pribeh’s picture

Hi Ice, I think there might be some sort of dependency on Organic Groups. I'll try to give it another go today, but I've been trying to duplicate Commons' module setup and configuration to try and isolate any dependency. Twice now, I've removed this warning and resolved the regeneration issue by not simply switching on OG but actually setting up a base OG node type ("group").

icecreamyou’s picture

Is this still a problem? And is #1247490: Regeneration of Rules "with" Custom CCK Token Broken the same issue?

pribeh’s picture

Status: Postponed (maintainer needs more info) » Fixed

Let's close this. I'm not experiencing this anymore.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

adixb’s picture

I can confirm that the 'reset' line fixed a problem I encountered when using facebook_status (fbss) module. That module creates some custom rules which were not working until I added this fix.

eidoscom’s picture

I added

if (is_array($v['display_type'])){
      $v['display_type'] = reset($v['display_type']);
    }

to the function _activity_log_rebuild_templates() before the construction of $record array and all the errors gone out. Never more shows the warnings and the activity logs stop desapearing on the activities page.

The desapearing issue is because if try to update the database when 'display_type' is an array, the default value 'web' doesn't stores to the database. On views, the default query is using " 'display_type = 'web' ", so a blank value causes no selection of the activity message.

It's not the solution, but let me work without alerts/warnings and is working.