Skip to content

Commit

Permalink
Make panel data binary values.
Browse files Browse the repository at this point in the history
postgres gets really sad when you put null bytes into character columns.
With this change new schema will use binary columns which work fine in
postgres.
  • Loading branch information
markstory committed Jan 5, 2016
1 parent 816d40d commit e19f55c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/Model/Entity/Panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,20 @@ class Panel extends Entity
* @var array
*/
protected $_hidden = ['content'];

/**
* Read the stream contents.
*
* Over certain sizes PDO will return file handles.
* For backwards compatibility and consistency we smooth over that difference here.
*
* @return string
*/
protected function _getContent($content)
{
if (is_resource($content)) {
return stream_get_contents($content);
}
return $content;
}
}
2 changes: 1 addition & 1 deletion tests/Fixture/PanelsFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PanelsFixture extends TestFixture
'title' => ['type' => 'string'],
'element' => ['type' => 'string'],
'summary' => ['type' => 'string'],
'content' => ['type' => 'text'],
'content' => ['type' => 'binary'],
'_constraints' => [
'primary' => ['type' => 'primary', 'columns' => ['id']],
'unique_panel' => ['type' => 'unique', 'columns' => ['request_id', 'panel']],
Expand Down

3 comments on commit e19f55c

@dandoingdev
Copy link

@dandoingdev dandoingdev commented on e19f55c Jul 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change has caused me days of issues :) I've moved to developing on a new machine using the GoogleAppEngine (GAE) SDK, it does not behave nicely with the php data wrapper used to convert the values to PHP when retrieved from the database (Core/Database/Type/BinaryType.php). I've fixed for my development by using the original 'text' column type - I don't know what to suggest as a long term solution as php://data is unsupported.

https://cloud.google.com/appengine/docs/php/runtime#PHP_Stream_wrappers

@markstory
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't either. Sounds like you'll have to use a custom BinaryType on Google App Engine.

@dandoingdev
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'll try and invest some time in creating a more solid work around soon.

Please sign in to comment.