File content is lost after flush() #290

Closed
myurasov opened this Issue Apr 9, 2012 · 4 comments

Comments

Projects
None yet
4 participants

myurasov commented Apr 9, 2012

$dm = DocumentManager::getInstance();

$fileName = tempnam(null, null);
file_put_contents($fileName, "abc");

$file = new \Documents\File();
$file->setFile($fileName);

$dm->persist($file);
$dm->flush();

echo ($file->getFile()->getBytes()); // "abc"

$file->getFile()->setBytes("123");
$dm->flush();

echo ($file->getFile()->getBytes()); // "abc", *should be "123"*

unlink($fileName);
Owner

jmikola commented Apr 9, 2012

Could you turn this code example into a failing test case? File creation is probably best done with tempnam() and sys_get_temp_dir() for this purpose. Thanks.

myurasov commented Apr 9, 2012

You mean like this?

Owner

jmikola commented Apr 10, 2012

A pull request with a failing test case is preferable.

@malarzm malarzm added the needs test label Jan 21, 2016

@alcaeus alcaeus closed this Dec 22, 2017

Member

alcaeus commented Dec 22, 2017

GridFS is getting a rewrite for 2.0, so I'm closing this (and we still need a test case).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment