HEX
Server: Apache/2.4.65 (Debian)
System: Linux 88f31f35b0b8 6.1.0-38-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.147-1 (2025-08-02) x86_64
User: www-data (33)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/advanced-ads-tracking/upgrades/upgrade-1-7.php
<?php
/**
 * Update routine
 *
 * @package AdvancedAds
 * @author  Advanced Ads <info@wpadvancedads.com>
 * @since   1.6
 */

use AdvancedAds\Tracking\Database;

/**
 * Hotfix for missing stats on new year
 *
 * @since 1.6
 *
 * @param string $table Table name.
 *
 * @return void
 */
function advads_fix_stats( $table ): void {
	global $wpdb;

	$start = 2512012806;
	$end   = 2512013106;
	$rows  = $wpdb->get_results( "SELECT * FROM $table WHERE `timestamp` BETWEEN $start AND $end" );

	if ( ! empty( $rows ) ) {
		foreach ( $rows as $row ) {
			$ts = str_replace( '01', '52', $row->timestamp );
			$wpdb->query( "UPDATE $table SET `timestamp` = $ts WHERE `timestamp` = $row->timestamp AND `ad_id` = $row->ad_id" );
		}
	}
}

/**
 * Update something
 *
 * @since 1.6
 *
 * @return void
 */
function advads_upgrade_1_7_fix_stats(): void {
	advads_fix_stats( Database::get_impression_table() );
	advads_fix_stats( Database::get_click_table() );
}

advads_upgrade_1_7_fix_stats();