From: Tim Otten Date: Mon, 2 Jul 2018 20:07:03 +0000 (-0700) Subject: (dev/core#217) PrevNext - Sanitize the `getSelection()` contract X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=40ddbe99be49f36c08d24f2955ecf09b06dc4ef6;p=civicrm-core.git (dev/core#217) PrevNext - Sanitize the `getSelection()` contract 1. Improve docblock formatting 2. The `$entity_table` is never passed in. You can see this by grepping universe for `getSelection`. --- diff --git a/CRM/Core/BAO/PrevNextCache.php b/CRM/Core/BAO/PrevNextCache.php index 95b90b8e9d..8b19aef581 100644 --- a/CRM/Core/BAO/PrevNextCache.php +++ b/CRM/Core/BAO/PrevNextCache.php @@ -448,8 +448,8 @@ AND c.created_date < date_sub( NOW( ), INTERVAL %2 day ) * @deprecated * @see CRM_Core_PrevNextCache_Sql::getSelection() */ - public static function getSelection($cacheKey, $action = 'get', $entity_table = 'civicrm_contact') { - return Civi::service('prevnext')->getSelection($cacheKey, $action, $entity_table); + public static function getSelection($cacheKey, $action = 'get') { + return Civi::service('prevnext')->getSelection($cacheKey, $action); } /** diff --git a/CRM/Core/PrevNextCache/Interface.php b/CRM/Core/PrevNextCache/Interface.php index 212482fbd6..364e0b402b 100644 --- a/CRM/Core/PrevNextCache/Interface.php +++ b/CRM/Core/PrevNextCache/Interface.php @@ -76,14 +76,12 @@ interface CRM_Core_PrevNextCache_Interface { * @param string $cacheKey * Cache key. * @param string $action - * Action. - * $action : get - get only selection records - * getall - get all the records of the specified cache key - * @param string $entity_table - * Entity table. + * One of the following: + * - 'get' - get only selection records + * - 'getall' - get all the records of the specified cache key * * @return array|NULL */ - public function getSelection($cacheKey, $action = 'get', $entity_table = 'civicrm_contact'); + public function getSelection($cacheKey, $action = 'get'); } diff --git a/CRM/Core/PrevNextCache/Sql.php b/CRM/Core/PrevNextCache/Sql.php index 9f7d99dc4e..5febfe2fed 100644 --- a/CRM/Core/PrevNextCache/Sql.php +++ b/CRM/Core/PrevNextCache/Sql.php @@ -138,15 +138,15 @@ WHERE cacheKey LIKE %1 AND is_selected = 1 * @param string $cacheKey * Cache key. * @param string $action - * Action. - * $action : get - get only selection records - * getall - get all the records of the specified cache key - * @param string $entity_table - * Entity table. + * One of the following: + * - 'get' - get only selection records + * - 'getall' - get all the records of the specified cache key * * @return array|NULL */ - public function getSelection($cacheKey, $action = 'get', $entity_table = 'civicrm_contact') { + public function getSelection($cacheKey, $action = 'get') { + $entity_table = 'civicrm_contact'; + if (!$cacheKey) { return NULL; }