Merge pull request #22664 from braders/membershipview-default-values
[civicrm-core.git] / CRM / Queue / BAO / QueueItem.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * Helpers for managing SQL-backed queue items
20 *
21 * @see CRM_Queue_Queue_Sql
22 */
23 class CRM_Queue_BAO_QueueItem extends CRM_Queue_DAO_QueueItem {
24
25 /**
26 * Ensure that the required SQL table exists.
27 *
28 * The `civicrm_queue_item` table is a special requirement - without it, the upgrader cannot run.
29 * The upgrader will make a special request for `findCreateTable()` before computing upgrade-tasks.
30 *
31 * @return bool
32 * TRUE if table now exists
33 */
34 public static function findCreateTable(): bool {
35 if (!CRM_Core_DAO::checkTableExists('civicrm_queue_item')) {
36 // Table originated in 4.2. We no longer support direct upgrades from <=4.2. Don't bother trying to create table.
37 return FALSE;
38 }
39 else {
40 return static::updateTable();
41 }
42 }
43
44 /**
45 * Ensure that the `civicrm_queue_item` table is up-to-date.
46 *
47 * @return bool
48 */
49 public static function updateTable(): bool {
50 CRM_Upgrade_Incremental_Base::addColumn(NULL, 'civicrm_queue_item', 'run_count',
51 "int NOT NULL DEFAULT 0 COMMENT 'Number of times execution has been attempted.'");
52 return TRUE;
53 }
54
55 }