Passed
Push — master ( 0398fd...04e2c5 )
by Ashley
01:52
created

wp_queue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
use WP_Queue\Queue;
4
use WP_Queue\QueueManager;
5
6
if ( ! function_exists( 'wp_queue' ) ) {
7
	/**
8
	 * Return Queue instance.
9
	 *
10
	 * @param string $connection
11
	 *
12
	 * @return Queue
13
	 */
14
	function wp_queue( $connection = 'database' ) {
15 1
		return QueueManager::resolve( $connection );
16
	}
17
}
18
19
if ( ! function_exists( 'wp_queue_install_tables' ) ) {
20
	/**
21
	 * Install database tables
22
	 */
23
	function wp_queue_install_tables() {
24
		global $wpdb;
25
26
		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
27
28
		$wpdb->hide_errors();
29
		$charset_collate = $wpdb->get_charset_collate();
30
31
		$sql = "CREATE TABLE {$wpdb->prefix}queue_jobs (
32
				id bigint(20) NOT NULL AUTO_INCREMENT,
33
				job longtext NOT NULL,
34
				attempts tinyint(3) NOT NULL DEFAULT 0,
35
				reserved_at datetime DEFAULT NULL,
36
				available_at datetime NOT NULL,
37
				created_at datetime NOT NULL,
38
				PRIMARY KEY  (id)
39
				) $charset_collate;";
40
41
		dbDelta( $sql );
1 ignored issue
show
Bug introduced by
The function dbDelta was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
		/** @scrutinizer ignore-call */ dbDelta( $sql );
Loading history...
42
43
		$sql = "CREATE TABLE {$wpdb->prefix}queue_failures (
44
				id bigint(20) NOT NULL AUTO_INCREMENT,
45
				job longtext NOT NULL,
46
				error text DEFAULT NULL,
47
				failed_at datetime NOT NULL,
48
				PRIMARY KEY  (id)
49
				) $charset_collate;";
50
51
		dbDelta( $sql );
52
	}
53
}