I again have received the following error.

Fatal error: Unsupported operand types in /var/www/construction/sites/all/modules/rules/rules/rules.admin_rule_proxy.inc on line 26

The token actions module is not installed. I am updated to the latest releases for both rules and token modules.

My local install works just fine which is running mysql. The server I'm working on is postgresql so I'll be doing a little more testing to compare what exactly is going on. Like i noted in http://drupal.org/node/322242 it appears the data is not being serialized or unserialized correctly. Because when it goes to add that data into the $configurations array in these lines

    $configurations[$item_type] = array();
    while ($row = db_fetch_object($result)) {
      $configurations[$item_type][$row->name] = unserialize($row->data);
    }

$row->data does have serialized information.. but after calling unserialize on it I end up with an empty array.

I'll report back here the differences between the mysql and postgresql implementations.

Comments

agn507’s picture

Component: Rules Core » Rules Engine

I created identical rules in a mysql and postgresql environment.

I added a print_r on around line 1017 of rules.module

    while ($row = db_fetch_object($result)) {
	    	print_r($row);
      $configurations[$item_type][$row->name] = unserialize($row->data);
    }

so i could evaluate what the data looks like before its being unserialized.
The mysql install contains this

stdClass Object
(
    [name] => rules_1
    [data] => a:8:{s:5:"#type";s:4:"rule";s:4:"#set";s:17:"event_node_insert";s:6:"#label";s:18:"Send contact email";s:7:"#active";i:1;s:7:"#weight";s:1:"0";s:7:"#status";s:6:"custom";s:11:"#conditions";a:1:{i:0;a:5:{s:5:"#type";s:9:"condition";s:9:"#settings";a:2:{s:4:"type";a:1:{s:7:"contact";s:7:"contact";}s:13:"#argument map";a:1:{s:4:"node";s:4:"node";}}s:5:"#name";s:31:"rules_condition_content_is_type";s:5:"#info";a:3:{s:5:"label";s:26:"created content is Contact";s:9:"arguments";a:1:{s:4:"node";a:2:{s:4:"type";s:4:"node";s:5:"label";s:7:"Content";}}s:6:"module";s:4:"Node";}s:7:"#weight";d:0;}}s:8:"#actions";a:1:{i:0;a:5:{s:7:"#weight";d:0;s:5:"#info";a:3:{s:5:"label";s:39:"Show a configurable message on the site";s:6:"module";s:6:"System";s:10:"eval input";a:1:{i:0;s:7:"message";}}s:5:"#name";s:27:"rules_action_drupal_message";s:9:"#settings";a:3:{s:7:"message";s:77:"Title: [node:title-raw]<br />
NID: [node:nid]<br />
Type: [node:type]<br />";s:5:"error";i:0;s:11:"#eval input";a:1:{s:27:"token_rules_input_evaluator";a:1:{s:7:"message";a:1:{i:0;s:4:"node";}}}}s:5:"#type";s:6:"action";}}}
)

The postgresql install outputted this

stdClass Object
(
    [name] => rules_1
    [data] => a:8:{s:5:"#type";s:4:"rule";s:4:"#set";s:17:"event_node_insert";s:6:"#label";s:18:"Send contact email";s:7:"#active";i:1;s:7:"#weight";s:1:"0";s:7:"#status";s:6:"custom";s:11:"#conditions";a:1:{i:0;a:5:{s:5:"#type";s:9:"condition";s:9:"#settings";a:2:{s:4:"type";a:1:{s:7:"contact";s:7:"contact";}s:13:"#argument map";a:1:{s:4:"node";s:4:"node";}}s:5:"#name";s:31:"rules_condition_content_is_type";s:5:"#info";a:3:{s:5:"label";s:26:"created content is Contact";s:9:"arguments";a:1:{s:4:"node";a:2:{s:4:"type";s:4:"node";s:5:"label";s:7:"Content";}}s:6:"module";s:4:"Node";}s:7:"#weight";d:0;}}s:8:"#actions";a:1:{i:0;a:5:{s:7:"#weight";d:0;s:5:"#info";a:3:{s:5:"label";s:39:"Show a configurable message on the site";s:6:"module";s:6:"System";s:10:"eval input";a:1:{i:0;s:7:"message";}}s:5:"#name";s:27:"rules_action_drupal_message";s:9:"#settings";a:3:{s:7:"message";s:77:"Title: [node:title-raw]<br />\015\012NID: [node:nid]<br />\015\012Type: [node:type]<br />";s:5:"error";i:0;s:11:"#eval input";a:1:{s:27:"token_rules_input_evaluator";a:1:{s:7:"message";a:1:{i:0;s:4:"node";}}}}s:5:"#type";s:6:"action";}}}
)

The only differences I can see is after the "\015\012" which are where the line breaks are... where i actually hit enter to move to a new line.

It seems the postgresql install is handling it differently possibly causing the unserialize function to fail. I will try and put everything on one line and see if it makes a difference at all.

agn507’s picture

The problem seems to be related to newlines and possibly spaces in the body of the message. I removed all of them so everything was on one line and it worked just fine. Keep in mind this only happens when using postgresql and I believe it has something to do with it converting the newlines to "\015\012"

fago’s picture

Title: Fatal error - Not using token actions » postgresql: Fatal error when loading rules from db

hm, that's strange.

I had a look at the definition of the data field, it's a blob field like the field of the cache table. So if there is such a problem, I wonder if it also occurs in other cases? E.g. the variable cache is also stored in such a value and should also contain e-mail texts (e.g. the user registration mails). I assume you don't have any troubles with this?
Then what if you enter some newlines in another configuration, let's take the php-action. Can you use line-endings there?

Thanks for investigating this, unfortunately I have no test-install with postgresql.

spydmobile’s picture

confirmed this behaviour on my pgsql installs

hawk259’s picture

Having same issue with my postgres install.

I manually updated the rule via psql and remove the all the \015\012 and it is working, but of course my email has only one line.

Also rules table looks like this:

                        Table "public.rules_rules"
 Column |          Type          |               Modifiers                
--------+------------------------+----------------------------------------
 name   | character varying(255) | not null default ''::character varying
 data   | bytea                  | 
Indexes:
    "rules_rules_pkey" PRIMARY KEY, btree (name)

while variable looks like this:

                         Table "public.variable"
 Column |          Type          |               Modifiers                
--------+------------------------+----------------------------------------
 name   | character varying(128) | not null default ''::character varying
 value  | text                   | not null
Indexes:
    "variable_pkey" PRIMARY KEY, btree (name)

The rules data field is bytea, while the variables fields is text. Could this be the problem?

hawk259’s picture

Here is a patch that fixes the problem:

--- rules.module.orig	Tue Dec 16 08:26:58 2008
+++ rules.module	Tue Dec 16 08:27:03 2008
@@ -1016,7 +1016,7 @@
 
     $configurations[$item_type] = array();
     while ($row = db_fetch_object($result)) {
-      $configurations[$item_type][$row->name] = unserialize($row->data);
+      $configurations[$item_type][$row->name] = unserialize(db_decode_blob($row->data));
     }
     //add not altered default items
     $configurations[$item_type] += rules_get_item_defaults($item_type);
fago’s picture

Status: Active » Fixed

ah one should decode the blob.. good to know!
thanks, I've committed that.

Status: Fixed » Closed (fixed)

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