From d355aab69acaed998aa7c68ea7d582e38da9addb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 17 Feb 2023 19:44:10 +0100 Subject: [PATCH] Continued: - renamed getPrimaryKeyValue() to generatePrimaryKey() - added more debug lines - added more checks for parameter --- framework/loader/class_ClassLoader.php | 2 +- .../frontend/class_BaseDatabaseFrontend.php | 80 ++++++++++++++----- .../binary/index/class_IndexFile.php | 14 ++-- .../binary/stack/class_StackFile.php | 18 ++--- .../file_directories/class_BaseFileIo.php | 2 +- .../class_FrameworkFileInputOutputPointer.php | 4 +- .../index/file/class_BaseFileIndex.php | 18 ++--- .../index/file/stack/class_FileStackIndex.php | 4 +- .../classes/stacker/class_BaseStacker.php | 2 +- .../stacker/fifo/class_FiFoStacker.php | 11 ++- .../stacker/file/class_BaseFileStack.php | 20 ++--- .../stacker/file/fifo/class_FiFoFileStack.php | 4 +- .../stacker/filo/class_FiLoStacker.php | 2 +- .../main/classes/user/class_BaseUser.php | 2 +- .../frontend/class_DatabaseFrontend.php | 4 +- .../database/class_DatabaseConnection.php | 2 +- 16 files changed, 115 insertions(+), 74 deletions(-) diff --git a/framework/loader/class_ClassLoader.php b/framework/loader/class_ClassLoader.php index 07dfd842..a9de4ee0 100644 --- a/framework/loader/class_ClassLoader.php +++ b/framework/loader/class_ClassLoader.php @@ -399,7 +399,7 @@ final class ClassLoader { } // Try to include this class - //* NOISY-DEBUG: */ printf('[%s:%d]: Calling self->loadClassFile(%s) ...' . PHP_EOL, __METHOD__, __LINE__, $className); + //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking self->loadClassFile(%s) ...' . PHP_EOL, __METHOD__, __LINE__, $className); self::getSelfInstance()->loadClassFile($className); // Trace message diff --git a/framework/main/classes/database/frontend/class_BaseDatabaseFrontend.php b/framework/main/classes/database/frontend/class_BaseDatabaseFrontend.php index 2f4320cc..23de87b3 100644 --- a/framework/main/classes/database/frontend/class_BaseDatabaseFrontend.php +++ b/framework/main/classes/database/frontend/class_BaseDatabaseFrontend.php @@ -12,6 +12,9 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Result\Database\BaseDatabaseResult; use Org\Mxchange\CoreFramework\Traits\Cache\CacheableTrait; +// Import SPL stuff +use \InvalidArgumentException; + /** * A generic database frontend * @@ -55,10 +58,14 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { */ protected function __construct (string $className) { // Call parent constructor + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATABASE-FRONTEND: CONSTRUCTED!'); parent::__construct($className); // Initialize the cache instance $this->initCacheInstance(); + + // Trace message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATABASE-FRONTEND: EXIT!'); } /** @@ -68,13 +75,18 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { */ private final function initCacheInstance () { // Set "cache" attributes + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATABASE-FRONTEND: CALLED!'); $this->databaseCacheEnabled = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled'); // Is the cache enabled? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d', intval($this->databaseCacheEnabled))); if ($this->databaseCacheEnabled === true) { // Set the new instance $this->setCacheInstance(ObjectFactory::createObjectByConfiguredName('cache_class')); } + + // Trace message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATABASE-FRONTEND: EXIT!'); } /** @@ -105,7 +117,7 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { */ protected function getCacheKeyByCriteria (Criteria $criteriaInstance, array $onlyKeys = []) { // Generate it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRAMEWORK-SYSTEM: criteriaInstance=' . $criteriaInstance->__toString() . ',onlyKeys()=' . count($onlyKeys) . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: criteriaInstance=%s,onlyKeys()=%d - CALLED!', $criteriaInstance->__toString(), count($onlyKeys))); $cacheKey = sprintf('%s@%s', $this->__toString(), $criteriaInstance->getCacheKey($onlyKeys) @@ -125,21 +137,22 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { */ protected function queryInsertDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = []) { // Default cache key is NULL - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: dataSetInstance=%s,onlyKeys()=%d - CALLED!', $dataSetInstance->__toString(), count($onlyKeys))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: dataSetInstance=%s,onlyKeys()=%d - CALLED!', $dataSetInstance->__toString(), count($onlyKeys))); $cacheKey = NULL; // Is cache enabled? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d', intval($this->databaseCacheEnabled))); if ($this->databaseCacheEnabled === true) { // First get a key suitable for our cache and extend it with this class name $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys); - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRONTEND: Using cache key ' . $cacheKey . ' for purging ...'); + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: Using cache key %s for purging ...', $cacheKey)); } // Does this key exists in cache? - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d,cacheKey[%s]=%s', intval($this->databaseCacheEnabled), gettype($cacheKey), $cacheKey)); if (($this->databaseCacheEnabled === true) && ($this->getCacheInstance()->offsetExists($cacheKey))) { // Purge the cache - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: Calling this->cacheInstance->purgeOffset(%s) ...', $cacheKey)); + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: Invoking this->cacheInstance->purgeOffset(%s) ...', $cacheKey)); $this->getCacheInstance()->purgeOffset($cacheKey); } @@ -147,7 +160,7 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { FrameworkBootstrap::getDatabaseInstance()->queryInsertDataSet($dataSetInstance); // Trace message - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRONTEND: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATABASE-FRONTEND: EXIT!'); } /** @@ -159,16 +172,19 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { */ protected function queryUpdateDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = []) { // Init cache key + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: dataSetInstance=%s,onlyKeys()=%d - CALLED!', $dataSetInstance->__toString(), count($onlyKeys))); $cacheKey = NULL; // Is cache enabled? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d', intval($this->databaseCacheEnabled))); if ($this->databaseCacheEnabled === true) { // First get a key suitable for our cache and extend it with this class name $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys); - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRONTEND: Using cache key ' . $cacheKey . ' for purging ...'); + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATABASE-FRONTEND: Using cache key ' . $cacheKey . ' for purging ...'); } // Does this key exists in cache? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d,cacheKey=%s', intval($this->databaseCacheEnabled), $cacheKey)); if (($this->databaseCacheEnabled === true) && ($this->getCacheInstance()->offsetExists($cacheKey))) { // Purge the cache $this->getCacheInstance()->purgeOffset($cacheKey); @@ -176,6 +192,9 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { // Handle it over to the middleware FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); + + // Trace message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATABASE-FRONTEND: EXIT!'); } /** @@ -184,6 +203,7 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { * @return $indexKey Index key */ public final function getIndexKey () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATABASE-FRONTEND: CALLED!'); return FrameworkBootstrap::getDatabaseInstance()->getIndexKey(); } @@ -193,6 +213,7 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { * @return $lastException Last exception or NULL if none occured */ public final function getLastException () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATABASE-FRONTEND: CALLED!'); return FrameworkBootstrap::getDatabaseInstance()->getLastException(); } @@ -206,34 +227,36 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { */ public function doSelectByCriteria (Criteria $criteriaInstance, array $onlyKeys = []) { // Default cache key if cache is not enabled - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: criteriaInstance=%s,onlyKeys()=%d - CALLED!', $criteriaInstance->__toString(), count($onlyKeys))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: criteriaInstance=%s,onlyKeys()=%d - CALLED!', $criteriaInstance->__toString(), count($onlyKeys))); $cacheKey = NULL; $result = []; // Is the cache enabled? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d', intval($this->databaseCacheEnabled))); if ($this->databaseCacheEnabled === true) { // First get a key suitable for our cache and extend it with this class name $cacheKey = $this->getCacheKeyByCriteria($criteriaInstance, $onlyKeys); } // Does this key exists in cache? - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d,cacheKey[%s]=%s', intval($this->databaseCacheEnabled), gettype($cacheKey), $cacheKey)); if (($this->databaseCacheEnabled === true) && ($this->getCacheInstance()->offsetExists($cacheKey, BaseDatabaseResult::RESULT_NAME_ROWS, 1))) { // Then use this result - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: Cache used for cacheKey=%s', $cacheKey)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: Cache used for cacheKey=%s', $cacheKey)); $result = $this->getCacheInstance()->offsetGet($cacheKey); } else { // Now it's time to ask the database layer for this select statement - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: Quering database, cacheKey=%s ...', $cacheKey)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: Quering database, cacheKey=%s ...', $cacheKey)); $result = FrameworkBootstrap::getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance); // Cache the result if not null - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: result[]=%s', gettype($result))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: result[]=%s', gettype($result))); if (!is_null($result)) { // Is cache enabled? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d', intval($this->databaseCacheEnabled))); if ($this->databaseCacheEnabled === true) { // A valid result has returned from the database layer - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: Setting cacheKey=%s with result()=%d entries', $cacheKey, count($result))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: Setting cacheKey=%s with result()=%d entries', $cacheKey, count($result))); $this->getCacheInstance()->offsetSet($cacheKey, $result); } } else { @@ -247,11 +270,11 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { // Create an instance of a CachedDatabaseResult class with the given result // @TODO Minor: Update above comment to e.g. BaseDatabaseResult - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: result[%s]=%s,result[%s]?=%d,result[%s]?=%d', BaseDatabaseResult::RESULT_NAME_STATUS, $result[BaseDatabaseResult::RESULT_NAME_STATUS], BaseDatabaseResult::RESULT_NAME_ROWS, isset($result[BaseDatabaseResult::RESULT_NAME_ROWS]), BaseDatabaseResult::RESULT_NAME_EXCEPTION, isset($result[BaseDatabaseResult::RESULT_NAME_EXCEPTION]))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: result[%s]=%s,result[%s]?=%d,result[%s]?=%d', BaseDatabaseResult::RESULT_NAME_STATUS, $result[BaseDatabaseResult::RESULT_NAME_STATUS], BaseDatabaseResult::RESULT_NAME_ROWS, isset($result[BaseDatabaseResult::RESULT_NAME_ROWS]), BaseDatabaseResult::RESULT_NAME_EXCEPTION, isset($result[BaseDatabaseResult::RESULT_NAME_EXCEPTION]))); $resultInstance = ObjectFactory::createObjectByConfiguredName('database_result_class', array($result)); // And return the instance - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: resultInstance=%s - EXIT!', $resultInstance->__toString())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: resultInstance=%s - EXIT!', $resultInstance->__toString())); return $resultInstance; } @@ -264,34 +287,36 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { */ public function doSelectCountByCriteria (Criteria $criteriaInstance, array $onlyKeys = []) { // Total numbers is -1 so we can distinglish between failed and valid queries + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: criteriaInstance=%s,onlyKeys()=%d - CALLED!', $criteriaInstance->__toString(), count($onlyKeys))); $numRows = 0; // Get the result from above method $resultInstance = $this->doSelectByCriteria($criteriaInstance, $onlyKeys); // Was that query fine? + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: resultInstance->ifStatusIsOkay()=%d', $resultInstance->ifStatusIsOkay())); if ($resultInstance->ifStatusIsOkay()) { // Then get the number of rows $numRows = $resultInstance->getAffectedRows(); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRONTEND: numRows=' . $numRows); } // Return the result + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: numRows=%d - EXIT!', $numRows)); return $numRows; } /** - * Getter for primary key used in wrapped table + * Generates a primary key for this database frontend * * @return $primaryKey Primary key used in wrapped table */ - public final function getPrimaryKeyValue () { + public final function generatePrimaryKey () { // Get the table name and a database instance and ask for it + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATABASE-FRONTEND: CALLED!'); $primaryKey = FrameworkBootstrap::getDatabaseInstance()->getPrimaryKeyOfTable($this->getTableName()); // Return value + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: primaryKey=%s - EXIT!', $primaryKey)); return $primaryKey; } @@ -302,9 +327,11 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { */ public final function countTotalRows () { // Get the table name and a database instance and ask for it + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATABASE-FRONTEND: CALLED!'); $count = FrameworkBootstrap::getDatabaseInstance()->countTotalRows($this->getTableName()); // Return value + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: count=%d - EXIT!', $count)); return $count; } @@ -313,12 +340,21 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { * * @param $data An array with possible non-public data that needs to be removed. * @return $data A cleaned up array with only public data. + * @throws InvalidArgumentException If a parameter has an invalid value */ public function removeNonPublicDataFromArray (array $data) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: Calling FrameworkBootstrap::getDatabaseInstance()->removeNonPublicDataFromArray(data) ...'); + // Check parameter + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: data()=%d - CALLED!', count($data))); + if (count($data) == 0) { + // Throw IAE + throw new InvalidArgumentException('Parameter "data" is an empty array', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); + } + + // Remove non-public data (aka. sensitive) $data = FrameworkBootstrap::getDatabaseInstance()->removeNonPublicDataFromArray($data); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: data[]=' . gettype($data)); + // Return cleaned array + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATABASE-FRONTEND: data()=%d - EXIT!', count($data))); return $data; } diff --git a/framework/main/classes/file_directories/binary/index/class_IndexFile.php b/framework/main/classes/file_directories/binary/index/class_IndexFile.php index 78dac38e..99a56a6c 100644 --- a/framework/main/classes/file_directories/binary/index/class_IndexFile.php +++ b/framework/main/classes/file_directories/binary/index/class_IndexFile.php @@ -93,7 +93,7 @@ class IndexFile extends BaseBinaryFile implements IndexableFile { } // Call block instance - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Calling this->indexInstance->flushFileHeader() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Invoking this->indexInstance->flushFileHeader() ...'); $this->getIndexInstance()->flushFileHeader(); // Trace message @@ -126,6 +126,7 @@ class IndexFile extends BaseBinaryFile implements IndexableFile { $minimumBlockLength = $this->getIndexInstance()->calculateMinimumBlockLength(); // Call protected method + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Invoking this->preAllocateFileByTypeLength(%s,%d) ...', $type, $minimumBlockLength)); $this->preAllocateFileByTypeLength($type, $minimumBlockLength); // Trace message @@ -149,11 +150,11 @@ class IndexFile extends BaseBinaryFile implements IndexableFile { } // Get length from index - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Calling this->indexInstance->calculateMinimumBlockLength() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Invoking this->indexInstance->calculateMinimumBlockLength() ...'); $length = $this->getIndexInstance()->calculateMinimumBlockLength(); // Call protected method - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Calling this->isValidByLength(%d) ...', $length)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Invoking this->isValidByLength(%d) ...', $length)); $isValid = $this->isValidByLength($length); // Return result @@ -174,7 +175,7 @@ class IndexFile extends BaseBinaryFile implements IndexableFile { $length = $this->getIndexInstance()->calculateMinimumBlockLength(); // Call protected method - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Calling parent::readNextBlockByLength(%d) ...', $length)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Invoking parent::readNextBlockByLength(%d) ...', $length)); parent::readNextBlockByLength($length); // Trace message @@ -188,7 +189,7 @@ class IndexFile extends BaseBinaryFile implements IndexableFile { */ public function readFileHeader () { // Call index class' method - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Calling this->indexInstance->readIndexHeader() - CALLED!'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Invoking this->indexInstance->readIndexHeader() - CALLED!'); $this->getIndexInstance()->readIndexHeader(); // Trace message @@ -219,10 +220,11 @@ class IndexFile extends BaseBinaryFile implements IndexableFile { } // Encode/convert the value into a "binary format" + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Invoking StringUtils::encodeData(value[]=%s) ...', gettype($value))); $encoded = StringUtils::encodeData($value); // Get a strong hash for the "encoded" data - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: encoded=%s', $encoded)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: encoded(%d)=%s', strlen($encoded), $encoded)); $hash = CryptoUtils::hash($encoded); // Then write it to the next free gap diff --git a/framework/main/classes/file_directories/binary/stack/class_StackFile.php b/framework/main/classes/file_directories/binary/stack/class_StackFile.php index f93dd769..5d3f4c94 100644 --- a/framework/main/classes/file_directories/binary/stack/class_StackFile.php +++ b/framework/main/classes/file_directories/binary/stack/class_StackFile.php @@ -91,7 +91,7 @@ class StackFile extends BaseBinaryFile implements FileStacker { } // Call block instance - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: Calling this->indexInstance->flushFileHeader() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: Invoking this->indexInstance->flushFileHeader() ...'); $this->getStackInstance()->flushFileHeader(); // Trace message @@ -147,11 +147,11 @@ class StackFile extends BaseBinaryFile implements FileStacker { } // Get length from index - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: Calling this->stackInstance->calculateMinimumBlockLength() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: Invoking this->stackInstance->calculateMinimumBlockLength() ...'); $length = $this->getStackInstance()->calculateMinimumBlockLength(); // Call protected method - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling this->isValidByLength(%d) ...', $length)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Invoking this->isValidByLength(%d) ...', $length)); $isValid = $this->isValidByLength($length); // Return result @@ -167,7 +167,7 @@ class StackFile extends BaseBinaryFile implements FileStacker { */ public function readFileHeader () { // Call stacke instance - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: Calling this->stackInstance->readStackHeader() - CALLED!'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: Invoking this->stackInstance->readStackHeader() - CALLED!'); $this->getStackInstance()->readStackHeader(); // Trace message @@ -187,7 +187,7 @@ class StackFile extends BaseBinaryFile implements FileStacker { $length = $this->getStackInstance()->calculateMinimumBlockLength(); // Call protected method - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling parent::readNextBlockByLength(%d) ...', $length)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Invoking parent::readNextBlockByLength(%d) ...', $length)); parent::readNextBlockByLength($length); // Trace message @@ -208,21 +208,21 @@ class StackFile extends BaseBinaryFile implements FileStacker { if (empty($stackName)) { // Throw IAE throw new InvalidArgumentException('Parameter "stackName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); - } elseif (is_object($value) || is_resource($value)) { + } elseif (is_array($value) || is_object($value) || is_resource($value)) { // Not wanted here throw new InvalidArgumentException(sprintf('value[]=%s is not stackable in files', gettype($value))); } // Encode/convert the value into a "binary format" - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling StringUtils::encodeData(value[]=%s) ...', gettype($value))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Invoking StringUtils::encodeData(value[]=%s) ...', gettype($value))); $encoded = StringUtils::encodeData($value); // Get a strong hash for the "encoded" data - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling CryptoUtils::hash(%s) ...', $encoded)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Invoking CryptoUtils::hash(%s) ...', $encoded)); $hash = CryptoUtils::hash($encoded); // Then write it to the next free gap - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling this->stackInstance->writeDataToFreeGap(%s,%s,%s) ...', $stackName, $hash, $encoded)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Invoking this->stackInstance->writeDataToFreeGap(%s,%s,%s) ...', $stackName, $hash, $encoded)); $data = $this->getStackInstance()->writeDataToFreeGap($stackName, $hash, $encoded); // Return info diff --git a/framework/main/classes/file_directories/class_BaseFileIo.php b/framework/main/classes/file_directories/class_BaseFileIo.php index 05098d0b..3dfab5b6 100644 --- a/framework/main/classes/file_directories/class_BaseFileIo.php +++ b/framework/main/classes/file_directories/class_BaseFileIo.php @@ -61,7 +61,7 @@ abstract class BaseFileIo extends BaseFrameworkSystem implements FilePointer, Cl //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: this->fileObject[]=%s - DESTRUCTOR!', gettype($this->getFileObject()))); if (is_object($this->getFileObject())) { // Try to close a file - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-IO: Calling this->closeFile() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-IO: Invoking this->closeFile() ...'); $this->closeFile(); } diff --git a/framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php b/framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php index 54a18ac7..b0086c98 100644 --- a/framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php +++ b/framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php @@ -136,7 +136,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP $length = strlen($dataStream); // Write data to the file pointer and return written bytes - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: Calling this->fileObject->fwrite(%s,%d) ...', $dataStream, $length)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: Invoking this->fileObject->fwrite(%s,%d) ...', $dataStream, $length)); $status = $this->getFileObject()->fwrite($dataStream, $length); // Return status @@ -168,7 +168,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP } // Then write the data at that position - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: Calling this->writeToFile(%s) ...', $dataStream)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: Invoking this->writeToFile(%s) ...', $dataStream)); $status = $this->writeToFile($dataStream); // Return status diff --git a/framework/main/classes/index/file/class_BaseFileIndex.php b/framework/main/classes/index/file/class_BaseFileIndex.php index b0a24772..21166c12 100644 --- a/framework/main/classes/index/file/class_BaseFileIndex.php +++ b/framework/main/classes/index/file/class_BaseFileIndex.php @@ -100,7 +100,7 @@ abstract class BaseFileIndex extends BaseIndex implements FileIndexer { $data = substr($data, 0, -1); // And update seek position - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->updateSeekPosition() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->updateSeekPosition() ...'); $this->getIteratorInstance()->getBinaryFileInstance()->updateSeekPosition(); /* @@ -112,7 +112,7 @@ abstract class BaseFileIndex extends BaseIndex implements FileIndexer { $header = explode(chr(BinaryFile::SEPARATOR_HEADER_DATA), $data); // Map numeric entries to associative (alpha-numeric) elements - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: Calling ArrayUtils::mapNumericKeysToAssociative(%d) ...', count($header))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: Invoking ArrayUtils::mapNumericKeysToAssociative(%d) ...', count($header))); //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: header(%d)=%s', count($header), print_r($header, true))); $header = ArrayUtils::mapNumericKeysToAssociative($header, [ BinaryFile::HEADER_NAME_MAGIC, @@ -165,7 +165,7 @@ abstract class BaseFileIndex extends BaseIndex implements FileIndexer { ); // Write it to disk (header is always at seek position 0) - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->writeAtPosition(0, header=%s) ...', $header)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->writeAtPosition(0, header=%s) ...', $header)); $this->getIteratorInstance()->getBinaryFileInstance()->writeAtPosition(0, $header); // Trace message @@ -203,7 +203,7 @@ abstract class BaseFileIndex extends BaseIndex implements FileIndexer { $this->getIteratorInstance()->getBinaryFileInstance()->setHeaderSize($headerSize); // Init counters and gaps array - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->initCountersGapsArray() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->initCountersGapsArray() ...'); $this->getIteratorInstance()->getBinaryFileInstance()->initCountersGapsArray(); // Default is not created @@ -212,11 +212,11 @@ abstract class BaseFileIndex extends BaseIndex implements FileIndexer { // Is the file's header initialized? if (!$this->getIteratorInstance()->getBinaryFileInstance()->isFileHeaderInitialized()) { // First pre-allocate a bit - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->preAllocateFile(index) ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->preAllocateFile(index) ...'); $this->getIteratorInstance()->getBinaryFileInstance()->preAllocateFile('index'); // Then write file header - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->createFileHeader() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->createFileHeader() ...'); $this->getIteratorInstance()->getBinaryFileInstance()->createFileHeader(); // Mark as freshly created @@ -224,14 +224,14 @@ abstract class BaseFileIndex extends BaseIndex implements FileIndexer { } // Load the file header - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Calling this->readIndexHeader() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Invoking this->readIndexHeader() ...'); $this->readIndexHeader(); // Freshly created? /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: created=%d', intval($created))); if (!$created) { // Analyze file structure - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->analyzeFileStructure() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->analyzeFileStructure() ...'); $this->getIteratorInstance()->getBinaryFileInstance()->analyzeFileStructure(); } @@ -320,7 +320,7 @@ abstract class BaseFileIndex extends BaseIndex implements FileIndexer { } // Call iterated object's method - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->writeAtPosition(%d, %s) ...', $seekPosition, $dataStream)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->writeAtPosition(%d, %s) ...', $seekPosition, $dataStream)); $status = $this->getIteratorInstance()->getBinaryFileInstance()->writeAtPosition($seekPosition, $dataStream); // Return status diff --git a/framework/main/classes/index/file/stack/class_FileStackIndex.php b/framework/main/classes/index/file/stack/class_FileStackIndex.php index 6cf2742f..621508d0 100644 --- a/framework/main/classes/index/file/stack/class_FileStackIndex.php +++ b/framework/main/classes/index/file/stack/class_FileStackIndex.php @@ -109,7 +109,7 @@ class FileStackIndex extends BaseFileIndex implements IndexableStack, Registerab /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: stackName=%s,hash{}=0x%s,rawData(%d)=%s', $stackName, bin2hex($data[StackableFile::ARRAY_NAME_HASH]), strlen($rawData), $rawData)); // Search for next free gap - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: Calling this->iteratorInstance->binaryFileInstance->searchNextGap(%d) ...', strlen($rawData))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: Invoking this->iteratorInstance->binaryFileInstance->searchNextGap(%d) ...', strlen($rawData))); $gapPosition = $this->getIteratorInstance()->getBinaryFileInstance()->searchNextGap(strlen($rawData)); // Gap position cannot be smaller or equal than header length @@ -120,7 +120,7 @@ class FileStackIndex extends BaseFileIndex implements IndexableStack, Registerab } // Then write the data at that gap - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: Calling this->iteratorInstance->binaryFileInstance->writeData(%d,%s) ...', $gapPosition, $rawData)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: Invoking this->iteratorInstance->binaryFileInstance->writeData(%d,%s) ...', $gapPosition, $rawData)); $this->getIteratorInstance()->getBinaryFileInstance()->writeData($gapPosition, $rawData); // Trace message diff --git a/framework/main/classes/stacker/class_BaseStacker.php b/framework/main/classes/stacker/class_BaseStacker.php index 6526f0a4..3480ddb7 100644 --- a/framework/main/classes/stacker/class_BaseStacker.php +++ b/framework/main/classes/stacker/class_BaseStacker.php @@ -102,7 +102,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { // "Walk" through all (more will be added as needed foreach ($stacks as $stackerName) { // Init this stack - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Calling this->initStack(%s,%d) ...', $stackerName, intval($forceReInit))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Invoking this->initStack(%s,%d) ...', $stackerName, intval($forceReInit))); $this->initStack($stackerName, $forceReInit); } diff --git a/framework/main/classes/stacker/fifo/class_FiFoStacker.php b/framework/main/classes/stacker/fifo/class_FiFoStacker.php index 32574ee7..cf590a76 100644 --- a/framework/main/classes/stacker/fifo/class_FiFoStacker.php +++ b/framework/main/classes/stacker/fifo/class_FiFoStacker.php @@ -72,10 +72,13 @@ class FiFoStacker extends BaseStacker implements Stackable { if (empty($stackerName)) { // No empty stack name throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); + } elseif (is_resource($value) || is_array($value) || is_object($value)) { + // Unsupported variable type + throw new InvalidArgumentException(sprintf('value[]=%s is not supported', gettype($value)), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } // Call the protected method - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Calling parent::addValueToStack(%s,%s) ...', $stackerName, gettype($value))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Invoking parent::addValueToStack(%s,%s) ...', $stackerName, gettype($value))); parent::addValueToStack($stackerName, $value); // Trace message @@ -100,11 +103,11 @@ class FiFoStacker extends BaseStacker implements Stackable { } // Get the value - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Calling this->getNamed(%s) ...', $stackerName)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Invoking this->getNamed(%s) ...', $stackerName)); $value = $this->getNamed($stackerName); // Call the protected method - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Calling parent::popFirst(%s) ...', $stackerName)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Invoking parent::popFirst(%s) ...', $stackerName)); parent::popFirst($stackerName); // Return the value @@ -130,7 +133,7 @@ class FiFoStacker extends BaseStacker implements Stackable { } // Call the protected method - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Calling parent::getFirstValue(%s) ...', $stackerName)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Invoking parent::getFirstValue(%s) ...', $stackerName)); $value = parent::getFirstValue($stackerName); // Return value diff --git a/framework/main/classes/stacker/file/class_BaseFileStack.php b/framework/main/classes/stacker/file/class_BaseFileStack.php index e5f1ce72..4eb59431 100644 --- a/framework/main/classes/stacker/file/class_BaseFileStack.php +++ b/framework/main/classes/stacker/file/class_BaseFileStack.php @@ -115,7 +115,7 @@ abstract class BaseFileStack extends BaseStacker { $data = substr($data, 0, -1); // And update seek position - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->binaryFileInstance->updateSeekPosition() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->iteratorInstance->binaryFileInstance->updateSeekPosition() ...'); $this->getIteratorInstance()->getBinaryFileInstance()->updateSeekPosition(); /* @@ -128,7 +128,7 @@ abstract class BaseFileStack extends BaseStacker { $header = explode(chr(BinaryFile::SEPARATOR_HEADER_DATA), $data); // Map numeric indexes to associative indexes - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Calling ArrayUtils::mapNumericKeysToAssociative(%d) ...', count($header))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Invoking ArrayUtils::mapNumericKeysToAssociative(%d) ...', count($header))); $header = ArrayUtils::mapNumericKeysToAssociative($header, [ BinaryFile::HEADER_NAME_MAGIC, BinaryFile::HEADER_NAME_TOTAL_ENTRIES, @@ -206,7 +206,7 @@ abstract class BaseFileStack extends BaseStacker { ); // Write it to disk (header is always at seek position 0) - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Calling this->iteratorInstance->writeAtPosition(0, header=%s) ...', $header)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Invoking this->iteratorInstance->writeAtPosition(0, header=%s) ...', $header)); $this->getIteratorInstance()->getBinaryFileInstance()->writeAtPosition(0, $header); // Trace message @@ -254,7 +254,7 @@ abstract class BaseFileStack extends BaseStacker { $this->getIteratorInstance()->getBinaryFileInstance()->setHeaderSize($headerSize); // Init counters and gaps array - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->initCountersGapsArray() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->iteratorInstance->initCountersGapsArray() ...'); $this->getIteratorInstance()->getBinaryFileInstance()->initCountersGapsArray(); /* @@ -271,7 +271,7 @@ abstract class BaseFileStack extends BaseStacker { // Is the file's header initialized? if (!$this->getIteratorInstance()->getBinaryFileInstance()->isFileHeaderInitialized()) { // First pre-allocate a bit - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->preAllocateFile(file_stack) ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->iteratorInstance->preAllocateFile(file_stack) ...'); $this->getIteratorInstance()->getBinaryFileInstance()->preAllocateFile('file_stack'); // Then create file header @@ -280,22 +280,22 @@ abstract class BaseFileStack extends BaseStacker { } // Load the file header - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->readStackHeader() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->readStackHeader() ...'); $this->readStackHeader(); // Is the index loaded correctly, e.g. the stack file is just created? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->indexInstance->isIndexLoaded() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->indexInstance->isIndexLoaded() ...'); if (!$this->getIndexInstance()->isIndexLoaded()) { /* * Something horrible has happened to the index as it should be * loaded at this point. The stack's file structure then needs to * be analyzed and the index rebuild. */ - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->analyzeFileStructure() ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->iteratorInstance->analyzeFileStructure() ...'); $this->getIteratorInstance()->getBinaryFileInstance()->analyzeFileStructure(); // Rebuild index from file - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Calling this->iteratorInstance->rebuildIndexFromStack(%s) ...', $this->__toString())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Invoking this->iteratorInstance->rebuildIndexFromStack(%s) ...', $this->__toString())); $this->getIndexInstance()->rebuildIndexFromStack($this); } @@ -336,7 +336,7 @@ abstract class BaseFileStack extends BaseStacker { // Add the hash and gap position to the index //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: data=%s', print_r($data, true)); - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Calling this->indexInstance->addHashedDataToIndex(%s,data()=%d) ...', $stackerName, count($data))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Invoking this->indexInstance->addHashedDataToIndex(%s,data()=%d) ...', $stackerName, count($data))); $this->getIndexInstance()->addHashedDataToIndex($stackerName, $data); // Trace message diff --git a/framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php b/framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php index 15723e28..30344ab8 100644 --- a/framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php +++ b/framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php @@ -67,7 +67,7 @@ class FiFoFileStack extends BaseFileStack implements StackableFile, Calculatable $stackInstance = new FiFoFileStack(); // Init this stack - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FIFO-FILE-STACK: Calling stackInstance->initFileStack([%s]=%s,%s) ...', get_class($fileInfoInstance), $fileInfoInstance, $type)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FIFO-FILE-STACK: Invoking stackInstance->initFileStack([%s]=%s,%s) ...', get_class($fileInfoInstance), $fileInfoInstance, $type)); $stackInstance->initFileStack($fileInfoInstance, $type); // Return the prepared instance @@ -96,7 +96,7 @@ class FiFoFileStack extends BaseFileStack implements StackableFile, Calculatable } // Call the protected method - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FIFO-FILE-STACK: Calling parent::addValueToStack(%s,%s) ...', $stackerName, gettype($value))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FIFO-FILE-STACK: Invoking parent::addValueToStack(%s,%s) ...', $stackerName, gettype($value))); parent::addValueToStack($stackerName, $value); // Trace message diff --git a/framework/main/classes/stacker/filo/class_FiLoStacker.php b/framework/main/classes/stacker/filo/class_FiLoStacker.php index d27c1c20..79db9944 100644 --- a/framework/main/classes/stacker/filo/class_FiLoStacker.php +++ b/framework/main/classes/stacker/filo/class_FiLoStacker.php @@ -74,7 +74,7 @@ class FiLoStacker extends BaseStacker implements Stackable { } // Call the protected method - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILO-FILE-STACK: Calling parent::addValueToStack(%s,%s) ...', $stackerName, gettype($value))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILO-FILE-STACK: Invoking parent::addValueToStack(%s,%s) ...', $stackerName, gettype($value))); parent::addValueToStack($stackerName, $value); // Trace message diff --git a/framework/main/classes/user/class_BaseUser.php b/framework/main/classes/user/class_BaseUser.php index 023ba4b6..4b6514d3 100644 --- a/framework/main/classes/user/class_BaseUser.php +++ b/framework/main/classes/user/class_BaseUser.php @@ -307,7 +307,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable { $frontendInstance = ObjectFactory::createObjectByConfiguredName('user_db_frontend_class'); // Get the primary key back from the frontend - $primaryKey = $frontendInstance->getPrimaryKeyValue(); + $primaryKey = $frontendInstance->generatePrimaryKey(); // Get that field $primaryValue = $this->getField($primaryKey); diff --git a/framework/main/interfaces/database/frontend/class_DatabaseFrontend.php b/framework/main/interfaces/database/frontend/class_DatabaseFrontend.php index aa3a625e..3303a4d7 100644 --- a/framework/main/interfaces/database/frontend/class_DatabaseFrontend.php +++ b/framework/main/interfaces/database/frontend/class_DatabaseFrontend.php @@ -63,11 +63,11 @@ interface DatabaseFrontend extends FrameworkInterface { function doSelectCountByCriteria (Criteria $criteriaInstance, array $onlyKeys = []); /** - * Getter for primary key used in wrapped table + * Generates primary key for this database frontend * * @return $primaryKey Primary key used in wrapped table */ - function getPrimaryKeyValue (); + function generatePrimaryKey (); /** * Counts total rows of this table diff --git a/framework/main/middleware/database/class_DatabaseConnection.php b/framework/main/middleware/database/class_DatabaseConnection.php index 1f99803d..77aa81cd 100644 --- a/framework/main/middleware/database/class_DatabaseConnection.php +++ b/framework/main/middleware/database/class_DatabaseConnection.php @@ -240,7 +240,7 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re $this->backendInstance->connectToDatabase(); // Call database backend - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DB-CONNECTION[' . $this->__toString() . ']: Calling this->backendInstance->removeNonPublicDataFromArray(data) ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DB-CONNECTION[' . $this->__toString() . ']: Invoking this->backendInstance->removeNonPublicDataFromArray(data) ...'); $data = $this->backendInstance->removeNonPublicDataFromArray($data); //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DB-CONNECTION[' . $this->__toString() . ']: data[]=' . gettype($data)); -- 2.39.5