diff --git a/api/src/Etemplate/Request.php b/api/src/Etemplate/Request.php index e10ac35ed3..c41fe8362f 100644 --- a/api/src/Etemplate/Request.php +++ b/api/src/Etemplate/Request.php @@ -242,6 +242,7 @@ class Request */ public function &id() { + $this->cleanup(); $data = serialize($this->data); // compress the data if available @@ -266,6 +267,24 @@ class Request return $id; } + /** + * Clean up data before storing it: currently only removes "real" nextmatch rows + */ + protected function cleanup() + { + if (isset($this->data['content']['nm']) && is_array($this->data['content']['nm']['rows'])) + { + foreach(array_keys($this->data['content']['nm']['rows']) as $n) + { + if (is_int($n)) + { + unset($this->data['content']['nm']['rows'][$n]); + } + } + //error_log(__METHOD__."() content[nm][rows]=".array2string($this->data['content']['nm']['rows'])); + } + } + /** * Register a form-variable to be processed * diff --git a/api/src/Etemplate/Request/Cache.php b/api/src/Etemplate/Request/Cache.php index fc258b574c..4f536aab91 100644 --- a/api/src/Etemplate/Request/Cache.php +++ b/api/src/Etemplate/Request/Cache.php @@ -135,6 +135,7 @@ class Cache extends Etemplate\Request isset($this->data['last_saved']) && (time()-$this->data['last_saved']) > self::EXPIRATION/2)) { //error_log(__METHOD__."() saving $this->id".($this->data_modified?'':' data NOT modified, just keeping session alife')); + $this->cleanup(); $this->data['last_saved'] = time(); if (!Api\Cache::setTree($GLOBALS['egw_info']['server']['install_id'].'_etemplate', $this->id, $this->data, // use bigger one of our own self::EXPIRATION=4h and session lifetime (session.gc_maxlifetime) as expiration time diff --git a/api/src/Etemplate/Request/Files.php b/api/src/Etemplate/Request/Files.php index 704e242147..eca570b3cf 100644 --- a/api/src/Etemplate/Request/Files.php +++ b/api/src/Etemplate/Request/Files.php @@ -151,10 +151,14 @@ class Files extends Etemplate\Request //error_log(__METHOD__."() destroying $this->id"); @unlink(self::$directory.'/'.$this->id); } - elseif (!$this->destroyed && $this->data_modified && - !file_put_contents($filename = self::$directory.'/'.$this->id,serialize($this->data))) + elseif (!$this->destroyed && $this->data_modified) { - error_log("Error opening '$filename' to store the etemplate request data!"); + $this->cleanup(); + + if (!file_put_contents($filename = self::$directory.'/'.$this->id,serialize($this->data))) + { + error_log("Error opening '$filename' to store the etemplate request data!"); + } } } } \ No newline at end of file diff --git a/api/src/Etemplate/Request/Session.php b/api/src/Etemplate/Request/Session.php index 14e0f11358..c71f4d7731 100644 --- a/api/src/Etemplate/Request/Session.php +++ b/api/src/Etemplate/Request/Session.php @@ -121,6 +121,8 @@ class Session extends Etemplate\Request } elseif (!$this->destroyed && $this->data_modified) { + $this->cleanup(); + Api\Cache::setSession('etemplate', $this->id, $this->data); } if (!$this->garbage_collection_done)