fetchField(); if (!$path_to_rules_query) { print 'Rules module not found in the database.'; exit(); } // Strip the filename off the end so we have the actual path $path_to_rules = str_replace('/rules.module', '', $path_to_rules_query); // Actual display text $disp = ''; // Values that should be there but might not be $rules_info = array( 'RulesActionHandlerBase' => array('name' => 'RulesActionHandlerBase', 'type' => 'class', 'filename' => $path_to_rules . '/includes/rules.core.inc'), 'RulesActionHandlerInterface' => array('name' => 'RulesActionHandlerInterface', 'type' => 'interface', 'filename' => $path_to_rules . '/includes/rules.core.inc'), 'RulesConditionHandlerBase' => array('name' => 'RulesConditionHandlerBase', 'type' => 'class', 'filename' => $path_to_rules . '/includes/rules.core.inc'), 'RulesConditionHandlerInterface' => array('name' => 'RulesConditionHandlerInterface', 'type' => 'interface', 'filename' => $path_to_rules . '/includes/rules.core.inc'), 'RulesDataInputOptionsListInterface' => array('name' => 'RulesDataInputOptionsListInterface', 'type' => 'interface', 'filename' => $path_to_rules . '/ui/ui.data.inc'), 'RulesDataUIBundleEntity' => array('name' => 'RulesDataUIBundleEntity', 'type' => 'class', 'filename' => $path_to_rules . '/ui/ui.data.inc'), 'RulesEventDefaultHandler' => array('name' => 'RulesEventDefaultHandler', 'type' => 'class', 'filename' => $path_to_rules . '/includes/rules.event.inc'), 'RulesEventDispatcherInterface' => array('name' => 'RulesEventDispatcherInterface', 'type' => 'interface', 'filename' => $path_to_rules . '/includes/rules.event.inc'), 'RulesEventDispatcherTestCase' => array('name' => 'RulesEventDispatcherTestCase', 'type' => 'class', 'filename' => $path_to_rules . '/tests/rules.test'), 'RulesEventHandlerBase' => array('name' => 'RulesEventHandlerBase', 'type' => 'class', 'filename' => $path_to_rules . '/includes/rules.event.inc'), 'RulesEventHandlerEntityBundle' => array('name' => 'RulesEventHandlerEntityBundle', 'type' => 'class', 'filename' => $path_to_rules . '/includes/rules.event.inc'), 'RulesEventHandlerInterface' => array('name' => 'RulesEventHandlerInterface', 'type' => 'interface', 'filename' => $path_to_rules . '/includes/rules.event.inc'), 'RulesNodeConditionBase' => array('name' => 'RulesNodeConditionBase', 'type' => 'class', 'filename' => $path_to_rules . '/modules/node.eval.inc'), 'RulesNodeConditionPromoted' => array('name' => 'RulesNodeConditionPromoted', 'type' => 'class', 'filename' => $path_to_rules . '/modules/node.eval.inc'), 'RulesNodeConditionPublished' => array('name' => 'RulesNodeConditionPublished', 'type' => 'class', 'filename' => $path_to_rules . '/modules/node.eval.inc'), 'RulesNodeConditionSticky' => array('name' => 'RulesNodeConditionSticky', 'type' => 'class', 'filename' => $path_to_rules . '/modules/node.eval.inc'), 'RulesNodeConditionType' => array('name' => 'RulesNodeConditionType', 'type' => 'class', 'filename' => $path_to_rules . '/modules/node.eval.inc'), 'RulesPluginHandlerBase' => array('name' => 'RulesPluginHandlerBase', 'type' => 'class', 'filename' => $path_to_rules . '/includes/rules.core.inc'), 'RulesPluginHandlerInterface' => array('name' => 'RulesPluginHandlerInterface', 'type' => 'interface', 'filename' => $path_to_rules . '/includes/rules.core.inc'), 'RulesUICategory' => array('name' => 'RulesUICategory', 'type' => 'class', 'filename' => $path_to_rules . '/ui/ui.core.inc'), ); // Just the names of the missing classes / interfaces $values_needed = array_keys($rules_info); // Find out which values currently do exist in the database $values_existing = db_query("SELECT r.name FROM {registry} r WHERE r.module = 'rules'")->fetchAll(); // Save values from $values_existing for later comparison if ($values_existing) { foreach ($values_existing as $value_existing) { $values_compare[] = $value_existing->name; } } // Find the difference between what we need and what already exists $values_diff = array_diff($values_needed, $values_compare); // Assign info from $rules_info to $values_insert if we have a match $values_insert = array(); if (!empty($values_diff)) { foreach ($values_needed as $value_needed) { if (in_array($value_needed, $values_diff)) { $values_insert[] = $rules_info[$value_needed]; $output[0][] = $rules_info["{$value_needed}"]; } } } // First row of output $disp .= ''; for ($i = 0; $i < count($output[0]); $i++) { $disp .= ''; } $disp .= ''; // Assign values to compare against later on to see if any changes were made, and then // make the changes $values_verify = array(); if (!empty($values_insert)) { foreach ($values_insert as $value_insert) { $values_verify[] = $value_insert['name']; $output[1][] = 'Missing'; db_insert('registry') ->fields(array( 'name' => $value_insert['name'], 'type' => $value_insert['type'], 'filename' => $value_insert['filename'], 'module' => 'rules', 'weight' => 20, )) ->execute(); } } // Second row of output $disp .= ''; for ($j = 0; $j < count($output[1]); $j++) { $disp .= ''; } $disp .= ''; // Perform the query again to see if our values were inserted correctly $values_existing_fetch_new = db_query("SELECT r.name FROM {registry} r WHERE r.module = 'rules'")->fetchAll(); $values_existing_new = array(); if ($values_existing_fetch_new && !empty($values_existing_fetch_new)) { foreach ($values_existing_fetch_new as $value_existing_fetch_new) { $values_existing_new[] = $value_existing_fetch_new->name; } } // If everything went well, create the third row of the output if (!empty($values_existing_new) && !empty($values_verify)) { foreach ($values_verify as $value_verify) { if (in_array($value_verify, $values_existing_new)) { $output[2][] = 'Fixed'; } } } $disp .= ''; for ($k = 0; $k < count($output[2]); $k++) { $disp .= ''; } $disp .= ''; // Last parts of the output text $disp .= '
' . $output[0][$i]['name'] . '
' . $output[1][$j] . '
' . $output[2][$k] . '
'; $disp .= '

IF EACH COLUMN SAYS FIXED IN THE BOTTOM ROW, PLEASE TRY YOUR SITE AGAIN AND IF IT IS WORKING NOW, DELETE THIS FILE FROM YOUR SERVER.

'; print $disp; ?>