From 02d65cabdfcb24313e4e0cefcc4a834aeab7d2a3 Mon Sep 17 00:00:00 2001 From: Jimmy Huang Date: Sat, 8 Jun 2024 20:55:01 +0800 Subject: [PATCH] refs #39637, fixes cache api to prevent null expiry date, correct front end testing --- CRM/Core/BAO/Cache.php | 5 ++--- CRM/SMS/BAO/Provider.php | 2 +- tests/playwright/tests/edit_mailing.spec.js | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CRM/Core/BAO/Cache.php b/CRM/Core/BAO/Cache.php index 818e12699..3c670198a 100644 --- a/CRM/Core/BAO/Cache.php +++ b/CRM/Core/BAO/Cache.php @@ -76,7 +76,6 @@ static function &getItem($group, $path, $componentID = NULL, $createdTime = 0) { $dao->group_name = $group; $dao->path = $path; $dao->component_id = $componentID; - $dao->whereAdd("expired_date >= NOW()"); if ($createdTime) { if (is_numeric($createdTime)) { $createdTime = CRM_Utils_Type::escape($createdTime, 'Positive'); @@ -246,7 +245,7 @@ static function storeSessionToCache($names, $resetSession = TRUE) { foreach ($names as $key => $sessionName) { if (is_array($sessionName)) { if (!empty($_SESSION[$sessionName[0]][$sessionName[1]])) { - $expired = isset($_SESSION[$sessionName[0]][$sessionName[1]]['expired']) ? $_SESSION[$sessionName[0]][$sessionName[1]]['expired'] : NULL; + $expired = isset($_SESSION[$sessionName[0]][$sessionName[1]]['expired']) ? $_SESSION[$sessionName[0]][$sessionName[1]]['expired'] : CRM_REQUEST_TIME+86400; self::setItem($_SESSION[$sessionName[0]][$sessionName[1]], 'CiviCRM Session', "{$sessionName[0]}_{$sessionName[1]}", NULL, $expired); // CRM_Core_Error::debug_var( "session value for: {$sessionName[0]}_{$sessionName[1]}", // $_SESSION[$sessionName[0]][$sessionName[1]] ); @@ -258,7 +257,7 @@ static function storeSessionToCache($names, $resetSession = TRUE) { } else { if (!empty($_SESSION[$sessionName])) { - $expired = isset($_SESSION[$sessionName]) ? $_SESSION[$sessionName]['expired'] : NULL; + $expired = isset($_SESSION[$sessionName]['expired']) ? $_SESSION[$sessionName]['expired'] : CRM_REQUEST_TIME+86400; self::setItem($_SESSION[$sessionName], 'CiviCRM Session', $sessionName, NULL, $expired); // CRM_Core_Error::debug_var( "session value for: {$sessionName}", // $_SESSION[$sessionName] ); diff --git a/CRM/SMS/BAO/Provider.php b/CRM/SMS/BAO/Provider.php index 5d622b77a..2e8241d22 100644 --- a/CRM/SMS/BAO/Provider.php +++ b/CRM/SMS/BAO/Provider.php @@ -80,7 +80,7 @@ public static function getProviders($selectArr = NULL, $filter = NULL, $getActiv $dao->whereAdd("(domain_id = " . CRM_Core_Config::domainID() . " OR domain_id IS NULL)"); $dao->orderBy($orderBy); $cacheId = md5(implode('|', $dao->_query)); - $providers = CRM_Core_BAO_Cache::getItem('SMS Provider', $cacheId, NULL); + $providers = CRM_Core_BAO_Cache::getItem('SMS Provider', $cacheId, NULL, CRM_REQUEST_TIME-3600); if (empty($providers)) { $dao->find(); while ($dao->fetch()) { diff --git a/tests/playwright/tests/edit_mailing.spec.js b/tests/playwright/tests/edit_mailing.spec.js index 31b752cd9..c88f5c7ae 100644 --- a/tests/playwright/tests/edit_mailing.spec.js +++ b/tests/playwright/tests/edit_mailing.spec.js @@ -127,7 +127,7 @@ test.describe.serial('Mailing Editing', () => { await test.step('Mailing Test.', async () => { /* Step 1: open "New Mailing" page */ - await page.goto('civicrm/mailing/send'); + await page.goto('civicrm/mailing/send?reset=1'); await utils.wait(wait_secs); await expect(page.locator('.crm-error')).toHaveCount(0); await utils.findElement(page, 'form#Group');