For view fields marked a "serialize" (like "display_options"), there is an inconsistency between the way the data is saved in the database and the way the data is reloaded.

In view::save_row (view.inc, line 1632), field value is saved as "serialize($this->$field)"
But in view::load_row (view.inc, line 1675), field value is reloaded as "unserialize(db_decode_blob($data->$field))"

Luckily, for MySQL, db_decode_blob just returns the passed argument so it does not hurt.

But for other types of databases, it might cause I major problem since Views is unable to read back what it saved in the database.

I hit the problem with SQLite, I did not test it but think it will also be a problem with PostgreSQL.

The fix is fairly simple: replace line 1632 in views.inc with :

        $values[] = db_encode_blob(serialize($this->$field));

Thanks for your attention.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs work

Could you make a patch out of it?

gfrenoy’s picture

FileSize
353 bytes

Patch for 3.0-alpha3 is attached.

dawehner’s picture

Status: Needs work » Needs review

update status.

Thanks!

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

This makes sense for me.

merlinofchaos’s picture

Version: 6.x-3.0-alpha3 » 7.x-3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Does not apply to 7.x so needs porting.

Committed to 6.x.

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Priority: Normal » Critical
Status: Patch (to be ported) » Needs work

This patch has to be reverted. This causes the problems in #940104: views-6.x-3.x-dev of Oct 12 empties the contents of fields on save

dawehner’s picture

Revert for both versions.

Thanks for git bisect

dagmar’s picture

Status: Needs work » Needs review
dagmar’s picture

Status: Needs review » Reviewed & tested by the community

Yes this patch is causing the problem. I just tested it.

dawehner’s picture

Status: Reviewed & tested by the community » Active

Reverted the patch

iamjon’s picture

Status: Active » Postponed

gfrenoy,
can you try to patch again based on the comments on #940104: views-6.x-3.x-dev of Oct 12 empties the contents of fields on save?

marking this as postponed from lack of activity.

merlinofchaos’s picture

Status: Postponed » Closed (won't fix)