fix
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php #comp-page builds: premium
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates for altering the table used to store statistics data.
|
||||
* Adds new columns and renames existing ones in order to add support for the new social buttons.
|
||||
*/
|
||||
class WIOUpdate010009 extends Wbcr_Factory600_Update {
|
||||
|
||||
public function install() {
|
||||
|
||||
$db_version = RIO_Process_Queue::get_db_version();
|
||||
$plugin_version_in_db = $this->get_plugin_version_in_db();
|
||||
$current_plugin_version = $this->plugin->getPluginVersion();
|
||||
|
||||
$init_log_message = "Start plugin migration < %s.\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-DB Version: {$db_version}\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-Plugin Version in DB: {$plugin_version_in_db}\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-Current Plugin Version: {$current_plugin_version}";
|
||||
|
||||
WRIO_Plugin::app()->logger->info( sprintf( $init_log_message, '1.1.5' ) );
|
||||
|
||||
WRIO_Plugin::app()->updateOption( 'image_optimization_server', 'server_2' );
|
||||
|
||||
WBCR\Factory_Templates_759\Helpers::flushPageCache();
|
||||
|
||||
WRIO_Plugin::app()->logger->info( 'Plugin migration was successfull!' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get previous plugin version
|
||||
*
|
||||
* @since 1.3.8
|
||||
* @return int
|
||||
*/
|
||||
public function get_plugin_version_in_db() {
|
||||
if ( WRIO_Plugin::app()->isNetworkActive() ) {
|
||||
return get_site_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
|
||||
}
|
||||
|
||||
return get_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php #comp-page builds: premium
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates for altering the table used to store statistics data.
|
||||
* Adds new columns and renames existing ones in order to add support for the new social buttons.
|
||||
*/
|
||||
class WIOUpdate010300 extends Wbcr_Factory600_Update {
|
||||
|
||||
/**
|
||||
* @since 1.3.6
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function install() {
|
||||
|
||||
$db_version = RIO_Process_Queue::get_db_version();
|
||||
$plugin_version_in_db = $this->get_plugin_version_in_db();
|
||||
$current_plugin_version = $this->plugin->getPluginVersion();
|
||||
|
||||
$init_log_message = "Start plugin migration < %s.\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-DB Version: {$db_version}\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-Plugin Version in DB: {$plugin_version_in_db}\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-Current Plugin Version: {$current_plugin_version}";
|
||||
|
||||
WRIO_Plugin::app()->logger->info( sprintf( $init_log_message, '1.3.0' ) );
|
||||
|
||||
RIO_Process_Queue::try_create_plugin_tables();
|
||||
|
||||
$this->clear_log();
|
||||
|
||||
WRIO_Plugin::app()->deleteOption( 'cron_running' );
|
||||
|
||||
if ( class_exists( 'WRIO_Cron' ) ) {
|
||||
WRIO_Cron::stop();
|
||||
}
|
||||
|
||||
WBCR\Factory_Templates_759\Helpers::flushPageCache();
|
||||
|
||||
WRIO_Plugin::app()->logger->info( 'Plugin migration was successfull!' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get previous plugin version
|
||||
*
|
||||
* @since 1.3.8
|
||||
* @return number
|
||||
*/
|
||||
public function get_plugin_version_in_db() {
|
||||
if ( WRIO_Plugin::app()->isNetworkActive() ) {
|
||||
return get_site_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
|
||||
}
|
||||
|
||||
return get_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Since version 1.3.0, we use a different path and a different algorithm for
|
||||
* accumulating log files. Therefore, if there is an old log file, you need to clear it.
|
||||
*
|
||||
* @since 1.3.6
|
||||
*/
|
||||
public function clear_log() {
|
||||
$wp_upload_dir = wp_upload_dir();
|
||||
|
||||
if ( isset( $wp_upload_dir['error'] ) && $wp_upload_dir['error'] !== false ) {
|
||||
WRIO_Plugin::app()->logger->error( sprintf( 'Plugin migration error: %s', $wp_upload_dir['error'] ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$file_path = wp_normalize_path( trailingslashit( $wp_upload_dir['basedir'] ) . 'wio.log' );
|
||||
|
||||
if ( file_exists( $file_path ) ) {
|
||||
if ( @unlink( $file_path ) ) {
|
||||
WRIO_Plugin::app()->logger->info( 'Plugin migration: The old error log was successfully deleted!' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
109
wp-content/plugins/robin-image-optimizer/migrations/010306.php
Normal file
109
wp-content/plugins/robin-image-optimizer/migrations/010306.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php #comp-page builds: premium
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates for altering the table used to store statistics data.
|
||||
* Adds new columns and renames existing ones in order to add support for the new social buttons.
|
||||
*/
|
||||
class WIOUpdate010306 extends Wbcr_Factory600_Update {
|
||||
|
||||
/**
|
||||
* {inherit}
|
||||
*
|
||||
* @since 1.3.6
|
||||
*/
|
||||
public function install() {
|
||||
|
||||
$db_version = RIO_Process_Queue::get_db_version();
|
||||
$plugin_version_in_db = $this->get_plugin_version_in_db();
|
||||
$current_plugin_version = $this->plugin->getPluginVersion();
|
||||
|
||||
$init_log_message = "Start plugin migration < %s.\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-DB Version: {$db_version}\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-Plugin Version in DB: {$plugin_version_in_db}\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-Current Plugin Version: {$current_plugin_version}";
|
||||
|
||||
WRIO_Plugin::app()->logger->info( sprintf( $init_log_message, '1.3.6' ) );
|
||||
|
||||
$this->clear_webp_images();
|
||||
|
||||
WBCR\Factory_Templates_759\Helpers::flushPageCache();
|
||||
|
||||
WRIO_Plugin::app()->logger->info( 'Plugin migration was successfull!' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get previous plugin version
|
||||
*
|
||||
* @since 1.3.8
|
||||
* @return number
|
||||
*/
|
||||
public function get_plugin_version_in_db() {
|
||||
if ( WRIO_Plugin::app()->isNetworkActive() ) {
|
||||
return get_site_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
|
||||
}
|
||||
|
||||
return get_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.3.6
|
||||
* @see RIO_Process_Queue::fix_table_collation
|
||||
*/
|
||||
public function fix_table_collation() {
|
||||
RIO_Process_Queue::fix_table_collation();
|
||||
}
|
||||
|
||||
/**
|
||||
* This removes webp queue items from in the database. For compatibility with the new
|
||||
* version, it will be better to remove them, so that the user can start converting
|
||||
* and have no compatibility problems.
|
||||
*
|
||||
* @since 1.3.6
|
||||
*/
|
||||
public function clear_webp_queue_items() {
|
||||
global $wpdb;
|
||||
|
||||
$table_name = RIO_Process_Queue::table_name();
|
||||
$wpdb->query( "DELETE FROM {$table_name} WHERE item_type='webp'" );
|
||||
}
|
||||
|
||||
/**
|
||||
* We are removing Webp dir, since the migration will be very difficult. The previous
|
||||
* version of the plugin has serious problems in the design of webp image convertation.
|
||||
*
|
||||
* @since 1.3.6
|
||||
* @return bool
|
||||
*/
|
||||
public function clear_webp_images() {
|
||||
|
||||
require_once( WRIO_PLUGIN_DIR . '/includes/functions.php' );
|
||||
|
||||
$upload_dirs = wp_upload_dir();
|
||||
|
||||
if ( isset( $upload_dirs['error'] ) && $upload_dirs['error'] !== false ) {
|
||||
WRIO_Plugin::app()->logger->error( sprintf( 'Plugin migration error: %s', $upload_dirs['error'] ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$content_path = $upload_dirs['basedir'];
|
||||
|
||||
$dir_path = wp_normalize_path( trailingslashit( $content_path ) . 'wrio-webp-uploads' );
|
||||
|
||||
if ( file_exists( $dir_path ) ) {
|
||||
$this->clear_webp_queue_items();
|
||||
$this->plugin->updatePopulateOption( 'cleared_webp_images', 1 );
|
||||
|
||||
wrio_rmdir( $dir_path );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php #comp-page builds: premium
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates for altering the table used to store statistics data.
|
||||
* Adds new columns and renames existing ones in order to add support for the new social buttons.
|
||||
*/
|
||||
class WIOUpdate010309 extends Wbcr_Factory600_Update {
|
||||
|
||||
/**
|
||||
* {inherit}
|
||||
*
|
||||
* @since 1.3.9
|
||||
*/
|
||||
public function install() {
|
||||
|
||||
$db_version = RIO_Process_Queue::get_db_version();
|
||||
$plugin_version_in_db = $this->get_plugin_version_in_db();
|
||||
$current_plugin_version = $this->plugin->getPluginVersion();
|
||||
|
||||
$init_log_message = "Start plugin migration < %s.\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-DB Version: {$db_version}\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-Plugin Version in DB: {$plugin_version_in_db}\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-Current Plugin Version: {$current_plugin_version}";
|
||||
|
||||
WRIO_Plugin::app()->logger->info( sprintf( $init_log_message, '1.3.9' ) );
|
||||
|
||||
$this->add_indexes_in_db();
|
||||
|
||||
WBCR\Factory_Templates_759\Helpers::flushPageCache();
|
||||
|
||||
WRIO_Plugin::app()->logger->info( 'Plugin migration was successfull!' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get previous plugin version
|
||||
*
|
||||
* @return number
|
||||
* @since 1.3.9
|
||||
*/
|
||||
public function get_plugin_version_in_db() {
|
||||
if ( WRIO_Plugin::app()->isNetworkActive() ) {
|
||||
return get_site_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
|
||||
}
|
||||
|
||||
return get_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* In older plugin relises, the option 'plugin_activated' did not exist. Therefore,
|
||||
* if during migration it still does not exist, you need to add option with the current timestamp.
|
||||
*
|
||||
* @since 1.3.9
|
||||
*/
|
||||
public function update_plugin_activation_time() {
|
||||
if ( $this->plugin->isNetworkActive() ) {
|
||||
$activated = get_site_option( $this->plugin->getOptionName( 'plugin_activated' ), 0 );
|
||||
} else {
|
||||
$activated = get_option( $this->plugin->getOptionName( 'plugin_activated' ), 0 );
|
||||
}
|
||||
|
||||
if ( ! $activated ) {
|
||||
if ( $this->plugin->isNetworkActive() ) {
|
||||
update_site_option( $this->plugin->getOptionName( 'plugin_activated' ), time() );
|
||||
update_site_option( $this->plugin->getOptionName( 'plugin_version' ), $this->plugin->getPluginVersion() );
|
||||
} else {
|
||||
update_option( $this->plugin->getOptionName( 'plugin_activated' ), time() );
|
||||
update_option( $this->plugin->getOptionName( 'plugin_version' ), $this->plugin->getPluginVersion() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get previous plugin version
|
||||
*
|
||||
* @since 1.3.9
|
||||
*/
|
||||
public function add_indexes_in_db() {
|
||||
global $wpdb;
|
||||
|
||||
$table_name = RIO_Process_Queue::table_name();
|
||||
$wpdb->query( "ALTER TABLE {$table_name} ADD INDEX `index-type-attachments` (`object_id`, `item_type`);" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php #comp-page builds: premium
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates for altering the table used to store statistics data.
|
||||
* Adds new columns and renames existing ones in order to add support for the new social buttons.
|
||||
*/
|
||||
class WIOUpdate010402 extends Wbcr_Factory600_Update {
|
||||
|
||||
/**
|
||||
* {inherit}
|
||||
*
|
||||
* @since 1.3.9
|
||||
*/
|
||||
public function install() {
|
||||
|
||||
$db_version = RIO_Process_Queue::get_db_version();
|
||||
$plugin_version_in_db = $this->get_plugin_version_in_db();
|
||||
$current_plugin_version = $this->plugin->getPluginVersion();
|
||||
|
||||
$init_log_message = "Start plugin migration < %s.\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-DB Version: {$db_version}\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-Plugin Version in DB: {$plugin_version_in_db}\r\n";
|
||||
$init_log_message .= "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-Current Plugin Version: {$current_plugin_version}";
|
||||
|
||||
WRIO_Plugin::app()->logger->info( sprintf( $init_log_message, '1.4.2' ) );
|
||||
|
||||
if ( 'server_4' === WRIO_Plugin::app()->getOption( 'image_optimization_server' ) ) {
|
||||
WRIO_Plugin::app()->updateOption( 'image_optimization_server', 'server_2' );
|
||||
}
|
||||
|
||||
WRIO_Plugin::app()->logger->info( 'Plugin migration was successfull!' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get previous plugin version
|
||||
*
|
||||
* @return number
|
||||
* @since 1.3.9
|
||||
*/
|
||||
public function get_plugin_version_in_db() {
|
||||
if ( WRIO_Plugin::app()->isNetworkActive() ) {
|
||||
return get_site_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
|
||||
}
|
||||
|
||||
return get_option( WRIO_Plugin::app()->getOptionName( 'plugin_version' ), 0 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates for altering the table used to store statistics data.
|
||||
* Adds new columns and renames existing ones in order to add support for the new social buttons.
|
||||
*/
|
||||
class WIOUpdate010501 extends Wbcr_Factory480_Update {
|
||||
|
||||
/**
|
||||
* {inherit}
|
||||
*
|
||||
* @since 1.3.9
|
||||
*/
|
||||
public function install() {
|
||||
$old_dir = $this->get_old_dir();
|
||||
$new_dir = WRIO_Plugin::app()->logger->get_base_dir();
|
||||
|
||||
$files = array_diff( scandir( $old_dir ), [ '..', '.' ] );
|
||||
foreach ( $files as $file ) {
|
||||
@copy( $old_dir . $file, $new_dir . $file );
|
||||
}
|
||||
WRIO_Plugin::app()->logger->info( 'Plugin migration to 1.5.1 was successful!' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base directory, location of logs.
|
||||
*
|
||||
* @return null|string NULL in case of failure, string on success.
|
||||
*/
|
||||
public function get_old_dir() {
|
||||
$wp_upload_dir = wp_upload_dir();
|
||||
|
||||
if ( isset( $wp_upload_dir['error'] ) && $wp_upload_dir['error'] !== false ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$base_path = wp_normalize_path( trailingslashit( $wp_upload_dir['basedir'] ) . 'wrio/' );
|
||||
|
||||
$folders = glob( $base_path . 'logs-*' );
|
||||
|
||||
if ( ! empty( $folders ) ) {
|
||||
$exploded_path = explode( '/', trim( $folders[0] ) );
|
||||
$selected_logs_folder = array_pop( $exploded_path );
|
||||
} else {
|
||||
if ( function_exists( 'wp_salt' ) ) {
|
||||
$hash = md5( wp_salt() );
|
||||
} else {
|
||||
$hash = md5( AUTH_KEY );
|
||||
}
|
||||
|
||||
$selected_logs_folder = 'logs-' . $hash;
|
||||
}
|
||||
|
||||
$path = $base_path . $selected_logs_folder . '/';
|
||||
|
||||
if ( ! file_exists( $path ) ) {
|
||||
@mkdir( $path, 0755, true );
|
||||
}
|
||||
|
||||
// Create .htaccess file to protect log files
|
||||
$htaccess_path = $path . '.htaccess';
|
||||
|
||||
if ( ! file_exists( $htaccess_path ) ) {
|
||||
$htaccess_content = 'deny from all';
|
||||
@file_put_contents( $htaccess_path, $htaccess_content );
|
||||
}
|
||||
|
||||
// Create index.htm file in case .htaccess is not support as a fallback
|
||||
$index_path = $path . 'index.html';
|
||||
|
||||
if ( ! file_exists( $index_path ) ) {
|
||||
@file_put_contents( $index_path, '' );
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates for altering the table used to store statistics data.
|
||||
* Adds new columns and renames existing ones in order to add support for the new social buttons.
|
||||
*
|
||||
*/
|
||||
class WIOUpdate010802 extends Wbcr_Factory600_Update {
|
||||
|
||||
/**
|
||||
* Handles the installation process for the plugin, including cleanup of
|
||||
* old options and setting new configurations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function install() {
|
||||
WRIO_Plugin::app()->deleteOption( 'image_optimize_all_usage' );
|
||||
WRIO_Plugin::app()->deleteOption( 'image_optimize_flush_usage' );
|
||||
|
||||
WRIO_Plugin::app()->updatePopulateOption( 'server_2_quota_limit', 300 );
|
||||
|
||||
WRIO_Plugin::app()->logger->info( 'Plugin migration to 1.8.2 was successful!' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates for altering the table used to store statistics data.
|
||||
* Adds new columns and renames existing ones in order to add support for the new social buttons.
|
||||
*
|
||||
*/
|
||||
class WIOUpdate010803 extends Wbcr_Factory480_Update {
|
||||
|
||||
/**
|
||||
* Handles the installation process for the plugin, including cleanup of
|
||||
* old options and setting new configurations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function install() {
|
||||
|
||||
WRIO_Plugin::app()->updatePopulateOption( 'image_optimization_server', 'server_2' );
|
||||
WRIO_Plugin::app()->updatePopulateOption( 'server_2_quota_limit', 1000 );
|
||||
|
||||
WRIO_Plugin::app()->logger->info( 'Plugin migration to 1.8.3 was successful!' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// silence is golden
|
||||
Reference in New Issue
Block a user