From fbccce51c617d817210c1bdcba5adc582624a8ae Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 5 Sep 2008 09:29:06 +0000 Subject: - Patch #261859 by rse, Damien Tournoud: make the trigger module work on PostgreSQL. --- includes/actions.inc | 14 +++++++------- modules/system/system.module | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/actions.inc b/includes/actions.inc index 611618c8a..0aaa972c6 100644 --- a/includes/actions.inc +++ b/includes/actions.inc @@ -52,7 +52,7 @@ function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a $where_values = array(); foreach ($action_ids as $action_id) { if (is_numeric($action_id)) { - $where[] = 'OR aid = %d'; + $where[] = "OR aid = '%s'"; $where_values[] = $action_id; } elseif (isset($available_actions[$action_id])) { @@ -91,7 +91,7 @@ function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a else { // If it's a configurable action, retrieve stored parameters. if (is_numeric($action_ids)) { - $action = db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = %d", $action_ids)); + $action = db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = '%s'", $action_ids)); $function = $action->callback; $context = array_merge($context, unserialize($action->parameters)); $result[$action_ids] = $function($object, $context, $a1, $a2); @@ -236,7 +236,7 @@ function actions_function_lookup($hash) { } // Must be an instance; must check database. - $aid = db_result(db_query("SELECT aid FROM {actions} WHERE MD5(aid) = '%s' AND parameters != ''", $hash)); + $aid = db_result(db_query("SELECT aid FROM {actions} WHERE MD5(aid) = '%s' AND parameters <> ''", $hash)); return $aid; } @@ -323,7 +323,7 @@ function actions_synchronize($actions_in_code = array(), $delete_orphans = FALSE function actions_save($function, $type, $params, $desc, $aid = NULL) { $serialized = serialize($params); if ($aid) { - db_query("UPDATE {actions} SET callback = '%s', type = '%s', parameters = '%s', description = '%s' WHERE aid = %d", $function, $type, $serialized, $desc, $aid); + db_query("UPDATE {actions} SET callback = '%s', type = '%s', parameters = '%s', description = '%s' WHERE aid = '%s'", $function, $type, $serialized, $desc, $aid); watchdog('actions', 'Action %action saved.', array('%action' => $desc)); } else { @@ -331,7 +331,7 @@ function actions_save($function, $type, $params, $desc, $aid = NULL) { // separate table for numeric aids. db_query('INSERT INTO {actions_aid} VALUES (default)'); $aid = db_last_insert_id('actions_aid', 'aid'); - db_query("INSERT INTO {actions} (aid, callback, type, parameters, description) VALUES (%d, '%s', '%s', '%s', '%s')", $aid, $function, $type, $serialized, $desc); + db_query("INSERT INTO {actions} (aid, callback, type, parameters, description) VALUES ('%s', '%s', '%s', '%s', '%s')", $aid, $function, $type, $serialized, $desc); watchdog('actions', 'Action %action created.', array('%action' => $desc)); } @@ -348,7 +348,7 @@ function actions_save($function, $type, $params, $desc, $aid = NULL) { * The appropriate action row from the database as an object. */ function actions_load($aid) { - return db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = %d", $aid)); + return db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = '%s'", $aid)); } /** @@ -358,6 +358,6 @@ function actions_load($aid) { * integer The ID of the action to delete. */ function actions_delete($aid) { - db_query("DELETE FROM {actions} WHERE aid = %d", $aid); + db_query("DELETE FROM {actions} WHERE aid = '%s'", $aid); module_invoke_all('actions_delete', $aid); } diff --git a/modules/system/system.module b/modules/system/system.module index 4a9053c1f..005d21a89 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1492,7 +1492,7 @@ function system_actions_manage() { } $row = array(); - $instances_present = db_fetch_object(db_query("SELECT aid FROM {actions} WHERE parameters != ''")); + $instances_present = db_fetch_object(db_query("SELECT aid FROM {actions} WHERE parameters <> ''")); $header = array( array('data' => t('Action type'), 'field' => 'type'), array('data' => t('Description'), 'field' => 'description'), @@ -1596,7 +1596,7 @@ function system_actions_configure($form_state, $action = NULL) { if (is_numeric($action)) { $aid = $action; // Load stored parameter values from database. - $data = db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = %d", intval($aid))); + $data = db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = '%s'", $aid)); $edit['actions_description'] = $data->description; $edit['actions_type'] = $data->type; $function = $data->callback; -- cgit v1.2.3