From fb6eabf80c553c552c0884b483a1678c3c20c037 Mon Sep 17 00:00:00 2001 From: Jan-Niclas Loosen Date: Sat, 26 Sep 2026 17:36:23 +0200 Subject: [PATCH] refactor: one wpdb accessor style (L4) The three lazy db() methods use the $this->db ?? $GLOBALS['wpdb'] one-liner that SampledMetaSource, MediaUsageFinder and ConnectionRepository already use. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/ChangeLog/ChangeLog.php | 7 +------ src/Integrations/Divi/Pages/DiviReplaceTextAbility.php | 7 +------ src/Integrations/WordPress/Status/PostCloner.php | 7 +------ 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/ChangeLog/ChangeLog.php b/src/ChangeLog/ChangeLog.php index 574c2db..0ef0c0a 100644 --- a/src/ChangeLog/ChangeLog.php +++ b/src/ChangeLog/ChangeLog.php @@ -181,11 +181,6 @@ class ChangeLog protected function db(): \wpdb { - if ($this->db === null) { - global $wpdb; - $this->db = $wpdb; - } - - return $this->db; + return $this->db ?? $GLOBALS['wpdb']; } } diff --git a/src/Integrations/Divi/Pages/DiviReplaceTextAbility.php b/src/Integrations/Divi/Pages/DiviReplaceTextAbility.php index e37b66f..f7189da 100644 --- a/src/Integrations/Divi/Pages/DiviReplaceTextAbility.php +++ b/src/Integrations/Divi/Pages/DiviReplaceTextAbility.php @@ -490,11 +490,6 @@ final class DiviReplaceTextAbility implements Ability private function db(): \wpdb { - if ($this->db === null) { - global $wpdb; - $this->db = $wpdb; - } - - return $this->db; + return $this->db ?? $GLOBALS['wpdb']; } } diff --git a/src/Integrations/WordPress/Status/PostCloner.php b/src/Integrations/WordPress/Status/PostCloner.php index fdfa993..ed4a991 100644 --- a/src/Integrations/WordPress/Status/PostCloner.php +++ b/src/Integrations/WordPress/Status/PostCloner.php @@ -362,11 +362,6 @@ class PostCloner private function db(): \wpdb { - if ($this->db === null) { - global $wpdb; - $this->db = $wpdb; - } - - return $this->db; + return $this->db ?? $GLOBALS['wpdb']; } }