Introduced seekToOldPosition() and avoided endless loop.
[core.git] / inc / classes / main / class_BaseFrameworkSystem.php
index 161710f552f119e0faa8ceefb0c3288cfa5e91fe..06f3a4d6d6debc47f5201b4ad1fa3c9df52f4207 100644 (file)
@@ -3057,14 +3057,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!!', __METHOD__, __LINE__));
        }
 
+       /**
+        * Seeks to old position
+        *
+        * @return      void
+        */
+       protected function seekToOldPosition () {
+               // Seek to currently ("old") saved position
+               $this->getIteratorInstance()->seek($this->getSeekPosition());
+       }
+
        /**
         * Writes data at given position
         *
         * @param       $seekPosition   Seek position
         * @param       $data                   Data to be written
+        * @param       $flushHeader    Whether to flush the header (default: flush)
         * @return      void
         */
-       protected function writeData ($seekPosition, $data) {
+       protected function writeData ($seekPosition, $data, $flushHeader = TRUE) {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekPosition=%s,data()=%s - CALLED!', __METHOD__, __LINE__, $seekPosition, strlen($data)));
 
                // Write data at given position
@@ -3073,8 +3084,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Update seek position
                $this->updateSeekPosition();
 
-               // Flush header
-               $this->flushFileHeader();
+               // Flush the header?
+               if ($flushHeader === TRUE) {
+                       // Flush header
+                       $this->flushFileHeader();
+               } // END - if
 
                // Seek to old position
                $this->seekToOldPosition();