Added assert() + commented in debug lines
authorRoland Häder <roland@mxchange.org>
Sat, 19 Oct 2013 15:06:43 +0000 (15:06 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 19 Oct 2013 15:06:43 +0000 (15:06 +0000)
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/criteria/class_BaseCriteria.php
inc/classes/main/database/class_BaseDatabaseWrapper.php

index 4207299..6c06b03 100644 (file)
@@ -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)
                );
index 929b048..9e1be5b 100644 (file)
@@ -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()
                                );
index 65c4445..d507f2c 100644 (file)
@@ -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);