From f7a7c7b58899eced94f134ef587f8b93aa1ff3d3 Mon Sep 17 00:00:00 2001 From: colemanw Date: Wed, 15 Nov 2023 11:34:45 -0500 Subject: [PATCH] APIv4 - Minor cleanup of redundant variables Is it just me, or does staring at the word today for too long stop making sense? --- .../Service/Spec/Provider/IsCurrentFieldSpecProvider.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Civi/Api4/Service/Spec/Provider/IsCurrentFieldSpecProvider.php b/Civi/Api4/Service/Spec/Provider/IsCurrentFieldSpecProvider.php index 29ce637ad8..afe41cbe41 100644 --- a/Civi/Api4/Service/Spec/Provider/IsCurrentFieldSpecProvider.php +++ b/Civi/Api4/Service/Spec/Provider/IsCurrentFieldSpecProvider.php @@ -81,9 +81,8 @@ class IsCurrentFieldSpecProvider extends \Civi\Core\Service\AutoService implemen $startDate = substr_replace($field['sql_name'], 'start_date', -11, -1); $endDate = substr_replace($field['sql_name'], 'end_date', -11, -1); $isActive = substr_replace($field['sql_name'], 'is_active', -11, -1); - $todayStart = date('Ymd', strtotime('now')); - $todayEnd = date('Ymd', strtotime('now')); - return "IF($isActive = 1 AND ($startDate <= '$todayStart' OR $startDate IS NULL) AND ($endDate >= '$todayEnd' OR $endDate IS NULL), '1', '0')"; + $today = date('Ymd'); + return "IF($isActive = 1 AND ($startDate <= '$today' OR $startDate IS NULL) AND ($endDate >= '$today' OR $endDate IS NULL), '1', '0')"; } /** @@ -95,8 +94,8 @@ class IsCurrentFieldSpecProvider extends \Civi\Core\Service\AutoService implemen */ public static function renderNonExpiredSql(array $field): string { $endDate = substr_replace($field['sql_name'], 'expires_date', -11, -1); - $todayEnd = date('Ymd'); - return "IF($endDate >= '$todayEnd' OR $endDate IS NULL, 1, 0)"; + $today = date('Ymd'); + return "IF($endDate >= '$today' OR $endDate IS NULL, 1, 0)"; } } -- 2.25.1