Completed
Pull Request — develop (#1256)
by Naveen
03:54
created

Wordlift_Install_3_28_0   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A install() 0 20 2
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
25
		$post_meta_table_name = $wpdb->postmeta;
26
		$dataset_uri          = $dataset_uri . '%';
27
		$meta_key             = Wordlift_Schema_Service::FIELD_SAME_AS;
28
		$sql                  = "DELETE FROM $post_meta_table_name WHERE meta_key='$meta_key' 
29
AND ( ( meta_value NOT LIKE 'https://%' AND meta_value NOT LIKE 'http://%' )
30
OR meta_value LIKE '$dataset_uri' )";
31
		$wpdb->query( $sql );
32
33
	}
34
35
36
}
37