After updating to 8.x-3.0-rc2, we are getting the error "Serialization of 'CurlHandle' is not allowed in serialize()" when the Feeds cron job runs or when deleting existing Feeds items.
It appears to be related to this commit: https://git.drupalcode.org/project/feeds/-/commit/9b60a9bd8ed4186c46250c...
The commit added a reference to loggers in Feeds State which is serialized between batches. Since we use Monolog to send logs to Loggly, the Loggly log handler has a reference to CurlHandle that can't be serialized. As a temporary workaround, we disabled Loggly for the Feeds log channel. But it would be nice to figure out how to serialize Feeds State without the logger object.
Issue fork feeds-3479242
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
megachrizI had hoped that DependencySerializationTrait would take care of reinitialising the logger, but I see that the object indeed appears in the serialized text, which I found out using the following code:
To fix this,
\Drupal\feeds\Stateshould implement__sleep()to prevent the$loggerproperty from being serialized and implement__wakeup()to restore the logger again.It would be cool if we could add a Unit or Kernel test that fails when the logger would get serialized. Probably it would work to mock
\Psr\Log\LoggerInterfaceand let its__sleep()method throw a \LogicException, similar as how\Drupal\Core\Site\Settingsdoes this for example.Comment #3
megachrizNote: since DependencySerializationTrait already implements
__sleep()and__wakeup(), these methods should be aliased and then be called from theState::__sleep()andState::__wakeup()respectively.Comment #5
megachrizI think that the code provided in the MR should fix the issue for you.
@kevin w
Do you want to test it?
Comment #6
megachrizI guess not serializing the logger creates some problems...
Comment #7
megachrizThe fix was relatively simple, \Drupal\Core\DependencyInjection\DependencySerializationTrait::__sleep() must be compatible with Drupal\feeds\State::__sleep(). So I removed the return value for it.
Comment #9
megachrizBecause there is now an issue related to this one opened whose fix would cause overlap with this one, I merged the code. Feel free to reopen this issue if it didn't completely fix the problem for you.
The related issue: #3487439: Error: Call to undefined method Drupal\feeds\State::messenger()