0011362: mime-type lost after detail update
authorCornelius Weiß <c.weiss@metaways.de>
Thu, 8 Oct 2015 17:59:49 +0000 (19:59 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 22 Oct 2015 08:42:45 +0000 (10:42 +0200)
https://forge.tine20.org/view.php?id=11362

Change-Id: Iaf32609c4130c81dc6ce4d921e72fa6b171da163
Reviewed-on: http://gerrit.tine20.com/customers/2264
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Filemanager/Frontend/JsonTests.php
tine20/Filemanager/Controller/Node.php

index eed72b4..4f7956d 100644 (file)
@@ -995,14 +995,17 @@ class Filemanager_Frontend_JsonTests extends TestCase
         $result = $this->_json->searchNodes($filter, array());
         
         $this->assertEquals(2, $result['totalcount']);
+        $initialNode = $result['results'][0];
         
-        $node = $this->_json->getNode($result['results'][0]['id']);
+        $node = $this->_json->getNode($initialNode['id']);
         $this->assertEquals('file', $node['type']);
         
         $node['description'] = 'UNITTEST';
         $node = $this->_json->saveNode($node);
         
         $this->assertEquals('UNITTEST', $node['description']);
+        $this->assertEquals($initialNode['contenttype'], $node['contenttype'], 'contenttype  not preserved');
+
         
         return $node;
     }
index 0916703..b2193c6 100644 (file)
@@ -112,9 +112,10 @@ class Filemanager_Controller_Node extends Tinebase_Controller_Record_Abstract
      */
     protected function _inspectBeforeUpdate($_record, $_oldRecord)
     {
+        // protect against file object spoofing
         foreach (array_keys($_record->toArray()) as $property) {
-            if (! in_array($property, array('id', 'name', 'description', 'relations', 'customfields', 'tags', 'notes', 'object_id'))) {
-                unset($_record->{$property});
+            if (! in_array($property, array('name', 'description', 'relations', 'customfields', 'tags', 'notes'))) {
+                $_record->{$property} = $_oldRecord->{$property};
             }
         }
     }