PluginProbe ʕ •ᴥ•ʔ
LiteSpeed Cache / 7.6.1
LiteSpeed Cache v7.6.1
trunk 1.0.15 1.9.1.1 2.9.9.2 3.6.4 4.6 5.7.0.1 6.5.4 7.0.0.1 7.0.1 7.1 7.2 7.3 7.3.0.1 7.4 7.5 7.5.0.1 7.6 7.6.1 7.6.2 7.7 7.8 7.8.0.1 7.8.1
litespeed-cache / src / data.upgrade.func.php
litespeed-cache / src Last commit date
cdn 7 months ago data_structure 7 months ago activation.cls.php 7 months ago admin-display.cls.php 7 months ago admin-settings.cls.php 7 months ago admin.cls.php 7 months ago api.cls.php 7 months ago avatar.cls.php 7 months ago base.cls.php 7 months ago cdn.cls.php 7 months ago cloud.cls.php 7 months ago conf.cls.php 7 months ago control.cls.php 7 months ago core.cls.php 7 months ago crawler-map.cls.php 7 months ago crawler.cls.php 7 months ago css.cls.php 7 months ago data.cls.php 7 months ago data.upgrade.func.php 7 months ago db-optm.cls.php 7 months ago debug2.cls.php 7 months ago doc.cls.php 7 months ago error.cls.php 7 months ago esi.cls.php 7 months ago file.cls.php 7 months ago gui.cls.php 7 months ago health.cls.php 7 months ago htaccess.cls.php 7 months ago img-optm.cls.php 7 months ago import.cls.php 7 months ago import.preset.cls.php 7 months ago lang.cls.php 7 months ago localization.cls.php 7 months ago media.cls.php 7 months ago metabox.cls.php 7 months ago object-cache-wp.cls.php 7 months ago object-cache.cls.php 7 months ago object.lib.php 7 months ago optimize.cls.php 7 months ago optimizer.cls.php 7 months ago placeholder.cls.php 7 months ago purge.cls.php 7 months ago report.cls.php 7 months ago rest.cls.php 7 months ago root.cls.php 7 months ago router.cls.php 7 months ago str.cls.php 7 months ago tag.cls.php 7 months ago task.cls.php 7 months ago tool.cls.php 7 months ago ucss.cls.php 7 months ago utility.cls.php 7 months ago vary.cls.php 7 months ago vpi.cls.php 7 months ago
data.upgrade.func.php
134 lines
1 <?php
2 // phpcs:ignoreFile
3
4 /**
5 * Database upgrade funcs
6 *
7 * NOTE: whenever called this file, always call Data::get_upgrade_lock and Data::_set_upgrade_lock first.
8 *
9 * @since 3.0
10 */
11 defined('WPINC') || exit();
12
13 use LiteSpeed\Debug2;
14 use LiteSpeed\Cloud;
15
16 /**
17 * Table existence check function
18 *
19 * @since 7.2
20 */
21 function litespeed_table_exists( $table_name ) {
22 global $wpdb;
23 $save_state = $wpdb->suppress_errors;
24 $wpdb->suppress_errors(true);
25 $tb_exists = $wpdb->get_var('DESCRIBE `' . $table_name . '`');
26 $wpdb->suppress_errors($save_state);
27
28 return $tb_exists !== null;
29 }
30
31 /**
32 * Migrate v7.0- url_files URL from no trailing slash to trailing slash
33 *
34 * @since 7.0.1
35 */
36 function litespeed_update_7_0_1() {
37 global $wpdb;
38 Debug2::debug('[Data] v7.0.1 upgrade started');
39
40 $tb_url = $wpdb->prefix . 'litespeed_url';
41 if (!litespeed_table_exists($tb_url)) {
42 Debug2::debug('[Data] Table `litespeed_url` not found, bypassed migration');
43 return;
44 }
45
46 $q = "SELECT * FROM `$tb_url` WHERE url LIKE 'https://%/'";
47 $q = $wpdb->prepare($q);
48 $list = $wpdb->get_results($q, ARRAY_A);
49 $existing_urls = array();
50 if ($list) {
51 foreach ($list as $v) {
52 $existing_urls[] = $v['url'];
53 }
54 }
55
56 $q = "SELECT * FROM `$tb_url` WHERE url LIKE 'https://%'";
57 $q = $wpdb->prepare($q);
58 $list = $wpdb->get_results($q, ARRAY_A);
59 if (!$list) {
60 return;
61 }
62 foreach ($list as $v) {
63 if (substr($v['url'], -1) == '/') {
64 continue;
65 }
66 $new_url = $v['url'] . '/';
67 if (in_array($new_url, $existing_urls)) {
68 continue;
69 }
70 $q = "UPDATE `$tb_url` SET url = %s WHERE id = %d";
71 $q = $wpdb->prepare($q, $new_url, $v['id']);
72 $wpdb->query($q);
73 }
74 }
75
76 /**
77 * Migrate from domain key to pk/sk for QC
78 *
79 * @since 7.0
80 */
81 function litespeed_update_7() {
82 Debug2::debug('[Data] v7 upgrade started');
83
84 $__cloud = Cloud::cls();
85
86 $domain_key = $__cloud->conf('api_key');
87 if (!$domain_key) {
88 Debug2::debug('[Data] No domain key, bypassed migration');
89 return;
90 }
91
92 $new_prepared = $__cloud->init_qc_prepare();
93 if (!$new_prepared && $__cloud->activated()) {
94 Debug2::debug('[Data] QC previously activated in v7, bypassed migration');
95 return;
96 }
97 $data = array(
98 'domain_key' => $domain_key,
99 );
100 $resp = $__cloud->post(Cloud::SVC_D_V3UPGRADE, $data);
101 if (!empty($resp['qc_activated'])) {
102 if ($resp['qc_activated'] != 'deleted') {
103 $cloud_summary_updates = array( 'qc_activated' => $resp['qc_activated'] );
104 if (!empty($resp['main_domain'])) {
105 $cloud_summary_updates['main_domain'] = $resp['main_domain'];
106 }
107 Cloud::save_summary($cloud_summary_updates);
108 Debug2::debug('[Data] Updated QC activated status to ' . $resp['qc_activated']);
109 }
110 }
111 }
112
113 /**
114 * Append webp/mobile to url_file
115 *
116 * @since 5.3
117 */
118 function litespeed_update_5_3() {
119 global $wpdb;
120 Debug2::debug('[Data] Upgrade url_file table');
121
122 $tb = $wpdb->prefix . 'litespeed_url_file';
123 if (litespeed_table_exists($tb)) {
124 $q =
125 'ALTER TABLE `' .
126 $tb .
127 '`
128 ADD COLUMN `mobile` tinyint(4) NOT NULL COMMENT "mobile=1",
129 ADD COLUMN `webp` tinyint(4) NOT NULL COMMENT "webp=1"
130 ';
131 $wpdb->query($q);
132 }
133 }
134