X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FCache%2FNaiveHasTrait.php;h=786e8c0d21a9e1be0ed2f6e603ebb3cc59d2f8fb;hb=701fd7a63eb4b10a6b91a91c0c05dba1bbaf8b69;hp=78ecc678876373ff384fea8a29a8aac08d5560df;hpb=d8a2e00c3378588febd37dcc31b8bf8e68f829c3;p=civicrm-core.git diff --git a/CRM/Utils/Cache/NaiveHasTrait.php b/CRM/Utils/Cache/NaiveHasTrait.php index 78ecc67887..786e8c0d21 100644 --- a/CRM/Utils/Cache/NaiveHasTrait.php +++ b/CRM/Utils/Cache/NaiveHasTrait.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2018 | + | Copyright CiviCRM LLC (c) 2004-2019 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,22 +28,19 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2018 + * @copyright CiviCRM LLC (c) 2004-2019 * * The traditional CRM_Utils_Cache_Interface did not support has(). * To get drop-in compliance with PSR-16, we use a naive adapter. * - * Ideally, these should be replaced with more performant/native versions. + * There may be opportunities to replace/optimize in specific drivers. */ trait CRM_Utils_Cache_NaiveHasTrait { public function has($key) { - // This is crazy-talk. If you've got an environment setup where you might - // be investigating this, fix your preferred cache driver by - // replacing `NaiveHasTrait` with a decent function. - $hasDefaultA = ($this->get($key, NULL) === NULL); - $hasDefaultB = ($this->get($key, 123) === 123); - return !($hasDefaultA && $hasDefaultB); + $nack = CRM_Utils_Cache::nack(); + $value = $this->get($key, $nack); + return ($value !== $nack); } }