Closed xleliberty closed 10 years ago
@xleliberty How do you set the image or how does your code look like?
HiThere is no extra code ...
Xavier Lembo
On Sat, Jul 19, 2014 at 9:33 PM, hacfi notifications@github.com wrote:
@xleliberty How do you set the image or how does your code look like?
Reply to this email directly or view it on GitHub: https://github.com/symfony-cmf/MediaBundle/issues/109#issuecomment-49527555
bizar. are you using fixtures code or an upload? to debug, i would hack into the imagine block code to save a copy of the image to the file system to see if the data is already bad at that point. to narrow down at which point things go wrong...
Hi, thanks for you advice.
I'm currently debugging , i hope i'll find something. Xavier
I've still no luck with this problem... i've tried debugging but problem seems to be at flush time.
if i dump image just before flushing the complete block (Sonata\DoctrinePHPCRAdminBundle\Model\ModelManager::create ) , the file is ok. After, it's not...
i've checked again all vendor versions, and packages that matter ( phpcr stuff, jackalope, doctrine/phpcr-odm ) are same on the 2 projects ( symfony-cmf / my project )
Really no idea...
Well, the problem lies in doctrine/postgresql/bytea relations... i've just change the database type of my symfony-cmf from sqlite to postgresql and then, same problem... Things are not related to MediaBundle... i still investigate.
Xavier
uh, interesting. if you change your project to mysql / sqlite, does the problem go away? you could configure a separate dbal connection for jackalope if you use postgres for other things too. (not proposing this as a solution, just to narrow this down).
we seem to have a bunch of tests around binaries in phpcr-api-tests: https://github.com/phpcr/phpcr-api-tests/blob/master/tests/10_Writing/SetPropertyTypesTest.php#L49
but i notice that we set textual data as binary stream, not "real" binary data. if you can investigate further, one thing could be to checkout the jackalope-doctrine-dbal repository stand alone, configure phpunit.xml to run postgres and run the test suite, which should also run those tests. then you could add one more test in SetPropertyTypesTest with some non-printable binary data. if this fails too, we are pretty sure where the problem lies.
Well, i think i've finally isolated the problem. I work on mac dev machine and use liip/php-osx , i think it's the culprit... it's compiled with an oooold version of libpq PostgreSQL(libpq) Version 8.2.23 PostgreSQL(libpq) PostgreSQL 8.2.23 on i386-apple-darwin12.5.0, compiled by GCC Apple clang version 4.0 (tags/Apple/clang-421.0.57) (based on LLVM 3.1svn)
It seems that this old libpq version doesn't handle cleanly bytea conversions . i've just done a quick test that show the problem and a solution.
CREATE TABLE bintest
(
id serial NOT NULL,
data bytea,
CONSTRAINT pkok PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
<?php
//DATA insertion
$dbh = new PDO("pgsql:dbname=cmf;host=localhost", 'xav');
$thebytes = file_get_contents('source.jpg');
$sth = $dbh->prepare("INSERT INTO bintest ( data ) VALUES (:content)");
$sth->bindParam(':content', $thebytes, PDO::PARAM_LOB);
$sth->execute();
//DATA Reading
//If we use this line, everything is ok
$dbh->query("SET bytea_output=escape");
$sth = $dbh->prepare("SELECT data FROM bintest WHERE id = 1");
$sth->execute();
$content = $sth->fetchColumn();
file_put_contents('test.jpg', $content);
I'm currently reinstalling php from homebrew to verify that, i'll let you know.
Xavier
Ok, the end...
i confirm that in my case the culprit is liip/php-osx ... i've just test again with php compiled with latest libpq and everything is fine.
Sorry for this noise, i close this.
Xavier
glad you found the issue. i see you created https://github.com/liip/php-osx/issues/123 - i hope somebody here at liip can address this. (i am working on linux and never touch macs when i can avoid it :-)
Hi all, i'm trying to install cmf bundles into an existing application. a lot of components are ok, but i got a problem with images.
When i save an image into phpcr ( doctrinedbal ) , content is not saved into proper binary format.
if i dump the saved node, i got this:
but datas should be something like:
I don't understand why the content is converted to hexa string.
if I install cmf-sandbox and test it, everything is fine. I have checked all my configs against cmf-sandbox , but i can't find the problem.
Maybe someone have an idea ?
Thanks in advance
Xavier