Skip to content

Commit

Permalink
Merge develop to master (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkrcho authored Mar 25, 2022
1 parent ee6b1ca commit 6508e99
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 29 deletions.
18 changes: 18 additions & 0 deletions classes/Upgrade/Upgrade_43000_To_44400.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ public function __construct( WpSecurityAuditLog $plugin ) {
*/
public function run() {

// Delete unwanted usermeta.
global $wpdb;
$wpdb->query( // phpcs:ignore
$wpdb->prepare(
"DELETE FROM {$wpdb->usermeta} WHERE meta_key = '%s';", // phpcs:ignore
'wsal-notice-update-44-notice'
)
);

if ( class_exists( 'WSAL_Extension_Manager' ) ) {
WSAL_Extension_Manager::include_extension( 'external-db' );
}

if ( ! did_action( 'wsal_init' ) ) {
// We need to call wsal init manually because it does not run as before the upgrade procedure is triggered.
do_action( 'wsal_init', $this->plugin );
}

// Remove some forgotten WFCM settings from the options table.
$this->remove_wfcm_leftover_settings();

Expand Down
2 changes: 1 addition & 1 deletion third-party/vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInitb9d672d234a3d43fa8ace493e8708e77::getLoader();
return ComposerAutoloaderInit3f2af4d6ad50de85879f0d0ae1ddc459::getLoader();
10 changes: 5 additions & 5 deletions third-party/vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInitb9d672d234a3d43fa8ace493e8708e77
class ComposerAutoloaderInit3f2af4d6ad50de85879f0d0ae1ddc459
{
private static $loader;

Expand All @@ -21,16 +21,16 @@ public static function getLoader()
if (null !== self::$loader) {
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInitb9d672d234a3d43fa8ace493e8708e77', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit3f2af4d6ad50de85879f0d0ae1ddc459', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitb9d672d234a3d43fa8ace493e8708e77', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit3f2af4d6ad50de85879f0d0ae1ddc459', 'loadClassLoader'));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInitb9d672d234a3d43fa8ace493e8708e77::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit3f2af4d6ad50de85879f0d0ae1ddc459::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
Expand Down
4 changes: 2 additions & 2 deletions third-party/vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInitb9d672d234a3d43fa8ace493e8708e77
class ComposerStaticInit3f2af4d6ad50de85879f0d0ae1ddc459
{
public static $classMap = array (
'WSAL_Vendor\\MirazMac\\Requirements\\Checker' => __DIR__ . '/..' . '/mirazmac/php-requirements-checker/src/Checker.php',
Expand All @@ -15,7 +15,7 @@ class ComposerStaticInitb9d672d234a3d43fa8ace493e8708e77
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->classMap = ComposerStaticInitb9d672d234a3d43fa8ace493e8708e77::$classMap;
$loader->classMap = ComposerStaticInit3f2af4d6ad50de85879f0d0ae1ddc459::$classMap;
}, null, ClassLoader::class);
}
}
46 changes: 25 additions & 21 deletions wp-security-audit-log.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ public static function is_wpseo_active() {
*/
public static function is_mainwp_active() {
return self::is_plugin_active( 'mainwp-child/mainwp-child.php' );

}

/**
Expand Down Expand Up @@ -1321,11 +1322,18 @@ public function update( $old_version, $new_version ) {
// Update version in db.
$this->set_global_setting( 'version', $new_version, true );

// Keep track of the initial db version. This gets updated multiple times during the upgrade process
// and we need to know what was the starting point.
$initial_db_version = $this->settings()->get_database_version();

if ( '0.0.0' === $old_version ) {
// Set some initial plugins settings (only the ones that bypass the regular settings retrieval at
// some point) - e.g. disabled events.
$this->set_global_setting( 'disabled-alerts', implode( ',', $this->settings()->always_disabled_alerts ) );

// We set the database version to the latest if this is a freshly installed plugin.
$this->settings()->set_database_version( 44400 );

// We stop here as no further updates are needed for a freshly installed plugin.
return;
}
Expand Down Expand Up @@ -1422,31 +1430,27 @@ public function update( $old_version, $new_version ) {
}

if ( version_compare( $new_version, '4.4.0', '>=' ) ) {
// Delete unwanted usermeta.
global $wpdb;
$all_user_meta = $wpdb->get_results( // phpcs:ignore
$wpdb->prepare(
"DELETE FROM {$wpdb->usermeta} WHERE meta_key = '%s';", // phpcs:ignore
'wsal-notice-update-44-notice'
)
);

$this->settings()->set_database_version( 44400 );

if ( class_exists( 'WSAL_Extension_Manager' ) ) {
WSAL_Extension_Manager::include_extension( 'external-db' );
$should_440_upgrade_run = true;
if ( 44400 === $initial_db_version ) {
// Database version is 44400 if someone already upgraded from any version to 4.4.0.
$should_440_upgrade_run = false;
} elseif ( 0 === $initial_db_version ) {
// Database version is 0 if the plugin was never upgraded. This could be an upgrade from
// 4.3.6, 4.4.0 or any other lower version.
$should_440_upgrade_run = false;
if ( version_compare( $old_version, '4.4.0', '<' ) ) {
// We are upgrading from pre-4.4.0 version.
$should_440_upgrade_run = true;
}
}

if ( ! did_action( 'wsal_init' ) ) {
// We need to call wsal init manually because it does not run as before the upgrade procedure is triggered.
do_action( 'wsal_init', $this );
if ( $should_440_upgrade_run ) {
require_once 'classes/Upgrade/Upgrade_43000_To_44400.php';
$upgrader = new WSAL_Upgrade_43000_To_44400( $this );
$upgrader->run();
}

require_once 'classes/Upgrade/Upgrade_43000_To_44400.php';
$upgrader = new WSAL_Upgrade_43000_To_44400( $this );
$upgrader->run();

// @todo remove legacy periodic reports for unique_ip and number_logins
$this->settings()->set_database_version( 44400 );
}
}
}
Expand Down

0 comments on commit 6508e99

Please sign in to comment.