PluginProbe
Independent Analytics – WordPress Analytics Plugin / 2.14.0
Independent Analytics – WordPress Analytics Plugin v2.14.0
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 All 120 releases
independent-analytics / IAWP / Migrations / Migration_26.php
Migration_26.php
34 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IAWP\Migrations;
4
5 use IAWP\Query;
6 /** @internal */
7 class Migration_26 extends \IAWP\Migrations\Step_Migration
8 {
9 /**
10 * @return int
11 */
12 protected function database_version() : int
13 {
14 return 26;
15 }
16 /**
17 * @return array
18 */
19 protected function queries() : array
20 {
21 return [$this->set_empty_values_to_null('cached_title'), $this->set_empty_values_to_null('cached_url'), $this->set_empty_values_to_null('cached_type'), $this->set_empty_values_to_null('cached_type_label'), $this->set_empty_values_to_null('cached_author'), $this->set_empty_values_to_null('cached_category'), $this->nullify_authors_with_id_of_zero()];
22 }
23 private function set_empty_values_to_null(string $column) : string
24 {
25 $resources_table = Query::get_table_name(Query::RESOURCES);
26 return "\n UPDATE {$resources_table} SET {$column} = NULL WHERE {$column} = '' \n ";
27 }
28 private function nullify_authors_with_id_of_zero() : string
29 {
30 $resources_table = Query::get_table_name(Query::RESOURCES);
31 return "\n UPDATE {$resources_table} SET cached_author_id = NULL, cached_author = NULL WHERE cached_author_id = 0\n ";
32 }
33 }
34