From: colemanw Date: Wed, 15 Nov 2023 16:34:45 +0000 (-0500) Subject: APIv4 - Minor cleanup of redundant variables X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f7a7c7b58899eced94f134ef587f8b93aa1ff3d3;p=civicrm-core.git APIv4 - Minor cleanup of redundant variables Is it just me, or does staring at the word today for too long stop making sense? --- 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)"; } }