Commit 8d5536ac by Paul Klimov

yii\mongodb\file\ActiveRecord::update() fixed to save the attributes while updating file.

parent 1af04e1e
...@@ -178,6 +178,16 @@ abstract class ActiveRecord extends \yii\mongodb\ActiveRecord ...@@ -178,6 +178,16 @@ abstract class ActiveRecord extends \yii\mongodb\ActiveRecord
unset($values['file']); unset($values['file']);
} }
if (isset($newFileContent) || isset($newFile)) { if (isset($newFileContent) || isset($newFile)) {
$fileAssociatedAttributeNames = [
'filename',
'uploadDate',
'length',
'chunkSize',
'md5',
'file',
'newFileContent'
];
$values = array_merge($this->getAttributes(null, $fileAssociatedAttributeNames), $values);
$rows = $this->deleteInternal(); $rows = $this->deleteInternal();
$insertValues = $values; $insertValues = $values;
$insertValues['_id'] = $this->getAttribute('_id'); $insertValues['_id'] = $this->getAttribute('_id');
......
...@@ -248,6 +248,7 @@ class ActiveRecordTest extends MongoDbTestCase ...@@ -248,6 +248,7 @@ class ActiveRecordTest extends MongoDbTestCase
$record2 = CustomerFile::find($record->_id); $record2 = CustomerFile::find($record->_id);
$this->assertEquals($record->status, $record2->status); $this->assertEquals($record->status, $record2->status);
$this->assertEquals(file_get_contents($updateFileName), $record2->getFileContent()); $this->assertEquals(file_get_contents($updateFileName), $record2->getFileContent());
$this->assertEquals($record->tag, $record2->tag);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment