| 1 |
<?php |
| 2 |
/** |
| 3 |
* MainWP Install |
| 4 |
* |
| 5 |
* This file handles install MainWP DB. |
| 6 |
* |
| 7 |
* @package MainWP/Dashboard |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace MainWP\Dashboard; |
| 11 |
|
| 12 |
/** |
| 13 |
* Class MainWP_Install |
| 14 |
* |
| 15 |
* @package MainWP\Dashboard |
| 16 |
*/ |
| 17 |
class MainWP_Install extends MainWP_DB_Base { |
| 18 |
|
| 19 |
// phpcs:disable WordPress.DB.RestrictedFunctions, WordPress.DB.PreparedSQL.NotPrepared -- unprepared SQL ok, accessing the database directly to custom database functions. |
| 20 |
|
| 21 |
/** |
| 22 |
* Private variable to hold the database version info. |
| 23 |
* |
| 24 |
* @var string DB version info. |
| 25 |
*/ |
| 26 |
protected $mainwp_db_version = '8.42'; |
| 27 |
|
| 28 |
/** |
| 29 |
* Private static variable to hold the single instance of the class. |
| 30 |
* |
| 31 |
* @static |
| 32 |
* |
| 33 |
* @var mixed Default null |
| 34 |
*/ |
| 35 |
private static $instance = null; |
| 36 |
|
| 37 |
/** |
| 38 |
* Method instance() |
| 39 |
* |
| 40 |
* Return public static instance. |
| 41 |
* |
| 42 |
* @static |
| 43 |
* @return MainWP_DB |
| 44 |
*/ |
| 45 |
public static function instance() { |
| 46 |
if ( null == self::$instance ) { |
| 47 |
self::$instance = new self(); |
| 48 |
} |
| 49 |
|
| 50 |
self::$instance->test_connection(); |
| 51 |
|
| 52 |
return self::$instance; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Method install() |
| 57 |
* |
| 58 |
* Installs the new DB. |
| 59 |
* |
| 60 |
* @return void |
| 61 |
*/ |
| 62 |
public function install() { |
| 63 |
// get_site_option is multisite aware! |
| 64 |
$currentVersion = get_site_option( 'mainwp_db_version' ); |
| 65 |
|
| 66 |
if ( empty( $currentVersion ) ) { |
| 67 |
update_option( 'mainwp_run_quick_setup', 'yes' ); |
| 68 |
MainWP_Utility::update_option( 'mainwp_enableLegacyBackupFeature', 0 ); |
| 69 |
} elseif ( false === get_option( 'mainwp_enableLegacyBackupFeature' ) ) { |
| 70 |
MainWP_Utility::update_option( 'mainwp_enableLegacyBackupFeature', 1 ); |
| 71 |
} |
| 72 |
|
| 73 |
$rslt = self::instance()->query( "SHOW TABLES LIKE '" . $this->table_name( 'wp' ) . "'" ); |
| 74 |
if ( 0 == self::num_rows( $rslt ) ) { |
| 75 |
$currentVersion = false; |
| 76 |
} |
| 77 |
|
| 78 |
if ( $currentVersion == $this->mainwp_db_version ) { |
| 79 |
return; |
| 80 |
} |
| 81 |
|
| 82 |
$charset_collate = $this->wpdb->get_charset_collate(); |
| 83 |
|
| 84 |
$sql = array(); |
| 85 |
$tbl = 'CREATE TABLE ' . $this->table_name( 'wp' ) . ' ( |
| 86 |
id int(11) NOT NULL auto_increment, |
| 87 |
userid int(11) NOT NULL, |
| 88 |
adminname text NOT NULL, |
| 89 |
name text NOT NULL, |
| 90 |
url text NOT NULL, |
| 91 |
pubkey text NOT NULL, |
| 92 |
privkey text NOT NULL, |
| 93 |
nossl tinyint(1) NOT NULL, |
| 94 |
nosslkey text NOT NULL, |
| 95 |
siteurl text NOT NULL, |
| 96 |
ga_id text NOT NULL, |
| 97 |
gas_id int(11) NOT NULL, |
| 98 |
offline_checks_last int(11) NOT NULL, |
| 99 |
offline_check_result int(11) NOT NULL, |
| 100 |
http_response_code int(11) NOT NULL DEFAULT 0, |
| 101 |
http_code_noticed tinyint(1) NOT NULL DEFAULT 1, |
| 102 |
disable_status_check tinyint(1) NOT NULL DEFAULT 0, |
| 103 |
disable_health_check tinyint(1) NOT NULL DEFAULT 0, |
| 104 |
status_check_interval tinyint(1) NOT NULL DEFAULT 0, |
| 105 |
health_threshold int(11) NOT NULL DEFAULT 0, |
| 106 |
note text NOT NULL, |
| 107 |
note_lastupdate int(11) NOT NULL DEFAULT 0, |
| 108 |
statsUpdate int(11) NOT NULL, |
| 109 |
directories longtext NOT NULL, |
| 110 |
plugin_upgrades longtext NOT NULL, |
| 111 |
theme_upgrades longtext NOT NULL, |
| 112 |
translation_upgrades longtext NOT NULL, |
| 113 |
premium_upgrades longtext NOT NULL, |
| 114 |
securityIssues longtext NOT NULL, |
| 115 |
themes longtext NOT NULL, |
| 116 |
ignored_themes longtext NOT NULL, |
| 117 |
plugins longtext NOT NULL, |
| 118 |
ignored_plugins longtext NOT NULL, |
| 119 |
pages longtext NOT NULL, |
| 120 |
users longtext NOT NULL, |
| 121 |
categories longtext NOT NULL, |
| 122 |
pluginDir text NOT NULL, |
| 123 |
automatic_update tinyint(1) NOT NULL, |
| 124 |
backup_before_upgrade tinyint(1) NOT NULL DEFAULT 2, |
| 125 |
backups text NOT NULL, |
| 126 |
mainwpdir int(11) NOT NULL, |
| 127 |
loadFilesBeforeZip tinyint(1) NOT NULL DEFAULT 1, |
| 128 |
is_ignoreCoreUpdates tinyint(1) NOT NULL DEFAULT 0, |
| 129 |
is_ignorePluginUpdates tinyint(1) NOT NULL DEFAULT 0, |
| 130 |
is_ignoreThemeUpdates tinyint(1) NOT NULL DEFAULT 0, |
| 131 |
verify_certificate tinyint(1) NOT NULL DEFAULT 1, |
| 132 |
force_use_ipv4 tinyint(1) NOT NULL DEFAULT 0, |
| 133 |
ssl_version tinyint(1) NOT NULL DEFAULT 0, |
| 134 |
ip text NOT NULL DEFAULT "", |
| 135 |
uniqueId text NOT NULL, |
| 136 |
maximumFileDescriptorsOverride tinyint(1) NOT NULL DEFAULT 0, |
| 137 |
maximumFileDescriptorsAuto tinyint(1) NOT NULL DEFAULT 1, |
| 138 |
maximumFileDescriptors int(11) NOT NULL DEFAULT 150, |
| 139 |
http_user text NOT NULL DEFAULT "", |
| 140 |
http_pass text NOT NULL DEFAULT "", |
| 141 |
wpe tinyint(1) NOT NULL, |
| 142 |
is_staging tinyint(1) NOT NULL DEFAULT 0, |
| 143 |
KEY idx_userid (userid)'; |
| 144 |
if ( '' == $currentVersion ) { |
| 145 |
$tbl .= ', |
| 146 |
PRIMARY KEY (id) '; |
| 147 |
} |
| 148 |
$tbl .= ') ' . $charset_collate; |
| 149 |
$sql[] = $tbl; |
| 150 |
|
| 151 |
$tbl = 'CREATE TABLE ' . $this->table_name( 'wp_sync' ) . ' ( |
| 152 |
wpid int(11) NOT NULL, |
| 153 |
version text NOT NULL DEFAULT "", |
| 154 |
sync_errors longtext NOT NULL DEFAULT "", |
| 155 |
uptodate longtext NOT NULL DEFAULT "", |
| 156 |
dtsAutomaticSync int(11) NOT NULL DEFAULT 0, |
| 157 |
dtsAutomaticSyncStart int(11) NOT NULL DEFAULT 0, |
| 158 |
dtsSync int(11) NOT NULL DEFAULT 0, |
| 159 |
dtsSyncStart int(11) NOT NULL DEFAULT 0, |
| 160 |
totalsize int(11) NOT NULL DEFAULT 0, |
| 161 |
dbsize int(11) NOT NULL DEFAULT 0, |
| 162 |
extauth text NOT NULL DEFAULT "", |
| 163 |
last_post_gmt int(11) NOT NULL DEFAULT 0, |
| 164 |
health_value int(11) NOT NULL DEFAULT 0, |
| 165 |
health_site_noticed tinyint(1) NOT NULL DEFAULT 1, |
| 166 |
KEY idx_wpid (wpid)) ' . $charset_collate; |
| 167 |
$sql[] = $tbl; |
| 168 |
|
| 169 |
$tbl = 'CREATE TABLE ' . $this->table_name( 'wp_options' ) . ' ( |
| 170 |
wpid int(11) NOT NULL, |
| 171 |
name text NOT NULL DEFAULT "", |
| 172 |
value longtext NOT NULL DEFAULT "", |
| 173 |
KEY idx_wpid (wpid)) ' . $charset_collate; |
| 174 |
$sql[] = $tbl; |
| 175 |
|
| 176 |
$tbl = 'CREATE TABLE ' . $this->table_name( 'wp_settings_backup' ) . ' ( |
| 177 |
wpid int(11) NOT NULL, |
| 178 |
archiveFormat text NOT NULL, |
| 179 |
KEY idx_wpid (wpid)) ' . $charset_collate; |
| 180 |
$sql[] = $tbl; |
| 181 |
|
| 182 |
$tbl = 'CREATE TABLE ' . $this->table_name( 'users' ) . " ( |
| 183 |
userid int(11) NOT NULL, |
| 184 |
user_email text NOT NULL DEFAULT '', |
| 185 |
ignored_plugins longtext NOT NULL DEFAULT '', |
| 186 |
trusted_plugins longtext NOT NULL DEFAULT '', |
| 187 |
trusted_plugins_notes longtext NOT NULL DEFAULT '', |
| 188 |
ignored_themes longtext NOT NULL DEFAULT '', |
| 189 |
trusted_themes longtext NOT NULL DEFAULT '', |
| 190 |
trusted_themes_notes longtext NOT NULL DEFAULT '', |
| 191 |
site_view tinyint(1) NOT NULL DEFAULT '0', |
| 192 |
pluginDir text NOT NULL DEFAULT '', |
| 193 |
dismissed_plugins longtext NOT NULL DEFAULT '', |
| 194 |
dismissed_themes longtext NOT NULL DEFAULT ''"; |
| 195 |
if ( '' == $currentVersion ) { |
| 196 |
$tbl .= ', |
| 197 |
PRIMARY KEY (userid) '; |
| 198 |
} |
| 199 |
$tbl .= ') ' . $charset_collate; |
| 200 |
$sql[] = $tbl; |
| 201 |
|
| 202 |
$tbl = 'CREATE TABLE ' . $this->table_name( 'wp_status' ) . ' ( |
| 203 |
statusid bigint(20) unsigned NOT NULL auto_increment, |
| 204 |
wpid int(11) NOT NULL, |
| 205 |
http_code smallint NOT NULL DEFAULT 0, |
| 206 |
status tinyint(1) NOT NULL DEFAULT 0, |
| 207 |
event_timestamp int(11) NOT NULL, |
| 208 |
duration int(11) NOT NULL DEFAULT 0'; |
| 209 |
if ( '' == $currentVersion || version_compare( $currentVersion, '8.31', '<=' ) ) { |
| 210 |
$tbl .= ', |
| 211 |
PRIMARY KEY (statusid) '; |
| 212 |
} |
| 213 |
$tbl .= ') ' . $charset_collate; |
| 214 |
$sql[] = $tbl; |
| 215 |
|
| 216 |
$tbl = 'CREATE TABLE ' . $this->table_name( 'group' ) . ' ( |
| 217 |
id int(11) NOT NULL auto_increment, |
| 218 |
userid int(11) NOT NULL, |
| 219 |
name text NOT NULL'; |
| 220 |
if ( '' == $currentVersion ) { |
| 221 |
$tbl .= ', |
| 222 |
PRIMARY KEY (id) '; |
| 223 |
} |
| 224 |
$tbl .= ') ' . $charset_collate; |
| 225 |
$sql[] = $tbl; |
| 226 |
|
| 227 |
$sql[] = 'CREATE TABLE ' . $this->table_name( 'wp_group' ) . ' ( |
| 228 |
wpid int(11) NOT NULL, |
| 229 |
groupid int(11) NOT NULL, |
| 230 |
KEY idx_wpid (wpid), |
| 231 |
KEY idx_groupid (groupid) |
| 232 |
) ' . $charset_collate; |
| 233 |
|
| 234 |
$tbl = 'CREATE TABLE ' . $this->table_name( 'wp_backup_progress' ) . ' ( |
| 235 |
task_id int(11) NOT NULL, |
| 236 |
wp_id int(11) NOT NULL, |
| 237 |
dtsFetched int(11) NOT NULL DEFAULT 0, |
| 238 |
fetchResult text NOT NULL DEFAULT "", |
| 239 |
downloadedDB text NOT NULL DEFAULT "", |
| 240 |
downloadedFULL text NOT NULL DEFAULT "", |
| 241 |
downloadedDBComplete tinyint(1) NOT NULL DEFAULT 0, |
| 242 |
downloadedFULLComplete tinyint(1) NOT NULL DEFAULT 0, |
| 243 |
removedFiles tinyint(1) NOT NULL DEFAULT 0, |
| 244 |
attempts int(11) NOT NULL DEFAULT 0, |
| 245 |
last_error text NOT NULL DEFAULT "", |
| 246 |
pid int(11) NOT NULL DEFAULT 0, |
| 247 |
KEY idx_task_id (task_id) |
| 248 |
) ' . $charset_collate; |
| 249 |
$sql[] = $tbl; |
| 250 |
|
| 251 |
$tbl = 'CREATE TABLE ' . $this->table_name( 'wp_backup' ) . ' ( |
| 252 |
id int(11) NOT NULL auto_increment, |
| 253 |
userid int(11) NOT NULL, |
| 254 |
name text NOT NULL, |
| 255 |
schedule text NOT NULL, |
| 256 |
type text NOT NULL, |
| 257 |
exclude text NOT NULL, |
| 258 |
sites text NOT NULL, |
| 259 |
`groups` text NOT NULL, |
| 260 |
last int(11) NOT NULL, |
| 261 |
last_run int(11) NOT NULL, |
| 262 |
lastStartNotificationSent int(11) NOT NULL DEFAULT 0, |
| 263 |
last_run_manually int(11) NOT NULL, |
| 264 |
completed_sites text NOT NULL, |
| 265 |
completed int(11) NOT NULL, |
| 266 |
backup_errors text NOT NULL, |
| 267 |
subfolder text NOT NULL, |
| 268 |
filename text NOT NULL, |
| 269 |
paused tinyint(1) NOT NULL, |
| 270 |
template tinyint(1) DEFAULT 0, |
| 271 |
excludebackup tinyint(1) DEFAULT 0, |
| 272 |
excludecache tinyint(1) DEFAULT 0, |
| 273 |
excludenonwp tinyint(1) DEFAULT 0, |
| 274 |
excludezip tinyint(1) DEFAULT 0, |
| 275 |
archiveFormat text NOT NULL, |
| 276 |
loadFilesBeforeZip tinyint(1) NOT NULL DEFAULT 1, |
| 277 |
maximumFileDescriptorsOverride tinyint(1) NOT NULL DEFAULT 0, |
| 278 |
maximumFileDescriptorsAuto tinyint(1) NOT NULL DEFAULT 1, |
| 279 |
maximumFileDescriptors int(11) NOT NULL DEFAULT 150'; |
| 280 |
if ( '' == $currentVersion ) { |
| 281 |
$tbl .= ', |
| 282 |
PRIMARY KEY (id) '; |
| 283 |
} |
| 284 |
$tbl .= ') ' . $charset_collate; |
| 285 |
$sql[] = $tbl; |
| 286 |
|
| 287 |
$tbl = 'CREATE TABLE ' . $this->table_name( 'request_log' ) . ' ( |
| 288 |
id int(11) NOT NULL auto_increment, |
| 289 |
wpid int(11) NOT NULL, |
| 290 |
ip text NOT NULL DEFAULT "", |
| 291 |
subnet text NOT NULL DEFAULT "", |
| 292 |
micro_timestamp_stop DECIMAL( 12, 2 ) NOT NULL DEFAULT 0, |
| 293 |
micro_timestamp_start DECIMAL( 12, 2 ) NOT NULL DEFAULT 0'; |
| 294 |
if ( '' == $currentVersion || version_compare( $currentVersion, '5.7', '<=' ) ) { |
| 295 |
$tbl .= ', |
| 296 |
PRIMARY KEY (id) '; |
| 297 |
} |
| 298 |
$tbl .= ') ' . $charset_collate . ';'; |
| 299 |
$sql[] = $tbl; |
| 300 |
|
| 301 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 302 |
foreach ( $sql as $query ) { |
| 303 |
dbDelta( $query ); |
| 304 |
} |
| 305 |
|
| 306 |
$this->post_update(); |
| 307 |
|
| 308 |
if ( ! is_multisite() ) { |
| 309 |
MainWP_Utility::update_option( 'mainwp_db_version', $this->mainwp_db_version ); |
| 310 |
} else { |
| 311 |
update_site_option( 'mainwp_db_version', $this->mainwp_db_version ); |
| 312 |
} |
| 313 |
} |
| 314 |
|
| 315 |
/** |
| 316 |
* Method post_update() |
| 317 |
* |
| 318 |
* Update MainWP DB. |
| 319 |
* |
| 320 |
* @return void |
| 321 |
*/ |
| 322 |
public function post_update() { |
| 323 |
|
| 324 |
// get_site_option is multisite aware! |
| 325 |
$currentVersion = get_site_option( 'mainwp_db_version' ); |
| 326 |
|
| 327 |
if ( false == $currentVersion ) { |
| 328 |
return; |
| 329 |
} |
| 330 |
|
| 331 |
$this->post_update_81( $currentVersion ); |
| 332 |
|
| 333 |
// delete old columns. |
| 334 |
if ( version_compare( $currentVersion, '8.17', '<' ) ) { |
| 335 |
$rankColumns = array( |
| 336 |
'pagerank', |
| 337 |
'indexed', |
| 338 |
'alexia', |
| 339 |
'pagerank_old', |
| 340 |
'indexed_old', |
| 341 |
'alexia_old', |
| 342 |
'last_db_backup_size', |
| 343 |
); |
| 344 |
|
| 345 |
foreach ( $rankColumns as $rankColumn ) { |
| 346 |
$suppress = $this->wpdb->suppress_errors(); |
| 347 |
$this->wpdb->query( 'ALTER TABLE ' . $this->table_name( 'wp' ) . ' DROP COLUMN ' . $rankColumn ); |
| 348 |
$this->wpdb->suppress_errors( $suppress ); |
| 349 |
} |
| 350 |
|
| 351 |
$syncColumns = array( 'uptodate' ); |
| 352 |
foreach ( $syncColumns as $column ) { |
| 353 |
$suppress = $this->wpdb->suppress_errors(); |
| 354 |
$this->wpdb->query( 'ALTER TABLE ' . $this->table_name( 'wp_sync' ) . ' DROP COLUMN ' . $column ); |
| 355 |
$this->wpdb->suppress_errors( $suppress ); |
| 356 |
} |
| 357 |
} |
| 358 |
|
| 359 |
// delete old columns. |
| 360 |
if ( version_compare( $currentVersion, '8.35', '<' ) ) { |
| 361 |
$delColumns = array( 'offline_checks' ); |
| 362 |
foreach ( $delColumns as $column ) { |
| 363 |
$suppress = $this->wpdb->suppress_errors(); |
| 364 |
$this->wpdb->query( 'ALTER TABLE ' . $this->table_name( 'wp' ) . ' DROP COLUMN ' . $column ); |
| 365 |
$this->wpdb->suppress_errors( $suppress ); |
| 366 |
} |
| 367 |
$delColumns = array( 'heatMap' ); |
| 368 |
foreach ( $delColumns as $column ) { |
| 369 |
$suppress = $this->wpdb->suppress_errors(); |
| 370 |
$this->wpdb->query( 'ALTER TABLE ' . $this->table_name( 'users' ) . ' DROP COLUMN ' . $column ); |
| 371 |
$this->wpdb->suppress_errors( $suppress ); |
| 372 |
} |
| 373 |
} |
| 374 |
|
| 375 |
// change columns. |
| 376 |
if ( version_compare( $currentVersion, '8.40', '<' ) && version_compare( $currentVersion, '8.30', '>' ) ) { |
| 377 |
$this->wpdb->query( 'ALTER TABLE ' . $this->table_name( 'wp_status' ) . ' CHANGE COLUMN `timestamp_status` `event_timestamp` int(11) NOT NULL' ); |
| 378 |
} |
| 379 |
|
| 380 |
// delete columns. |
| 381 |
if ( version_compare( $currentVersion, '8.42', '<' ) ) { |
| 382 |
$delColumns = array( 'offlineChecksOnlineNotification' ); |
| 383 |
foreach ( $delColumns as $column ) { |
| 384 |
$suppress = $this->wpdb->suppress_errors(); |
| 385 |
$this->wpdb->query( 'ALTER TABLE ' . $this->table_name( 'users' ) . ' DROP COLUMN ' . $column ); |
| 386 |
$this->wpdb->suppress_errors( $suppress ); |
| 387 |
} |
| 388 |
} |
| 389 |
} |
| 390 |
|
| 391 |
/** |
| 392 |
* Method post_update_81() |
| 393 |
* |
| 394 |
* Update MainWP DB for version 8.1. |
| 395 |
* |
| 396 |
* @param string $current_version Current version DB. |
| 397 |
* |
| 398 |
* @return void |
| 399 |
*/ |
| 400 |
public function post_update_81( $current_version ) { |
| 401 |
|
| 402 |
if ( version_compare( $current_version, '8.1', '<' ) ) { |
| 403 |
|
| 404 |
// We can't split up here! |
| 405 |
$wpSyncColumns = array( |
| 406 |
'version', |
| 407 |
'totalsize', |
| 408 |
'dbsize', |
| 409 |
'extauth', |
| 410 |
'last_post_gmt', |
| 411 |
'sync_errors', |
| 412 |
'dtsSync', |
| 413 |
'dtsSyncStart', |
| 414 |
'dtsAutomaticSync', |
| 415 |
'dtsAutomaticSyncStart', |
| 416 |
); |
| 417 |
foreach ( $wpSyncColumns as $wpSyncColumn ) { |
| 418 |
$rslts = $this->wpdb->get_results( 'SELECT id,' . $wpSyncColumn . ' FROM ' . $this->table_name( 'wp' ), ARRAY_A ); |
| 419 |
if ( empty( $rslts ) ) { |
| 420 |
continue; |
| 421 |
} |
| 422 |
|
| 423 |
foreach ( $rslts as $rslt ) { |
| 424 |
$exists = $this->wpdb->get_results( $this->wpdb->prepare( 'SELECT wpid FROM ' . $this->table_name( 'wp_sync' ) . ' WHERE wpid = %d', $rslt['id'] ), ARRAY_A ); |
| 425 |
if ( empty( $exists ) ) { |
| 426 |
$this->wpdb->insert( |
| 427 |
$this->table_name( 'wp_sync' ), |
| 428 |
array( |
| 429 |
'wpid' => $rslt['id'], |
| 430 |
$wpSyncColumn => $rslt[ $wpSyncColumn ], |
| 431 |
) |
| 432 |
); |
| 433 |
} else { |
| 434 |
$this->wpdb->update( $this->table_name( 'wp_sync' ), array( $wpSyncColumn => $rslt[ $wpSyncColumn ] ), array( 'wpid' => $rslt['id'] ) ); |
| 435 |
} |
| 436 |
} |
| 437 |
|
| 438 |
$suppress = $this->wpdb->suppress_errors(); |
| 439 |
$this->wpdb->query( 'ALTER TABLE ' . $this->table_name( 'wp' ) . ' DROP COLUMN ' . $wpSyncColumn ); |
| 440 |
$this->wpdb->suppress_errors( $suppress ); |
| 441 |
} |
| 442 |
|
| 443 |
$optionColumns = array( |
| 444 |
'last_wp_upgrades', |
| 445 |
'last_plugin_upgrades', |
| 446 |
'last_theme_upgrades', |
| 447 |
'wp_upgrades', |
| 448 |
'recent_comments', |
| 449 |
'recent_posts', |
| 450 |
'recent_pages', |
| 451 |
); |
| 452 |
foreach ( $optionColumns as $optionColumn ) { |
| 453 |
$rslts = $this->wpdb->get_results( 'SELECT id,' . $optionColumn . ' FROM ' . $this->table_name( 'wp' ), ARRAY_A ); |
| 454 |
if ( empty( $rslts ) ) { |
| 455 |
continue; |
| 456 |
} |
| 457 |
|
| 458 |
foreach ( $rslts as $rslt ) { |
| 459 |
self::update_website_option( (object) $rslt, $optionColumn, $rslt[ $optionColumn ] ); |
| 460 |
} |
| 461 |
|
| 462 |
$suppress = $this->wpdb->suppress_errors(); |
| 463 |
$this->wpdb->query( 'ALTER TABLE ' . $this->table_name( 'wp' ) . ' DROP COLUMN ' . $optionColumn ); |
| 464 |
$this->wpdb->suppress_errors( $suppress ); |
| 465 |
} |
| 466 |
} |
| 467 |
} |
| 468 |
|
| 469 |
} |
| 470 |
|