rules for php 7.4 which is on ubuntu 20. May also need this version of rules for php7.2. Base off of Development version: 7.x-2.x-dev updated 15 Mar 2020 at 21:52 UTC
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

225 lines
6.4 KiB

<?php
/**
* @file
* Rules Scheduler - Installation file.
*/
/**
* Implements hook_schema().
*/
function rules_scheduler_schema() {
$schema['rules_scheduler'] = array(
'description' => 'Stores scheduled tasks.',
'fields' => array(
'tid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => "The scheduled task's id.",
),
'config' => array(
'type' => 'varchar',
'length' => '64',
'default' => '',
'not null' => TRUE,
'description' => "The scheduled configuration's name.",
),
'date' => array(
'description' => 'The Unix timestamp of when the task is to be scheduled.',
'type' => 'int',
'not null' => TRUE,
),
'data' => array(
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
'description' => 'The whole, serialized evaluation data.',
),
'identifier' => array(
'type' => 'varchar',
'length' => '255',
'default' => '',
'not null' => FALSE,
'description' => 'The user defined string identifying this task.',
),
'handler' => array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
'description' => 'The fully-qualified class name of the queue item handler.',
),
),
'primary key' => array('tid'),
'indexes' => array(
'date' => array('date'),
),
'unique key' => array(
'id' => array('config', 'identifier'),
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function rules_scheduler_install() {
// Create the queue to hold scheduled tasks.
$queue = DrupalQueue::get('rules_scheduler_tasks', TRUE);
$queue->createQueue();
}
/**
* Implements hook_uninstall().
*/
function rules_scheduler_uninstall() {
// Clean up after ourselves by deleting the queue and all items in it.
$queue = DrupalQueue::get('rules_scheduler_tasks');
$queue->deleteQueue();
}
/**
* Upgrade from Rules scheduler 6.x-1.x to 7.x.
*/
function rules_scheduler_update_7200() {
// Rename the old table so we can keep its content and start over with a
// fresh one.
db_rename_table('rules_scheduler', 'rules_scheduler_d6');
// Create the d7 table.
$schema['rules_scheduler'] = array(
'description' => 'Stores scheduled tasks.',
'fields' => array(
'tid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => "The scheduled task's id.",
),
'config' => array(
'type' => 'varchar',
'length' => '255',
'default' => '',
'not null' => TRUE,
'description' => "The scheduled configuration's name.",
),
'date' => array(
'description' => 'The Unix timestamp of when the task is to be scheduled.',
'type' => 'int',
'not null' => TRUE,
),
'data' => array(
'type' => 'text',
'not null' => FALSE,
'serialize' => TRUE,
'description' => 'The whole, serialized evaluation data.',
),
'identifier' => array(
'type' => 'varchar',
'length' => '255',
'default' => '',
'not null' => FALSE,
'description' => 'The user defined string identifying this task.',
),
),
'primary key' => array('tid'),
'indexes' => array('date' => array('date')),
);
db_create_table('rules_scheduler', $schema['rules_scheduler']);
}
/**
* Fix the length of the rules_scheduler.name column.
*/
function rules_scheduler_update_7202() {
// Note that update 7201 (add the 'id' unique key') has been removed as it is
// incorporated by 7202. For anyone that has already run the previous update
// 7201, we have to first drop the unique key.
db_drop_unique_key('rules_scheduler', 'id');
db_change_field('rules_scheduler', 'config', 'config', array(
'type' => 'varchar',
'length' => '64',
'default' => '',
'not null' => TRUE,
'description' => "The scheduled configuration's name.",
));
db_add_unique_key('rules_scheduler', 'id', array('config', 'identifier'));
}
/**
* Add a database column for specifying a queue item handler.
*/
function rules_scheduler_update_7203() {
db_add_field('rules_scheduler', 'handler', array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
'description' => 'The fully-qualified class name of the queue item handler.',
));
}
/**
* Rename rules_scheduler.state into rules_scheduler.data.
*/
function rules_scheduler_update_7204() {
if (db_field_exists('rules_scheduler', 'state')) {
db_change_field('rules_scheduler', 'state', 'data', array(
'type' => 'text',
'not null' => FALSE,
'serialize' => TRUE,
'description' => 'The whole, serialized evaluation data.',
));
}
}
/**
* Use blob:big for rules_scheduler.data for compatibility with PostgreSQL.
*/
function rules_scheduler_update_7205() {
if (db_field_exists('rules_scheduler', 'data')) {
db_change_field('rules_scheduler', 'data', 'data', array(
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
'description' => 'The whole, serialized evaluation data.',
));
}
}
/**
* Rules upgrade callback for mapping the action name.
*/
function rules_scheduler_action_upgrade_map_name($element) {
return 'schedule';
}
/**
* Rules upgrade callback.
*/
function rules_scheduler_action_upgrade($element, $target) {
$target->settings['component'] = $element['#info']['set'];
$target->settings['date'] = $element['#settings']['task_date'];
$target->settings['identifier'] = $element['#settings']['task_identifier'];
unset($element['#info']['arguments']['task_date'], $element['#info']['arguments']['task_identifier']);
foreach ($element['#info']['arguments'] as $name => $info) {
rules_upgrade_element_parameter_settings($element, $target, $name, $info, 'param_' . $name);
}
}
/**
* Rules upgrade callback for mapping the action name.
*/
function rules_action_delete_scheduled_set_upgrade_map_name($element) {
return 'schedule_delete';
}
/**
* Rules upgrade callback.
*/
function rules_action_delete_scheduled_set_upgrade($element, $target) {
$target->settings['component'] = $element['#settings']['ruleset'];
$target->settings['task'] = $element['#settings']['task_identifier'];
}