Brand new Drupal 6.10 install, unpack Rules 6.x-1.x-dev 2009-Apr-11 and enable. Following errors seen:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE name = 'rules_example_1'' at line 1 query: DELETE FROM WHERE name = 'rules_example_1' in /Applications/MAMP/htdocs/drupal-6.10/sites/all/modules/rules/rules/rules.module on line 774.
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(name, data) VALUES ('rules_example_1', 'a:8:{s:5:\"#type\";s:4:\"rule\";s:4:\"#' at line 1 query: INSERT INTO (name, data) VALUES ('rules_example_1', 'a:8:{s:5:\"#type\";s:4:\"rule\";s:4:\"#set\";s:15:\"event_node_view\";s:6:\"#label\";s:59:\"Example rule: When viewing an unpublished page, publish it.\";s:7:\"#status\";s:6:\"custom\";s:11:\"#categories\";a:1:{i:0;s:7:\"example\";}s:7:\"#active\";i:0;s:11:\"#conditions\";a:2:{i:0;a:4:{s:5:\"#type\";s:9:\"condition\";s:5:\"#name\";s:36:\"rules_condition_content_is_published\";s:9:\"#settings\";a:1:{s:13:\"#argument map\";a:1:{s:4:\"node\";s:4:\"node\";}}s:7:\"#negate\";i:1;}i:1;a:3:{s:5:\"#type\";s:9:\"condition\";s:5:\"#name\";s:31:\"rules_condition_content_is_type\";s:9:\"#settings\";a:2:{s:13:\"#argument map\";a:1:{s:4:\"node\";s:4:\"node\";}s:4:\"type\";a:1:{i:0;s:4:\"page\";}}}}s:8:\"#actions\";a:1:{i:0;a:3:{s:5:\"#type\";s:6:\"action\";s:5:\"#name\";s:30:\"rules_core_node_publish_action\";s:9:\"#settings\";a:2:{s:13:\"#argument map\";a:1:{s:4:\"node\";s:4:\"node\";}s:9:\"auto_save\";b:1;}}}}') in /Applications/MAMP/htdocs/drupal-6.10/sites/all/modules/rules/rules/rules.module on line 775.
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE name = 'rules_set_1'' at line 1 query: DELETE FROM WHERE name = 'rules_set_1' in /Applications/MAMP/htdocs/drupal-6.10/sites/all/modules/rules/rules/rules.module on line 774.
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(name, data) VALUES ('rules_set_1', 'a:4:{s:5:\"label\";s:44:\"Example: Empty ru' at line 1 query: INSERT INTO (name, data) VALUES ('rules_set_1', 'a:4:{s:5:\"label\";s:44:\"Example: Empty rule set working with content\";s:9:\"arguments\";a:1:{s:4:\"node\";a:2:{s:4:\"type\";s:4:\"node\";s:5:\"label\";s:7:\"Content\";}}s:10:\"categories\";a:1:{i:0;s:7:\"example\";}s:6:\"status\";s:6:\"custom\";}') in /Applications/MAMP/htdocs/drupal-6.10/sites/all/modules/rules/rules/rules.module on line 775.
CommentFileSizeAuthor
#3 rules.admin-install.patch1.03 KBlyricnz

Comments

lyricnz’s picture

Note: the install above only does this when attempting to install both "Rules" and "Rules Administration UI" at the same time. It seems that the code in the latter is making some assumptions about the state of the system.

lyricnz’s picture

Title: Brand new install fails » Installing Rules + Rules Administration UI generates error messages

This is caused by the change applied in http://drupal.org/cvs?commit=190672 intended to fix #300729: Investigate default/example rules & rule set installation type. The problem is that the "fake" rules_item_info doesn't contain $info['db_table'].

function rules_item_save($item_type, $name, $item) {
  error_log("rules_item_save($item_type, $name, $item)");
  if ($info = rules_get_items($item_type)) {
    db_query("DELETE FROM {". $info['db_table']. "} WHERE name = '%s'", $name);
    db_query("INSERT INTO {". $info['db_table']. "} (name, data) VALUES ('%s', %b)", $name, serialize($item));
  }
}

function rules_get_items($key = 'all') {
  // During module installation, the hook implementation of rules is not invoked,
  // as the module is not yet active. So we force it here to always return our own item infos.
  return !module_exists('rules') ? rules_rules_item_info() : rules_gather_data('rules_item_info', $key);
}

function rules_rules_item_info() {
  return array(
    'rules' => array(
      'label' => t('Rules'),
      'db_table' => 'rules_rules',
      'base' => 'rules_item_rule',
    ),
    'rule_sets' => array(
      'label' => t('Rule Sets'),
      'db_table' => 'rules_sets',
      'base' => 'rules_item_rule_set',
    ),
  );
}

Note: in order to be able to test this properly, you need to delete from {system}, since Rules Administration UI doesn't support uninstallation.

lyricnz’s picture

Status: Active » Needs review
StatusFileSize
new1.03 KB

I think the problem is just that rules_get_items() is not checking $key when it uses rules_rules_item_info() to get the information. See attached patch.

fago’s picture

Status: Needs review » Fixed

oh, indeed - committed. Thanks for catching this one!

Status: Fixed » Closed (fixed)

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

mitchell’s picture

Component: Miscellaneous » Rules Core

Updated component.