From c5a8985c0be3a5a8a5b99a625596b9861f8d63de Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 19 Oct 2013 15:06:43 +0000 Subject: [PATCH] Added assert() + commented in debug lines --- inc/classes/main/class_BaseFrameworkSystem.php | 2 +- inc/classes/main/criteria/class_BaseCriteria.php | 6 ++++-- inc/classes/main/database/class_BaseDatabaseWrapper.php | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 4207299b..6c06b03f 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -2017,7 +2017,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected function getCacheKeyByCriteria (Criteria $criteriaInstance, array $onlyKeys = array()) { // Generate it - $cacheKey = sprintf("%s@%s", + $cacheKey = sprintf('%s@%s', $this->__toString(), $criteriaInstance->getCacheKey($onlyKeys) ); diff --git a/inc/classes/main/criteria/class_BaseCriteria.php b/inc/classes/main/criteria/class_BaseCriteria.php index 929b048f..9e1be5b0 100644 --- a/inc/classes/main/criteria/class_BaseCriteria.php +++ b/inc/classes/main/criteria/class_BaseCriteria.php @@ -358,6 +358,8 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria { foreach ($this->getGenericArrayKey('criteria', $criteriaType, 'entries') as $criteriaKey => $criteriaValue) { // Make sure no 'my-' or 'my_' passes this point assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue))); + + // $criteriaValue cannot be an array assert(!is_array($criteriaValue)); // Convert dashes to underscore @@ -366,7 +368,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria { // Is the value in array or is $onlyKeys empty? if ((isset($onlyKeys[$criteriaKey])) || (count($onlyKeys) == 0)) { // Add the value URL encoded to avoid any trouble with special characters - $cacheKey .= sprintf("%s=%s;", + $cacheKey .= sprintf('%s=%s;', $criteriaKey, urlencode($criteriaValue) ); @@ -381,7 +383,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria { // Check if 'limit' and 'skip' are in if (((isset($onlyKeys['limit'])) && (isset($onlyKeys['skip']))) || (count($onlyKeys) == 0)) { // Add limit and skip values - $cacheKey .= sprintf(";%%limit%%=%s;%%skip%%=%s", + $cacheKey .= sprintf(';%%limit%%=%s;%%skip%%=%s', $this->getLimit(), $this->getSkip() ); diff --git a/inc/classes/main/database/class_BaseDatabaseWrapper.php b/inc/classes/main/database/class_BaseDatabaseWrapper.php index 65c4445b..d507f2c3 100644 --- a/inc/classes/main/database/class_BaseDatabaseWrapper.php +++ b/inc/classes/main/database/class_BaseDatabaseWrapper.php @@ -151,13 +151,13 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem { // Does this key exists in cache? if ($this->cacheInstance->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1)) { // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey . ':' . print_r($this->cacheInstance->offsetGet($cacheKey), TRUE)); + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey . ':' . print_r($this->cacheInstance->offsetGet($cacheKey), TRUE)); // Then use this result $result = $this->cacheInstance->offsetGet($cacheKey); } else { // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Quering database, cacheKey=' . $cacheKey); + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Quering database, cacheKey=' . $cacheKey); // Now it's time to ask the database layer for this select statement $result = $this->getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance); -- 2.39.5