fix(ns): root-qualify PHP builtins after PSR-4 move

Namespaced classes resolved DateTimeImmutable etc. under AKSRT\*
(e.g. Credits\DateTimeImmutable). Prefix with \ globally.
This commit is contained in:
2026-07-17 15:05:03 +08:00
parent 0335517467
commit da59d550ad
7 changed files with 15 additions and 15 deletions
+1 -1
View File
@@ -282,7 +282,7 @@ class AI {
'success' => true,
'content' => $text,
];
} catch (Throwable $t) {
} catch (\Throwable $t) {
return [
'success' => false,
'message' => $t->getMessage() ?: __('WordPress AI Client 调用失败', 'aksrt'),
+1 -1
View File
@@ -228,7 +228,7 @@ class Moderation {
$decision = $this->enrich_moderation_result($decision, $commentdata);
$this->remember_result($commentdata, $decision);
} catch (Exception $e) {
} catch (\Exception $e) {
// Intentionally silent: keep moderation flow without writing runtime logs.
}
+5 -5
View File
@@ -37,7 +37,7 @@ class Download {
public function maybe_schedule_cleanup(): void {
if (!wp_next_scheduled('aksrt_dl_token_cleanup')) {
$next = (new DateTimeImmutable('tomorrow 03:30', wp_timezone()))->getTimestamp();
$next = (new \DateTimeImmutable('tomorrow 03:30', wp_timezone()))->getTimestamp();
wp_schedule_event($next, 'daily', 'aksrt_dl_token_cleanup');
}
}
@@ -49,8 +49,8 @@ class Download {
$table = \AKSRT\Core\DBMigrator::table('dl_token');
if (!$table) return;
$now_utc = (new DateTimeImmutable('now', new DateTimeZone('UTC')))->format('Y-m-d H:i:s');
$audit_cutoff = (new DateTimeImmutable('-7 days', new DateTimeZone('UTC')))->format('Y-m-d H:i:s');
$now_utc = (new \DateTimeImmutable('now', new \DateTimeZone('UTC')))->format('Y-m-d H:i:s');
$audit_cutoff = (new \DateTimeImmutable('-7 days', new \DateTimeZone('UTC')))->format('Y-m-d H:i:s');
$wpdb->query($wpdb->prepare(
"DELETE FROM {$table} WHERE expires_at < %s",
@@ -417,8 +417,8 @@ class Download {
$ip = function_exists('aksrt_get_client_ip') ? (string) aksrt_get_client_ip() : (string) ($_SERVER['REMOTE_ADDR'] ?? '');
$ua_hash = sha1((string) ($_SERVER['HTTP_USER_AGENT'] ?? ''));
$now_utc = (new DateTimeImmutable('now', new DateTimeZone('UTC')))->format('Y-m-d H:i:s');
$expires_utc = (new DateTimeImmutable('now', new DateTimeZone('UTC')))->modify('+' . self::TOKEN_TTL . ' seconds')->format('Y-m-d H:i:s');
$now_utc = (new \DateTimeImmutable('now', new \DateTimeZone('UTC')))->format('Y-m-d H:i:s');
$expires_utc = (new \DateTimeImmutable('now', new \DateTimeZone('UTC')))->modify('+' . self::TOKEN_TTL . ' seconds')->format('Y-m-d H:i:s');
$ok = $wpdb->insert(
$table,
+1 -1
View File
@@ -57,7 +57,7 @@ class Earn {
if ($user_id <= 0 || !class_exists('PointsFree')) {
return;
}
$today = (new DateTimeImmutable('today', wp_timezone()))->format('Y-m-d');
$today = (new \DateTimeImmutable('today', wp_timezone()))->format('Y-m-d');
$last = (string) get_user_meta($user_id, PointsFree::META_LOGIN, true);
if ($last === $today) {
return;
+1 -1
View File
@@ -238,7 +238,7 @@ class Invite {
$log_table = \AKSRT\Core\DBMigrator::table('credit_log');
if (!$log_table) return true;
$today_utc = (new DateTimeImmutable('today', wp_timezone()))->setTimezone(new DateTimeZone('UTC'))->format('Y-m-d H:i:s');
$today_utc = (new \DateTimeImmutable('today', wp_timezone()))->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i:s');
$count = (int) $wpdb->get_var($wpdb->prepare(
"SELECT COUNT(*) FROM {$log_table} WHERE reason = 'invite' AND ip = %s AND created_at >= %s",
$ip,
+1 -1
View File
@@ -269,7 +269,7 @@ class PointsFree {
}
private static function today_key(): string {
return (new DateTimeImmutable('today', wp_timezone()))->format('Y-m-d');
return (new \DateTimeImmutable('today', wp_timezone()))->format('Y-m-d');
}
/**
+5 -5
View File
@@ -153,7 +153,7 @@ class Signin {
/** 站点时区下的今日日期 'Y-m-d' */
private function today_date(): string {
return (new DateTimeImmutable('today', wp_timezone()))->format('Y-m-d');
return (new \DateTimeImmutable('today', wp_timezone()))->format('Y-m-d');
}
/** 取签到记录 */
@@ -181,7 +181,7 @@ class Signin {
$table = \AKSRT\Core\DBMigrator::table('signin_log');
if (!$table) return [];
$from_date = (new DateTimeImmutable("-{$days} days", wp_timezone()))->format('Y-m-d');
$from_date = (new \DateTimeImmutable("-{$days} days", wp_timezone()))->format('Y-m-d');
$rows = $wpdb->get_results($wpdb->prepare(
"SELECT signin_date FROM {$table} WHERE user_id = %d AND signin_date >= %s ORDER BY signin_date ASC",
@@ -209,19 +209,19 @@ class Signin {
if (empty($rows)) return 0;
$dates = array_map(fn($r) => $r['signin_date'], $rows);
$today = new DateTimeImmutable($today_str);
$today = new \DateTimeImmutable($today_str);
$tz = wp_timezone();
// 起点:若今天已签则从今天回看,否则从昨天回看
$cursor = in_array($today_str, $dates, true)
? $today
: $today->sub(new DateInterval('P1D'));
: $today->sub(new \DateInterval('P1D'));
$count = 0;
foreach ($dates as $d) {
if ($d === $cursor->format('Y-m-d')) {
$count++;
$cursor = $cursor->sub(new DateInterval('P1D'));
$cursor = $cursor->sub(new \DateInterval('P1D'));
} else {
break;
}