When importing an export, I get the error:

Fatal error: Call to undefined method stdClass::__set_state() in /home/drupal/drupal6/sites/default/modules/mymodule/mymodule.module on line 310

I looks like this is related to the issue the Devel module had last year It has a patch attached that might be portable: http://drupal.org/node/215375

Comments

batje’s picture

This seems to be only when exporting multiple contexts, using admin/build/context/export

Exporting a single context generates correct code.

miche’s picture

Priority: Normal » Critical

I am experiencing the same error. If I have exported my contexts (but haven't deleted them from database yet so they should be considered Overridden) or if I have deleted them from the database (so they are considered Default), this error appears on all pages.

If I comment out my MODULENAME_context_default_contexts function, then the error disappears.

I changed priority to critical as the module doesn't appear to be working as designed.

ebeyrent’s picture

+1

ebeyrent’s picture

It appears that removing the stdClass::__set_state() and leaving just an array works just fine.

miche’s picture

I agree with comment #4. Implemented per the link in this issue's description.

James Andres’s picture

StatusFileSize
new864 bytes

Here's a patch that resolves the issue for me. I just replaced the stdClass::__set_state() with a cast to (object) which is semantically the same. Same enough at least.

This should work on PHP 4 as well as 5, though I haven't actually tested in PHP 4.

fearlsgroove’s picture

Status: Active » Needs review
StatusFileSize
new628 bytes

There's an underlying issue there somewhere, which is how is it that there are unexpectedly objects being returned for context to export? I don't know the answer to that, but this patch converts them to arrays, similarly to #215375: Fatal error: Call to undefined method stdClass::__set_state(), instead of relying on string replacement. So, this doesn't fix whatever the root problem is but it heads off the issue sufficiently to warrant consideration for commit in the meantime

steven jones’s picture

Issue tags: +context-2.x-rc-blocker

Needs to be fixed for 2.x

fearlsgroove’s picture

I should note this before I forget ... the bulk export produces the arrays wrapped in a function, presumably to be included with a module, and does not import successfully. This appears to be by design ... Exporting contexts individually does seem to work. I can't reproduce the circumstances to created objects for the "block" values of the exported contexts, which is what in turn caused the invalid export code above.

steven jones’s picture

Status: Needs review » Fixed

Fixed in 2.x

Status: Fixed » Closed (fixed)
Issue tags: -context-2.x-rc-blocker

Automatically closed -- issue fixed for 2 weeks with no activity.