Completed
Push — develop ( 7828fe...a475a4 )
by
unknown
03:04 queued 10s
created

Wordlift_Install_3_28_0::install()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @since 3.28.0
5
 * @author Naveen Muthusamy <[email protected]>
6
 */
7
class Wordlift_Install_3_28_0 extends Wordlift_Install {
8
9
	/**
10
	 * {@inheritdoc}
11
	 */
12
	protected static $version = '3.28.0';
13
14
	public function install() {
15
16
		global $wpdb;
17
18
		$dataset_uri = Wordlift_Configuration_Service::get_instance()->get_dataset_uri();
19
20
		if ( ! $dataset_uri ) {
21
			// Dont run the query, running it would delete all the values.
22
			return;
23
		}
24
		$post_meta_table_name = $wpdb->postmeta;
25
		$meta_key = Wordlift_Schema_Service::FIELD_SAME_AS;
26
27
		$http        = $wpdb->esc_like( 'http://' ) . '%';
28
		$https       = $wpdb->esc_like( 'https://' ) . '%';
29
		$dataset_uri = $wpdb->esc_like( $dataset_uri ) . '%';
30
		$sql         = $wpdb->prepare( "DELETE FROM $post_meta_table_name WHERE meta_key='$meta_key' 
31
AND ( ( meta_value NOT LIKE %s AND meta_value NOT LIKE %s )
32
OR meta_value LIKE %s )", $http, $https, $dataset_uri );
33
		$wpdb->query( $sql );
34
35
	}
36
37
38
}
39