processSQL($rev); return TRUE; } /** * Syntactic sugar for adding a task. * * Task is (a) in this class and (b) has a high priority. * * After passing the $funcName, you can also pass parameters that will go to * the function. Note that all params must be serializable. * * @param string $title * @param string $funcName */ protected function addTask($title, $funcName) { $queue = CRM_Queue_Service::singleton()->load(array( 'type' => 'Sql', 'name' => CRM_Upgrade_Form::QUEUE_NAME, )); $args = func_get_args(); $title = array_shift($args); $funcName = array_shift($args); $task = new CRM_Queue_Task( array(get_class($this), $funcName), $args, $title ); $queue->createItem($task, array('weight' => -1)); } /** * Remove a payment processor if not in use * * @param CRM_Queue_TaskContext $ctx * @param string $name * @return bool * @throws \CiviCRM_API3_Exception */ public static function removePaymentProcessorType(CRM_Queue_TaskContext $ctx, $name) { $processors = civicrm_api3('PaymentProcessor', 'getcount', array('payment_processor_type_id' => $name)); if (empty($processors['result'])) { $result = civicrm_api3('PaymentProcessorType', 'get', array( 'name' => $name, 'return' => 'id', )); if (!empty($result['id'])) { civicrm_api3('PaymentProcessorType', 'delete', array('id' => $result['id'])); } } return TRUE; } /** * Add a column to a table if it doesn't already exist * * @param CRM_Queue_TaskContext $ctx * @param string $table * @param string $column * @param string $properties * @return bool */ public static function addColumn($ctx, $table, $column, $properties) { if (!CRM_Core_BAO_SchemaHandler::checkIfFieldExists($table, $column)) { CRM_Core_DAO::executeQuery("ALTER TABLE `$table` ADD COLUMN `$column` $properties", array(), TRUE, NULL, FALSE, FALSE); } return TRUE; } /** * Drop a column from a table if it exist. * * @param CRM_Queue_TaskContext $ctx * @param string $table * @param string $column * @return bool */ public static function dropColumn($ctx, $table, $column) { if (CRM_Core_BAO_SchemaHandler::checkIfFieldExists($table, $column)) { CRM_Core_DAO::executeQuery("ALTER TABLE `$table` DROP COLUMN `$column`", array(), TRUE, NULL, FALSE, FALSE); } return TRUE; } /** * Add a index to a table column. * * @param CRM_Queue_TaskContext $ctx * @param string $table * @param string|array $column * @return bool */ public static function addIndex($ctx, $table, $column) { $tables = array($table => (array) $column); CRM_Core_BAO_SchemaHandler::createIndexes($tables); return TRUE; } /** * Drop a index from a table if it exist. * * @param CRM_Queue_TaskContext $ctx * @param string $table * @param string $indexName * @return bool */ public static function dropIndex($ctx, $table, $indexName) { CRM_Core_BAO_SchemaHandler::dropIndexIfExists($table, $indexName); return TRUE; } }