From e7040f10e90178e789f97ef7e195b479250e241a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 31 Jul 2012 22:11:43 +0000 Subject: [PATCH] Rewrote core: - LocalFileDatabase refactured to use FileIoHandler, please DELETE all your db/*/*.serialized database files, this "new" file format is incompatible and thanks to hashing it is a little more secure. - A lot other renames/fixes --- .../io/file/class_FileOutputStreamer.php | 2 +- inc/classes/main/cache/class_MemoryCache.php | 2 +- .../main/class_BaseFrameworkSystem.php | 67 ++++++++++++---- .../main/compressor/class_Bzip2Compressor.php | 9 ++- .../main/compressor/class_GzipCompressor.php | 4 +- .../main/compressor/class_NullCompressor.php | 4 +- .../main/compressor/class_ZlibCompressor.php | 4 +- .../main/console/class_ConsoleTools.php | 8 +- .../socket/class_SocketContainer.php | 4 +- .../main/controller/class_BaseController.php | 8 +- .../main/criteria/class_BaseCriteria.php | 2 +- .../database/class_BaseDatabaseWrapper.php | 10 +-- .../databases/class_LocalFileDatabase.php | 44 +++++----- .../main/debug/class_DebugConsoleOutput.php | 2 +- .../main/debug/class_DebugErrorLogOutput.php | 2 +- .../main/debug/class_DebugWebOutput.php | 2 +- .../payment/class_LocalPaymentDiscovery.php | 6 ++ inc/classes/main/filter/class_FilterChain.php | 8 +- inc/classes/main/helper/class_BaseHelper.php | 10 +-- inc/classes/main/io/class_FileIoStream.php | 4 +- .../io/class_FrameworkDirectoryPointer.php | 8 +- .../io/class_FrameworkFileInputPointer.php | 24 +----- .../main/parser/xml/class_XmlParser.php | 4 +- .../main/registry/class_BaseRegistry.php | 6 +- .../class_BaseControllerResolver.php | 4 +- .../main/response/class_BaseResponse.php | 2 +- .../streams/crypto/class_McryptStream.php | 2 +- .../streams/crypto/class_NullCryptoStream.php | 2 +- .../template/class_BaseTemplateEngine.php | 80 +++++++++---------- .../database/class_DatabaseConnection.php | 3 - .../middleware/io/class_FileIoHandler.php | 13 ++- 31 files changed, 191 insertions(+), 159 deletions(-) diff --git a/inc/classes/interfaces/io/file/class_FileOutputStreamer.php b/inc/classes/interfaces/io/file/class_FileOutputStreamer.php index 0882361f..8840e004 100644 --- a/inc/classes/interfaces/io/file/class_FileOutputStreamer.php +++ b/inc/classes/interfaces/io/file/class_FileOutputStreamer.php @@ -30,7 +30,7 @@ interface FileOutputStreamer extends Streamable { * @param $dataArray Array containing the compressor's extension and streamed data * @return void */ - function saveFile ($fileName, $dataArray); + function saveFile ($fileName, array $dataArray); } // [EOF] diff --git a/inc/classes/main/cache/class_MemoryCache.php b/inc/classes/main/cache/class_MemoryCache.php index ba2cb773..55bf24db 100644 --- a/inc/classes/main/cache/class_MemoryCache.php +++ b/inc/classes/main/cache/class_MemoryCache.php @@ -115,7 +115,7 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable { // Is the offset there? if ($this->offsetExists($offset)) { // Purge only existing keys - //* DEBUG: */ $this->debugOutput('CACHE: Unsetting cache ' . $offset); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CACHE: Unsetting cache ' . $offset); $this->dataCache->offsetUnset($offset); } // END - if } diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 77390bc2..76c89082 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -328,7 +328,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * * @return void */ - public function __destruct() { + public function __destruct () { // Flush any updated entries to the database $this->flushPendingUpdates(); @@ -338,7 +338,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $this->setRealClass('DestructedObject'); } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) { // Already destructed object - $this->debugOutput(sprintf("[%s:] The object %s is already destroyed.", + self::createDebugInstance(__CLASS__)->debugOutput(sprintf("[%s:] The object %s is already destroyed.", __CLASS__, $this->__toString() )); @@ -353,6 +353,17 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return void */ public final function __call ($methodName, $args) { + return self::__callStatic($methodName, $args); + } + + /** + * The __callStatic() method where all non-implemented static methods end up + * + * @param $methodName Name of the missing method + * @args $args Arguments passed to the method + * @return void + */ + public static final function __callStatic ($methodName, $args) { // Implode all given arguments $argsString = ''; if (empty($args)) { @@ -373,10 +384,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { if (is_string($arg)) { // Add length for strings - $argsString .= ', '.strlen($arg); + $argsString .= ', ' . strlen($arg); } elseif (is_array($arg)) { // .. or size if array - $argsString .= ', '.count($arg); + $argsString .= ', ' . count($arg); } elseif ($arg === true) { // ... is boolean 'true' $argsString .= ', true'; @@ -399,8 +410,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } // Output stub message - $this->debugOutput(sprintf("[%s->%s] Stub! Args: %s", - $this->__toString(), + // @TODO __CLASS__ does always return BaseFrameworkSystem but not the extending (=child) class + self::createDebugInstance(__CLASS__)->debugOutput(sprintf("[unknown::%s:] Stub! Args: %s", $methodName, $argsString )); @@ -1004,7 +1015,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return void */ public final function setSocketResource ($socketResource) { - //* NOISY-DEBUG: */ $this->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource=' . $socketResource . ',previous[' . gettype($this->socketResource) . ']=' . $this->socketResource); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource=' . $socketResource . ',previous[' . gettype($this->socketResource) . ']=' . $this->socketResource); $this->socketResource = $socketResource; } @@ -1014,7 +1025,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return $socketResource A valid socket resource */ public final function getSocketResource () { - //* NOISY-DEBUG: */ $this->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource[' . gettype($this->socketResource) . ']=' . $this->socketResource); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource[' . gettype($this->socketResource) . ']=' . $this->socketResource); return $this->socketResource; } @@ -1361,7 +1372,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Debug instance is there? if (!is_null($this->getDebugInstance())) { // Output stub message - $this->debugOutput($stubMessage); + self::createDebugInstance(__CLASS__)->debugOutput($stubMessage); } else { // Trigger an error trigger_error($stubMessage); @@ -1392,6 +1403,32 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } // END - if } + /** + * Creates an instance of a debugger instance + * + * @param $className Name of the class (currently unsupported) + * @return $debugInstance An instance of a debugger class + */ + public final static function createDebugInstance ($className) { + // Init debug instance + $debugInstance = NULL; + + // Try it + try { + // Get a debugger instance + $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_class')); + } catch (NullPointerException $e) { + // Didn't work, no instance there + die('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage()); + } + + // Empty string should be ignored and used for testing the middleware + DebugMiddleware::getSelfInstance()->output(''); + + // Return it + return $debugInstance; + } + /** * Outputs a debug message whether to debug instance (should be set!) or * dies with or ptints the message. Do NEVER EVER rewrite the die() call to @@ -1636,7 +1673,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Get current array $fieldArray = $resultInstance->current(); - //* DEBUG: */ $this->debugOutput($fieldName.':
'.print_r($fieldArray, true).'
'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.':
'.print_r($fieldArray, true).'
'); // Convert dashes to underscore $fieldName = $this->convertDashesToUnderscores($fieldName); @@ -1647,7 +1684,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $fieldValue = $fieldArray[$fieldName]; } else { // Missing field entry, may require debugging - $this->debugOutput($this->__toString() . ':fieldname=' . $fieldName . ' not found!'); + self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ':fieldname=' . $fieldName . ' not found!'); } // Return it @@ -1689,7 +1726,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Debug instance is there? if (!is_null($this->getDebugInstance())) { // Output stub message - $this->debugOutput($message); + self::createDebugInstance(__CLASS__)->debugOutput($message); } else { // Trigger an error trigger_error($message . "
\n"); @@ -1874,7 +1911,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected function hex2asc ($hex) { // Check for length, it must be devideable by 2 - //* DEBUG: */ $this->debugOutput('hex='.$hex); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('hex='.$hex); assert((strlen($hex) % 2) == 0); // Walk the string @@ -1916,7 +1953,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Cut it a little down $prepend = substr($prepend, 0, $diff); - //* DEBUG: */ $this->debugOutput('prepend('.strlen($prepend).')='.$prepend.',diff='.$diff.',length='.$length); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('prepend('.strlen($prepend).')='.$prepend.',diff='.$diff.',length='.$length); // Construct the final prepended string $strFinal = $prepend . $str; @@ -1974,7 +2011,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { ); // And return it - //* NOISY-DEBUG: */ $this->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey); return $cacheKey; } diff --git a/inc/classes/main/compressor/class_Bzip2Compressor.php b/inc/classes/main/compressor/class_Bzip2Compressor.php index 6e9fb844..364838f0 100644 --- a/inc/classes/main/compressor/class_Bzip2Compressor.php +++ b/inc/classes/main/compressor/class_Bzip2Compressor.php @@ -55,7 +55,7 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { * BZIP2 compression stream * * @param $streamData Mixed non-object stream data - * @return $streamData The compressed stream data + * @return $streamData The compressed stream data * @throws InvalidObjectException If the stream is an object */ public function compressStream ($streamData) { @@ -72,7 +72,7 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { * BZIP2 decompression stream * * @param $streamData Mixed non-object stream data - * @return $streamData The decompressed stream data + * @return $streamData The decompressed stream data * @throws InvalidObjectException If the stream is an object */ public function decompressStream ($streamData) { @@ -81,8 +81,11 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); } // END - if + // Decompress it + $streamData = bzdecompress($streamData, true); + // Return the decompressed stream - return bzdecompress($streamData); + return $streamData; } /** diff --git a/inc/classes/main/compressor/class_GzipCompressor.php b/inc/classes/main/compressor/class_GzipCompressor.php index 2373d78b..2f6275b8 100644 --- a/inc/classes/main/compressor/class_GzipCompressor.php +++ b/inc/classes/main/compressor/class_GzipCompressor.php @@ -55,7 +55,7 @@ class GzipCompressor extends BaseFrameworkSystem implements Compressor { * GZIP compression stream * * @param $streamData Mixed non-object stream data - * @return $streamData The compressed stream data + * @return $streamData The compressed stream data * @throws InvalidObjectException If the stream is an object */ public function compressStream ($streamData) { @@ -72,7 +72,7 @@ class GzipCompressor extends BaseFrameworkSystem implements Compressor { * GZIP decompression stream * * @param $streamData Mixed non-object stream data - * @return $streamData The decompressed stream data + * @return $streamData The decompressed stream data * @throws InvalidObjectException If the stream is an object */ public function decompressStream ($streamData) { diff --git a/inc/classes/main/compressor/class_NullCompressor.php b/inc/classes/main/compressor/class_NullCompressor.php index 8d039274..4417255a 100644 --- a/inc/classes/main/compressor/class_NullCompressor.php +++ b/inc/classes/main/compressor/class_NullCompressor.php @@ -49,7 +49,7 @@ class NullCompressor extends BaseFrameworkSystem implements Compressor { * Null compression stream * * @param $streamData Mixed non-object stream data - * @return $streamData The compressed stream data + * @return $streamData The compressed stream data * @throws InvalidObjectException If the stream is an object */ public function compressStream ($streamData) { @@ -66,7 +66,7 @@ class NullCompressor extends BaseFrameworkSystem implements Compressor { * Null decompression stream * * @param $streamData Mixed non-object stream data - * @return $streamData The decompressed stream data + * @return $streamData The decompressed stream data * @throws InvalidObjectException If the stream is an object */ public function decompressStream ($streamData) { diff --git a/inc/classes/main/compressor/class_ZlibCompressor.php b/inc/classes/main/compressor/class_ZlibCompressor.php index 742d5cca..1fab6377 100644 --- a/inc/classes/main/compressor/class_ZlibCompressor.php +++ b/inc/classes/main/compressor/class_ZlibCompressor.php @@ -55,7 +55,7 @@ class ZlibCompressor extends BaseFrameworkSystem implements Compressor { * ZLIB compression stream * * @param $streamData Mixed non-object stream data - * @return $streamData The compressed stream data + * @return $streamData The compressed stream data * @throws InvalidObjectException If the stream is an object */ public function compressStream ($streamData) { @@ -72,7 +72,7 @@ class ZlibCompressor extends BaseFrameworkSystem implements Compressor { * ZLIB decompression stream * * @param $streamData Mixed non-object stream data - * @return $streamData The decompressed stream data + * @return $streamData The decompressed stream data * @throws InvalidObjectException If the stream is an object */ public function decompressStream ($streamData) { diff --git a/inc/classes/main/console/class_ConsoleTools.php b/inc/classes/main/console/class_ConsoleTools.php index b82eb19e..960aaa42 100644 --- a/inc/classes/main/console/class_ConsoleTools.php +++ b/inc/classes/main/console/class_ConsoleTools.php @@ -46,7 +46,7 @@ class ConsoleTools extends BaseFrameworkSystem { */ protected function resolveIpAddress ($hostname) { // Debug message - $this->debugOutput(sprintf('[%s:] Host name to resolve is: %s', + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Host name to resolve is: %s', $this->__toString(), $hostname )); @@ -64,13 +64,13 @@ class ConsoleTools extends BaseFrameworkSystem { $ip = $ipResolved; // Debug message - $this->debugOutput(sprintf('[%s:] Resolved IP address is: %s', + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Resolved IP address is: %s', $this->__toString(), $ip )); } else { // Problem while resolving IP address - $this->debugOutput(sprintf('[%s:] Problem resolving IP address for host %s. Please check your /etc/hosts file.', + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Problem resolving IP address for host %s. Please check your /etc/hosts file.', $this->__toString(), $hostname )); @@ -123,7 +123,7 @@ class ConsoleTools extends BaseFrameworkSystem { // Add last new-line $proxyTunnel .= self::HTTP_EOL; - //* DEBUG: */ $this->debugOutput('CONSOLE-TOOLS: proxyTunnel=' . $proxyTunnel); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONSOLE-TOOLS: proxyTunnel=' . $proxyTunnel); // Write request fwrite($socketResource, $proxyTunnel); diff --git a/inc/classes/main/container/socket/class_SocketContainer.php b/inc/classes/main/container/socket/class_SocketContainer.php index d7bb080e..13dbfb4c 100644 --- a/inc/classes/main/container/socket/class_SocketContainer.php +++ b/inc/classes/main/container/socket/class_SocketContainer.php @@ -75,7 +75,7 @@ class SocketContainer extends BaseContainer implements Registerable { $packageData = $this->getPackageData(); // Debug message - //* NOISY-DEBUG: */ $this->debugOutput('SOCKET-CONTAINER: addressPort=' . $addressPort . ',packageData=' . print_r($packageData, true)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER: addressPort=' . $addressPort . ',packageData=' . print_r($packageData, true)); // So, does both match? $matches = ((isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) && ($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] === $addressPort)); @@ -92,7 +92,7 @@ class SocketContainer extends BaseContainer implements Registerable { */ public final function ifSocketResourceMatches ($socketResource) { // Debug message - /* NOISY-DEBUG: */ $this->debugOutput('SOCKET-CONTAINER: socketResource[' . gettype($socketResource) . ']=' .$socketResource . ',storedResource[' . gettype($this->getSocketResource()) . ']=' . $this->getSocketResource()); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER: socketResource[' . gettype($socketResource) . ']=' .$socketResource . ',storedResource[' . gettype($this->getSocketResource()) . ']=' . $this->getSocketResource()); // So, does both match? $matches = ((is_resource($socketResource)) && ($socketResource === $this->getSocketResource())); diff --git a/inc/classes/main/controller/class_BaseController.php b/inc/classes/main/controller/class_BaseController.php index c7dfa897..28c8de1b 100644 --- a/inc/classes/main/controller/class_BaseController.php +++ b/inc/classes/main/controller/class_BaseController.php @@ -61,9 +61,9 @@ class BaseController extends BaseFrameworkSystem implements Registerable { * @return void */ protected function initFilterChain ($filterChain) { - //* DEBUG: */ $this->debugOutput('CONTROLLER: ' . $filterChain . ' init: START'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: START'); $this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); - //* DEBUG: */ $this->debugOutput('CONTROLLER: ' . $filterChain . ' init: FINISHED'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: FINISHED'); } /** @@ -75,7 +75,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable { * @throws InvalidFilterChainException If the filter chain is invalid */ protected function addFilter ($filterChain, Filterable $filterInstance) { - //* DEBUG: */ $this->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: START'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: START'); // Test if the filter is there if (!isset($this->filterChains[$filterChain])) { @@ -85,7 +85,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable { // Add the filter $this->filterChains[$filterChain]->addFilter($filterInstance); - //* DEBUG: */ $this->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: FINISH'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: FINISH'); } /** diff --git a/inc/classes/main/criteria/class_BaseCriteria.php b/inc/classes/main/criteria/class_BaseCriteria.php index e1c048c5..582a696b 100644 --- a/inc/classes/main/criteria/class_BaseCriteria.php +++ b/inc/classes/main/criteria/class_BaseCriteria.php @@ -106,7 +106,7 @@ class BaseCriteria extends BaseFrameworkSystem { $criteriaKey = $this->convertDashesToUnderscores($criteriaKey); // Debug message - //* NOISY-DEBUG: */ $this->debugOutput('CRITERIA: criteriaKey=' . $criteriaKey . ',criteria()=' . count($this->criteria)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRITERIA: criteriaKey=' . $criteriaKey . ',criteria()=' . count($this->criteria)); // Default is not found $value = NULL; diff --git a/inc/classes/main/database/class_BaseDatabaseWrapper.php b/inc/classes/main/database/class_BaseDatabaseWrapper.php index 31a63a39..357be677 100644 --- a/inc/classes/main/database/class_BaseDatabaseWrapper.php +++ b/inc/classes/main/database/class_BaseDatabaseWrapper.php @@ -84,7 +84,7 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem { protected function queryInsertDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = array()) { // First get a key suitable for our cache and extend it with this class name $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys); - //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...'); // Does this key exists in cache? if ($this->cacheInstance->offsetExists($cacheKey)) { @@ -106,7 +106,7 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem { protected function queryUpdateDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = array()) { // First get a key suitable for our cache and extend it with this class name $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys); - //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...'); // Does this key exists in cache? if ($this->cacheInstance->offsetExists($cacheKey)) { @@ -151,13 +151,13 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem { // Does this key exists in cache? if ($this->cacheInstance->offsetExists($cacheKey)) { // Debug message - //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey); // Then use this result $result = $this->cacheInstance->offsetGet($cacheKey); } else { // Debug message - //* DEBUG: */ $this->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); @@ -202,7 +202,7 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem { $numRows = $resultInstance->getAffectedRows(); // Debug message - //* DEBUG: */ $this->debugOutput('BASE-WRAPPER: numRows=' . $numRows); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: numRows=' . $numRows); } // END - if // Return the result diff --git a/inc/classes/main/database/databases/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php index d92c29b4..375ec98e 100644 --- a/inc/classes/main/database/databases/class_LocalFileDatabase.php +++ b/inc/classes/main/database/databases/class_LocalFileDatabase.php @@ -89,6 +89,12 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackendIn // Set the compressor channel $databaseInstance->setCompressorChannel($compressorInstance); + // Get a file IO handler + $fileIoInstance = ObjectFactory::createObjectByConfiguredName('file_io_class'); + + // ... and set it + $databaseInstance->setFileIoInstance($fileIoInstance); + // "Connect" to the database $databaseInstance->connectToDatabase(); @@ -162,16 +168,13 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackendIn */ private function getDataArrayFromFile ($fqfn) { // Debug message - //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: Reading elements from database file ' . $fqfn . ' ...'); - - // Get a file pointer - $fileInstance = FrameworkFileInputPointer::createFrameworkFileInputPointer($fqfn); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Reading elements from database file ' . $fqfn . ' ...'); - // Get the raw data and BASE64-decode it - $compressedData = base64_decode($fileInstance->readLinesFromFile()); + // Init compressed data + $compressedData = $this->getFileIoInstance()->loadFileContents($fqfn); + $compressedData = $compressedData['data']; // Close the file and throw the instance away - $fileInstance->closeFile(); unset($fileInstance); // Decompress it @@ -181,7 +184,7 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackendIn $dataArray = unserialize($serializedData); // Debug message - //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: Read ' . count($dataArray) . ' elements from database file ' . $fqfn . '.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Read ' . count($dataArray) . ' elements from database file ' . $fqfn . '.'); // Finally return it return $dataArray; @@ -196,22 +199,19 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackendIn */ private function writeDataArrayToFqfn ($fqfn, array $dataArray) { // Debug message - //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file ' . $fqfn . ' ...'); - - // Get a file pointer instance - $fileInstance = FrameworkFileOutputPointer::createFrameworkFileOutputPointer($fqfn, 'w'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file ' . $fqfn . ' ...'); // Serialize and compress it $compressedData = $this->getCompressorChannel()->getCompressor()->compressStream(serialize($dataArray)); - // Write this data BASE64 encoded to the file - $fileInstance->writeToFile(base64_encode($compressedData)); + // Write data + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Writing ' . strlen($compressedData) . ' bytes ...'); - // Close the file pointer - $fileInstance->closeFile(); + // Write this data BASE64 encoded to the file + $this->getFileIoInstance()->saveFile($fqfn, $compressedData); // Debug message - //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file completed.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file completed.'); } /** @@ -350,6 +350,7 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackendIn // Read the file $dataArray = $this->getDataArrayFromFile($pathName . $dataFile); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',dataArray='.print_r($dataArray,true)); // Is this an array? if (is_array($dataArray)) { @@ -359,7 +360,7 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackendIn $criteria = $criteriaInstance->getCriteriaElemnent($key); // Is the criteria met or none set? - //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: criteria[' . gettype($criteria) . ']=' . $criteria . ';()=' . strlen($criteria) . ',criteriaInstance()=' . $criteriaInstance->count() . ',value(' . strlen($value) . ')=' . $value); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: criteria[' . gettype($criteria) . ']=' . $criteria . ';()=' . strlen($criteria) . ',criteriaInstance()=' . $criteriaInstance->count() . ',value(' . strlen($value) . ')=' . $value); if (((!is_null($criteria)) && ($criteria == $value)) || ($criteriaInstance->count() == 0)) { // Shall we skip this entry? if ($criteriaInstance->getSkip() > 0) { @@ -375,7 +376,7 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackendIn $dataArray[$this->getIndexKey()] = $idx; // Entry found! - //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: indexKey=' . $this->getIndexKey() . ',idx=' . $idx . ',dataArray=' . print_r($dataArray, true)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: indexKey=' . $this->getIndexKey() . ',idx=' . $idx . ',dataArray=' . print_r($dataArray, true)); $resultData[BaseDatabaseBackend::RESULT_INDEX_ROWS][] = $dataArray; // Count found entries up @@ -474,13 +475,14 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackendIn // Does the extension match? if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) { // Debug message - /* NOISY-DEBUG: */ $this->debugOutput('DATABASE: dataFile=' . $dataFile . ',getFileExtension()=' . $this->getFileExtension()); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',getFileExtension()=' . $this->getFileExtension() . ' - SKIPPED!'); // Skip this file! continue; } // END - if // Open this file for reading $dataArray = $this->getDataArrayFromFile($pathName . $dataFile); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',dataArray='.print_r($dataArray,true)); // Is this an array? if (is_array($dataArray)) { @@ -488,6 +490,7 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackendIn foreach ($dataArray as $key => $value) { // Get criteria element $criteria = $searchInstance->getCriteriaElemnent($key); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',key=' . $key . ',criteria=' . $criteria); // Is the criteria met? if (((!is_null($criteria)) && ($criteria == $value)) || ($searchInstance->count() == 0)) { @@ -503,6 +506,7 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackendIn // Entry found, so update it foreach ($criteriaArray as $criteriaKey => $criteriaValue) { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue); $dataArray[$criteriaKey] = $criteriaValue; } // END - foreach diff --git a/inc/classes/main/debug/class_DebugConsoleOutput.php b/inc/classes/main/debug/class_DebugConsoleOutput.php index 16e8dfa8..ed74c513 100644 --- a/inc/classes/main/debug/class_DebugConsoleOutput.php +++ b/inc/classes/main/debug/class_DebugConsoleOutput.php @@ -94,7 +94,7 @@ class DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, Output * @throws UnsupportedOperationException If this method is called */ public function streamData ($data) { - $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } } diff --git a/inc/classes/main/debug/class_DebugErrorLogOutput.php b/inc/classes/main/debug/class_DebugErrorLogOutput.php index 22fe5598..2baf7917 100644 --- a/inc/classes/main/debug/class_DebugErrorLogOutput.php +++ b/inc/classes/main/debug/class_DebugErrorLogOutput.php @@ -91,7 +91,7 @@ class DebugErrorLogOutput extends BaseFrameworkSystem implements Debugger, Outpu * @throws UnsupportedOperationException If this method is called */ public function streamData ($data) { - $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } } diff --git a/inc/classes/main/debug/class_DebugWebOutput.php b/inc/classes/main/debug/class_DebugWebOutput.php index 2d931db4..cfa8788a 100644 --- a/inc/classes/main/debug/class_DebugWebOutput.php +++ b/inc/classes/main/debug/class_DebugWebOutput.php @@ -80,7 +80,7 @@ class DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStre * @throws UnsupportedOperationException If this method is called */ public function streamData ($data) { - $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } } diff --git a/inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php b/inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php index 0dc13530..b6309baa 100644 --- a/inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php +++ b/inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php @@ -70,6 +70,12 @@ class LocalPaymentDiscovery extends BaseDiscovery implements Discoverable, Regis // Get result back $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + // Advanced to next entry + if (!$resultInstance->next()) { + // Not valid! + assert(false); + } // END - if + // Set the result instance $this->setResultInstance($resultInstance); } diff --git a/inc/classes/main/filter/class_FilterChain.php b/inc/classes/main/filter/class_FilterChain.php index afa63ab7..3aff6387 100644 --- a/inc/classes/main/filter/class_FilterChain.php +++ b/inc/classes/main/filter/class_FilterChain.php @@ -78,16 +78,16 @@ class FilterChain extends BaseFrameworkSystem implements Registerable { */ public function processFilters (Requestable $requestInstance, Responseable $responseInstance) { // Run all filters - //* DEBUG */ $this->debugOutput('COUNT=' . count($this->filters)); + //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('COUNT=' . count($this->filters)); foreach ($this->getFilters() as $filterInstance) { // Try to execute this filter try { - //* DEBUG */ $this->debugOutput('FILTER: ' . $filterInstance->__toString() . ': Processing started.'); + //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('FILTER: ' . $filterInstance->__toString() . ': Processing started.'); $filterInstance->execute($requestInstance, $responseInstance); - //* DEBUG */ $this->debugOutput('FILTER: ' . $filterInstance->__toString() . ': Processing ended.'); + //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('FILTER: ' . $filterInstance->__toString() . ': Processing ended.'); } catch (FilterChainException $e) { // This exception can be thrown to just skip any further processing - $this->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage()); + self::createDebugInstance(__CLASS__)->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage()); break; } } // END - foreach diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php index e8d75702..172846a9 100644 --- a/inc/classes/main/helper/class_BaseHelper.php +++ b/inc/classes/main/helper/class_BaseHelper.php @@ -175,7 +175,7 @@ class BaseHelper extends BaseFrameworkSystem { public function assignFieldWithFilter ($fieldName, $filterMethod) { // Get the value $fieldValue = $this->getValueField($fieldName); - //* DEBUG: */ $this->debugOutput($fieldName.'='.$fieldValue); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'='.$fieldValue); // Now filter it through the value through the filter method $filteredValue = call_user_func_array(array($this, 'doFilter' . $this->convertToClassName($filterMethod)), array($fieldValue)); @@ -193,14 +193,14 @@ class BaseHelper extends BaseFrameworkSystem { * @throws NullPointerException If recovery of requested value instance failed */ public function prefetchValueInstance ($registryKey, $extraKey = NULL) { - //* DEBUG: */ $this->debugOutput('O:'.$registryKey.'/'.$extraKey); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('O:'.$registryKey.'/'.$extraKey); try { // Get the required instance $this->valueInstance = Registry::getRegistry()->getInstance($registryKey); } catch (NullPointerException $e) { // Not set in registry // @TODO Try to log it here - //* DEBUG: */ $this->debugOutput($registryKey.'=NULL!'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($registryKey.'=NULL!'); } // Shall we get an extra instance? @@ -212,7 +212,7 @@ class BaseHelper extends BaseFrameworkSystem { // Try to create it $this->extraInstance = ObjectFactory::createObjectByConfiguredName($extraKey . '_class', array($this->valueInstance)); } - //* DEBUG: */ $this->debugOutput($extraKey.'='.$this->extraInstance.' - EXTRA!'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($extraKey.'='.$this->extraInstance.' - EXTRA!'); } // END - if // Is the value instance valid? @@ -457,7 +457,7 @@ class BaseHelper extends BaseFrameworkSystem { // Get the field value $fieldValue = $this->getValueInstance()->getField($fieldName); - //* DEBUG: */ $this->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).')'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).')'); // Is it null? if ((is_null($fieldValue)) && (!is_null($this->extraInstance))) { diff --git a/inc/classes/main/io/class_FileIoStream.php b/inc/classes/main/io/class_FileIoStream.php index 2ce19c61..d8ed3515 100644 --- a/inc/classes/main/io/class_FileIoStream.php +++ b/inc/classes/main/io/class_FileIoStream.php @@ -73,7 +73,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil * @see FileOutputStreamer * @todo This method needs heavy rewrite */ - public final function saveFile ($fileName, $dataArray) { + public final function saveFile ($fileName, array $dataArray) { // Try it five times $dirName = ''; $fileInstance = NULL; for ($idx = 0; $idx < 5; $idx++) { @@ -255,7 +255,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil * @throws UnsupportedOperationException If this method is called */ public function streamData ($data) { - $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } } diff --git a/inc/classes/main/io/class_FrameworkDirectoryPointer.php b/inc/classes/main/io/class_FrameworkDirectoryPointer.php index 3ce6a817..f48b884b 100644 --- a/inc/classes/main/io/class_FrameworkDirectoryPointer.php +++ b/inc/classes/main/io/class_FrameworkDirectoryPointer.php @@ -140,7 +140,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem { public function readDirectoryExcept (array $except = array('.', '..')) { if (count($except) == 0) { // No exception given, so read all data - $this->debugOutput('DIRECTORY: No exceptions given, please use readRawDirectory() instead!'); + self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY: No exceptions given, please use readRawDirectory() instead!'); return $this->readRawDirectory(); } // END - if @@ -150,16 +150,16 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem { // Shall we exclude directories? if ((!is_null($rawLine)) && ($rawLine !== false) && (!in_array($rawLine, $except))) { // Return read data - //* NOISY-DEBUG: */ $this->debugOutput('DIRECTORY: rawLine[' . gettype($rawLine) . ']=' . $rawLine); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY: rawLine[' . gettype($rawLine) . ']=' . $rawLine); return $rawLine; } elseif ((!is_null($rawLine)) && ($rawLine !== false)) { // Exclude this part - //* NOISY-DEBUG: */ $this->debugOutput('DIRECTORY: rawline[' . gettype($rawLine) . ']=' . $rawLine . ' - Recursive call!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY: rawline[' . gettype($rawLine) . ']=' . $rawLine . ' - Recursive call!'); return $this->readDirectoryExcept($except); } // End pointer reached - //* NOISY-DEBUG: */ $this->debugOutput('DIRECTORY: Returning NULL!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY: Returning NULL!'); return NULL; } diff --git a/inc/classes/main/io/class_FrameworkFileInputPointer.php b/inc/classes/main/io/class_FrameworkFileInputPointer.php index a6ccca4e..14eab16e 100644 --- a/inc/classes/main/io/class_FrameworkFileInputPointer.php +++ b/inc/classes/main/io/class_FrameworkFileInputPointer.php @@ -81,7 +81,7 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { } // Try to open a handler - $filePointer = @fopen($fileName, 'rb'); + $filePointer = fopen($fileName, 'rb'); if ((is_null($filePointer)) || ($filePointer === false)) { // Something bad happend throw new FileIoException($fileName, self::EXCEPTION_FILE_POINTER_INVALID); @@ -120,28 +120,6 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { return fread($this->getPointer(), 1024); } - /** - * Read lines from a file pointer - * - * @return mixed The result of fread() - * @throws NullPointerException If the file pointer instance - * is not set by setPointer() - * @throws InvalidResourceException If there is being set - * an invalid file resource - */ - public function readLinesFromFile () { - if (is_null($this->getPointer())) { - // Pointer not initialized - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_resource($this->getPointer())) { - // Pointer is not a valid resource! - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_DIRECTORY_POINTER); - } - - // Read data from the file pointer and return it - return fgets($this->getPointer(), 1024); - } - /** * Close a file source and set it's instance to null and the file name * to empty diff --git a/inc/classes/main/parser/xml/class_XmlParser.php b/inc/classes/main/parser/xml/class_XmlParser.php index 9374dc61..3394a85a 100644 --- a/inc/classes/main/parser/xml/class_XmlParser.php +++ b/inc/classes/main/parser/xml/class_XmlParser.php @@ -65,9 +65,9 @@ class XmlParser extends BaseParser implements Parseable { // Convert all to UTF8 if (empty($content)) { // No empty content! - $this->debugOutput('Empty content! Backtrace:
');
+			self::createDebugInstance(__CLASS__)->debugOutput('Empty content! Backtrace: 
');
 			debug_print_backtrace();
-			$this->debugOutput('
'); + self::createDebugInstance(__CLASS__)->debugOutput('
'); die(); } elseif (function_exists('recode')) { // Recode found, so use it diff --git a/inc/classes/main/registry/class_BaseRegistry.php b/inc/classes/main/registry/class_BaseRegistry.php index a368855c..cfe6edbc 100644 --- a/inc/classes/main/registry/class_BaseRegistry.php +++ b/inc/classes/main/registry/class_BaseRegistry.php @@ -132,19 +132,19 @@ class BaseRegistry extends BaseFrameworkSystem implements Registerable { // "Walk" over all entries foreach ($this->getEntries('object-name') as $key => $value) { // Debug message - //* DEBUG: */ $this->debugOutput('REGISTRY: Checking key=' . $key . ',value=' . $value . ',lookFor=' . $lookFor); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY: Checking key=' . $key . ',value=' . $value . ',lookFor=' . $lookFor); // If $value matches the $lookFor, we need to look for more entries for this! if ($lookFor == $value) { // Look for more entries foreach ($this->getEntries() as $key2 => $value2) { // Debug message - //* DEBUG: */ $this->debugOutput('REGISTRY: Checking key2=' . $key2 . ',value2=' . print_r($value2, true) . ',lookFor=' . $lookFor); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY: Checking key2=' . $key2 . ',value2=' . print_r($value2, true) . ',lookFor=' . $lookFor); // Both keys must match! if (($key == $key2) || (isset($value2[$key]))) { // Debug message - //* DEBUG: */ $this->debugOutput('REGISTRY: Adding ' . $value2[$key] . ' ...'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY: Adding ' . $value2[$key] . ' ...'); // Then add it $entry[$key2] = $value2[$key]; diff --git a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php index f7513385..69fcf870 100644 --- a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php +++ b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php @@ -78,7 +78,7 @@ class BaseControllerResolver extends BaseResolver { $this->setClassName($this->getClassPrefix() . 'DefaultNewsController'); // Generate the class name - //* DEBUG: */ $this->debugOutput('BEFORE: controller=' . $controllerName); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BEFORE: controller=' . $controllerName); if ($controllerName != $defaultController) { // Create controller class name $className = $this->getClassPrefix() . $this->convertToClassName($controllerName) . 'Controller'; @@ -89,7 +89,7 @@ class BaseControllerResolver extends BaseResolver { // No news at main command or non-news command $this->setClassName($this->getClassPrefix() . 'DefaultNewsController'); } - //* DEBUG: */ $this->debugOutput('AFTER: controller=' . $this->getClassName()); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('AFTER: controller=' . $this->getClassName()); // Is this class loaded? if (!class_exists($this->getClassName())) { diff --git a/inc/classes/main/response/class_BaseResponse.php b/inc/classes/main/response/class_BaseResponse.php index 80615f31..c8cfa4f5 100644 --- a/inc/classes/main/response/class_BaseResponse.php +++ b/inc/classes/main/response/class_BaseResponse.php @@ -171,7 +171,7 @@ class BaseResponse extends BaseFrameworkSystem { // Send all headers foreach ($this->responseHeaders as $name => $value) { header($name . ': ' . $value); - //* DEBUG: */ $this->debugOutput('name=' . $name . ',value=' . $value); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('name=' . $name . ',value=' . $value); } // END - foreach // Send cookies out? diff --git a/inc/classes/main/streams/crypto/class_McryptStream.php b/inc/classes/main/streams/crypto/class_McryptStream.php index 4607bd4c..7f6f1e9e 100644 --- a/inc/classes/main/streams/crypto/class_McryptStream.php +++ b/inc/classes/main/streams/crypto/class_McryptStream.php @@ -163,7 +163,7 @@ class McryptStream extends BaseStream implements EncryptableStream { * @throws UnsupportedOperationException If this method is called (which is a mistake) */ public function streamData ($data) { - $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } } diff --git a/inc/classes/main/streams/crypto/class_NullCryptoStream.php b/inc/classes/main/streams/crypto/class_NullCryptoStream.php index a8fb9ecd..25372a99 100644 --- a/inc/classes/main/streams/crypto/class_NullCryptoStream.php +++ b/inc/classes/main/streams/crypto/class_NullCryptoStream.php @@ -82,7 +82,7 @@ class NullCryptoStream extends BaseStream implements EncryptableStream { * @throws UnsupportedOperationException If this method is called (which is a mistake) */ public function streamData ($data) { - $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } } diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php index 334ff102..2692af52 100644 --- a/inc/classes/main/template/class_BaseTemplateEngine.php +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -181,7 +181,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { // If the stack is null, use the current group if (is_null($stack)) { // Use current group - //* DEBUG: */ $this->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!'); $stack = $this->currGroup; } // END - if @@ -189,11 +189,11 @@ class BaseTemplateEngine extends BaseFrameworkSystem { if ($this->isVarStackSet($stack)) { // Now search for it foreach ($this->getVarStack($stack) as $index => $currEntry) { - //* DEBUG: */ $this->debugOutput(__METHOD__.':currGroup=' . $stack . ',idx=' . $index . ',currEntry=' . $currEntry['name'] . ',variableName=' . $variableName); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.':currGroup=' . $stack . ',idx=' . $index . ',currEntry=' . $currEntry['name'] . ',variableName=' . $variableName); // Is the entry found? if ($currEntry['name'] == $variableName) { // Found! - //* DEBUG: */ $this->debugOutput(__METHOD__.':FOUND!'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.':FOUND!'); $found = $index; break; } // END - if @@ -256,7 +256,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { // If the stack is null, use the current group if (is_null($stack)) { // Use current group - //* DEBUG: */ $this->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!'); $stack = $this->currGroup; } // END - if @@ -270,7 +270,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { } // END - if // Return the current position - //* DEBUG: */ $this->debugOutput(__METHOD__.': group=' . $stack . ',variableName=' . $variableName . ', content[' . gettype($content) . ']=' . $content); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': group=' . $stack . ',variableName=' . $variableName . ', content[' . gettype($content) . ']=' . $content); return $content; } @@ -317,7 +317,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ public function setVariableGroup ($groupName, $add = true) { // Set group name - //* DEBIG: */ $this->debugOutput(__METHOD__.': currGroup=' . $groupName); + //* DEBIG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': currGroup=' . $groupName); $this->currGroup = $groupName; // Skip group 'general' @@ -339,7 +339,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $variableName = trim($this->convertDashesToUnderscores($variableName)); // Debug message - //* DEBUG: */ $this->debugOutput(__METHOD__.': group=' . $this->currGroup . ', variableName=' . $variableName . ', value=' . $value); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': group=' . $this->currGroup . ', variableName=' . $variableName . ', value=' . $value); // Get current variables in group $currVars = $this->readCurrentGroup(); @@ -601,11 +601,11 @@ class BaseTemplateEngine extends BaseFrameworkSystem { // Was it found? if ($index === false) { // Add it to the stack - //* DEBUG: */ $this->debugOutput(__METHOD__ . ':ADD: ' . $variableName . '[' . gettype($value) . ']=' . $value); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':ADD: ' . $variableName . '[' . gettype($value) . ']=' . $value); $this->addVariable($variableName, $value); } elseif (!empty($value)) { // Modify the stack entry - //* DEBUG: */ $this->debugOutput(__METHOD__ . ':MOD: ' . $variableName . '[' . gettype($value) . ']=' . $value); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':MOD: ' . $variableName . '[' . gettype($value) . ']=' . $value); $this->modifyVariable($variableName, $value); } } @@ -652,8 +652,8 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ protected final function setRawTemplateData ($rawTemplateData) { // And store it in this class - //* DEBUG: */ $this->debugOutput(__METHOD__.': ' . strlen($rawTemplateData) . ' Bytes set.'); - //* DEBUG: */ $this->debugOutput(__METHOD__.': ' . $this->currGroup . ' variables: ' . count($this->getVarStack($this->currGroup)) . ', groups=' . count($this->varStack)); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': ' . strlen($rawTemplateData) . ' Bytes set.'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': ' . $this->currGroup . ' variables: ' . count($this->getVarStack($this->currGroup)) . ', groups=' . count($this->varStack)); $this->rawTemplateData = (string) $rawTemplateData; } @@ -663,7 +663,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return $rawTemplateData The raw data from the template */ public final function getRawTemplateData () { - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': ' . strlen($this->rawTemplateData) . ' Bytes read.'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': ' . strlen($this->rawTemplateData) . ' Bytes read.'); return $this->rawTemplateData; } @@ -674,7 +674,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ private final function setCompiledData ($compiledData) { // And store it in this class - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': ' . strlen($compiledData) . ' Bytes set.'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': ' . strlen($compiledData) . ' Bytes set.'); $this->compiledData = (string) $compiledData; } @@ -684,7 +684,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return $compiledData Compiled template data */ public final function getCompiledData () { - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': ' . strlen($this->compiledData) . ' Bytes read.'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': ' . strlen($this->compiledData) . ' Bytes read.'); return $this->compiledData; } @@ -761,7 +761,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $ioInstance = $this->getFileIoInstance(); // Some debug code to look on the file which is being loaded - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': FQFN=' . $fqfn); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': FQFN=' . $fqfn); // Load the raw template $rawTemplateData = $ioInstance->loadFileContents($fqfn); @@ -787,7 +787,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $variableName = trim($this->convertDashesToUnderscores($variableName)); // Debug message - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': varName=' . $varName . ',variableName=' . $variableName); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': varName=' . $varName . ',variableName=' . $variableName); // Is it not a config variable? if ($varName != 'config') { @@ -813,7 +813,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { preg_match_all('/\$(\w+)(\[(\w+)\])?/', $rawData, $variableMatches); // Debug message - //* NOISY-DEBUG: */ $this->debugOutput(__METHOD__ . ':rawData(' . strlen($rawData) . ')=' . $rawData . ',variableMatches=' . print_r($variableMatches, true)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':rawData(' . strlen($rawData) . ')=' . $rawData . ',variableMatches=' . print_r($variableMatches, true)); // Did we find some variables? if ((is_array($variableMatches)) && (count($variableMatches) == 4) && (count($variableMatches[0]) > 0)) { @@ -862,7 +862,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { // RECURSIVE PROTECTION! BE CAREFUL HERE! if ((!isset($this->loadedRawData[$template])) && (!in_array($template, $this->loadedTemplates))) { // Debug message - //* DEBUG: */ $this->debugOutput(__METHOD__ . ':template=' . $template); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':template=' . $template); // Template not found, but maybe variable assigned? if ($this->getVariableIndex($template, 'config') !== false) { @@ -1003,7 +1003,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ private function assignAllVariables (array $varMatches) { // Debug message - //* DEBUG: */ $this->debugOutput(__METHOD__ . ':varMatches()=' . count($varMatches)); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':varMatches()=' . count($varMatches)); // Search for all variables foreach ($varMatches[1] as $key => $var) { @@ -1011,7 +1011,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $var = trim($this->convertDashesToUnderscores($var)); // Debug message - $this->debugOutput(__METHOD__ . ':key=' . $key . ',var=' . $var); + self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':key=' . $key . ',var=' . $var); // Detect leading equals if (substr($varMatches[2][$key], 0, 1) == '=') { @@ -1038,19 +1038,19 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ private function compileRawTemplateData (array $templateMatches) { // Debug message - //* DEBUG: */ $this->debugOutput(__METHOD__ . ':loadedRawData()= ' .count($this->loadedRawData)); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':loadedRawData()= ' .count($this->loadedRawData)); // Are some code-templates found which we need to compile? if (count($this->loadedRawData) > 0) { // Then compile all! foreach ($this->loadedRawData as $template => $code) { // Debug message - //* DEBUG: */ $this->debugOutput(__METHOD__ . ':template=' . $template . ',code(' . strlen($code) . ')=' . $code); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':template=' . $template . ',code(' . strlen($code) . ')=' . $code); // Is this template already compiled? if (in_array($template, $this->compiledTemplates)) { // Then skip it - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': Template ' . $template . ' already compiled. SKIPPED!'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': Template ' . $template . ' already compiled. SKIPPED!'); continue; } // END - if @@ -1061,7 +1061,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { if (($foundIndex !== false) && (isset($templateMatches[3][$foundIndex]))) { // Split it up with another reg. exp. into variable=value pairs preg_match_all($this->regExpVarValue, $templateMatches[3][$foundIndex], $varMatches); - //* NOISY-DEBUG: */ $this->debugOutput(__METHOD__ . ':varMatches=' . print_r($varMatches, true)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':varMatches=' . print_r($varMatches, true)); // Assign all variables $this->assignAllVariables($varMatches); @@ -1097,7 +1097,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { private function finalizeVariableCompilation () { // Get the content $content = $this->getRawTemplateData(); - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': content before=' . strlen($content) . ' (' . md5($content) . ')'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': content before=' . strlen($content) . ' (' . md5($content) . ')'); // Do we have the stack? if (!$this->isVarStackSet('general')) { @@ -1108,7 +1108,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { // Walk through all variables foreach ($this->getVarStack('general') as $currEntry) { - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': name=' . $currEntry['name'] . ', value=
' . htmlentities($currEntry['value']) . '
'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': name=' . $currEntry['name'] . ', value=
' . htmlentities($currEntry['value']) . '
'); // Replace all [$var] or {?$var?} with the content // @TODO Old behaviour, will become obsolete! $content = str_replace('$content[' . $currEntry['name'] . ']', $currEntry['value'], $content); @@ -1120,7 +1120,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $content = str_replace('{?' . $currEntry['name'] . '?}', $currEntry['value'], $content); } // END - for - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': content after=' . strlen($content) . ' (' . md5($content) . ')'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': content after=' . strlen($content) . ' (' . md5($content) . ')'); // Set the content back $this->setRawTemplateData($content); @@ -1152,7 +1152,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $variableName = trim($this->convertDashesToUnderscores($variableName)); // Sweet and simple... - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': variableName=' . $variableName . ',getConfigEntry()=' . $this->getConfigInstance()->getConfigEntry($variableName)); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': variableName=' . $variableName . ',getConfigEntry()=' . $this->getConfigInstance()->getConfigEntry($variableName)); $this->setVariable('config', $variableName, $this->getConfigInstance()->getConfigEntry($variableName)); } @@ -1182,7 +1182,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { // Do we have the stack? if (!$this->isVarStackSet('general')) { // Abort here silently - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': Aborted, variable stack general not found!'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': Aborted, variable stack general not found!'); return; } // END - if @@ -1192,13 +1192,13 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $value = $this->compileRawCode($this->readVariable($currVariable['name']), true); // Debug message - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': name=' . $currVariable['name'] . ',value=' . $value); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': name=' . $currVariable['name'] . ',value=' . $value); // Remove it from stack $this->removeVariable($currVariable['name'], 'general'); // Re-assign the variable - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': value='. $value . ',name=' . $currVariable['name'] . ',index=' . $index); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': value='. $value . ',name=' . $currVariable['name'] . ',index=' . $index); $this->assignConfigVariable($value); } // END - foreach } @@ -1217,7 +1217,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { // Iterate through all general variables foreach ($this->getVarStack('general') as $currVariable) { // Transfer it's name/value combination to the $content array - //* DEBUG: */ $this->debugOutput(__METHOD__ . ':' . $currVariable['name'] . '=
' . htmlentities($currVariable['value']).'
'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':' . $currVariable['name'] . '=
' . htmlentities($currVariable['value']).'
'); $dummy[$currVariable['name']] = $currVariable['value']; }// END - if @@ -1274,7 +1274,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { // Goes something wrong? if ((!isset($result)) || (empty($result))) { // Output eval command - $this->debugOutput(sprintf("Failed eval() code:
%s
", $this->markupCode($eval, true)), true); + self::createDebugInstance(__CLASS__)->debugOutput(sprintf("Failed eval() code:
%s
", $this->markupCode($eval, true)), true); // Output backtrace here $this->debugBackTrace(); @@ -1324,7 +1324,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { preg_match_all($this->regExpCodeTags, $rawData, $templateMatches); // Debug message - //* NOISY-DEBUG: */ $this->debugOutput(__METHOD__ . ':templateMatches=' . print_r($templateMatches , true)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':templateMatches=' . print_r($templateMatches , true)); // Analyze the matches array if ((is_array($templateMatches)) && (count($templateMatches) == 4) && (count($templateMatches[0]) > 0)) { @@ -1431,22 +1431,22 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ public function compileRawCode ($rawCode, $setMatchAsCode=false) { // Find the variables - //* NOISY-DEBUG: */ $this->debugOutput(__METHOD__ . ':rawCode=
' . htmlentities($rawCode) . '
'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':rawCode=
' . htmlentities($rawCode) . '
'); preg_match_all($this->regExpVarValue, $rawCode, $varMatches); // Compile all variables - //* NOISY-DEBUG: */ $this->debugOutput(__METHOD__ . ':
' . print_r($varMatches, true) . '
'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':
' . print_r($varMatches, true) . '
'); foreach ($varMatches[0] as $match) { // Add variable tags around it $varCode = '{?' . $match . '?}'; // Debug message - //* DEBUG: */ $this->debugOutput(__METHOD__ . ':varCode=' . $varCode); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':varCode=' . $varCode); // Is the variable found in code? (safes some calls) if (strpos($rawCode, $varCode) !== false) { // Debug message - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': match=' . $match . ',rawCode[' . gettype($rawCode) . ']=' . $rawCode); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': match=' . $match . ',rawCode[' . gettype($rawCode) . ']=' . $rawCode); // Use $match as new value or $value from read variable? if ($setMatchAsCode === true) { @@ -1463,7 +1463,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { } // END - foreach // Return the compiled data - //* DEBUG: */ $this->debugOutput(__METHOD__ . ':rawCode=
' . htmlentities($rawCode) . '
'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':rawCode=
' . htmlentities($rawCode) . '
'); return $rawCode; } @@ -1484,7 +1484,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return void */ public function renameVariable ($oldName, $newName) { - //* DEBUG: */ $this->debugOutput(__METHOD__ . ': oldName=' . $oldName . ', newName=' . $newName); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': oldName=' . $oldName . ', newName=' . $newName); // Get raw template code $rawData = $this->getRawTemplateData(); diff --git a/inc/classes/middleware/database/class_DatabaseConnection.php b/inc/classes/middleware/database/class_DatabaseConnection.php index 3e3332c3..0bf8b6c6 100644 --- a/inc/classes/middleware/database/class_DatabaseConnection.php +++ b/inc/classes/middleware/database/class_DatabaseConnection.php @@ -53,9 +53,6 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re // Get instance $databaseInstance = new DatabaseConnection(); - // Set debug output handler - $databaseInstance->setDebugInstance($debugInstance); - // Set database layer $databaseInstance->setDatabaseLayer($dbLayer); diff --git a/inc/classes/middleware/io/class_FileIoHandler.php b/inc/classes/middleware/io/class_FileIoHandler.php index e0bf69dc..533dce3e 100644 --- a/inc/classes/middleware/io/class_FileIoHandler.php +++ b/inc/classes/middleware/io/class_FileIoHandler.php @@ -119,15 +119,22 @@ class FileIoHandler extends BaseMiddleware { /** * Saves a file with data by using the current output stream * - * @param $fileName Name of the file - * @param $dataArray Array with file contents + * @param $fileName Name of the file + * @param $dataStream File data stream * @return void * @see FileOutputStreamer */ - public function saveFile ($fileName, $dataArray) { + public function saveFile ($fileName, $dataStream) { // Get output stream $outInstance = $this->getOutputStream(); + // Prepare output array + $dataArray = array( + // @TODO What is this for? + 0 => $this->__toString(), + 1 => $dataStream + ); + // Send the fileName and dataArray to the output handler $outInstance->saveFile($fileName, $dataArray); } -- 2.30.2