Skip to content

Instantly share code, notes, and snippets.

@lfglopes
Last active August 29, 2015 14:11
Show Gist options
  • Save lfglopes/06725dd1d287d17e7a4e to your computer and use it in GitHub Desktop.
Save lfglopes/06725dd1d287d17e7a4e to your computer and use it in GitHub Desktop.
php-activerecord #476
From af46512dd5aed90cc9b976f9529a8378cf1707ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lu=C3=ADs=20Lopes?=
Date: Thu, 18 Dec 2014 14:57:23 +0000
Subject: [PATCH] fixed AR serialization problem
https://github.com/jpfuentes2/php-activerecord/issues/476
---
kernel/vendor/activerecord/lib/Serialization.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/vendor/activerecord/lib/Serialization.php b/kernel/vendor/activerecord/lib/Serialization.php
index db02088..523ae54 100755
--- a/kernel/vendor/activerecord/lib/Serialization.php
+++ b/kernel/vendor/activerecord/lib/Serialization.php
@@ -173,7 +173,10 @@ abstract class Serialization
try {
$assoc = $this->model->$association;
- if (!is_array($assoc))
+ if (is_null($assoc)) {
+ $this->attributes[$association] = null;
+ }
+ elseif (!is_array($assoc))
{
$serialized = new $serializer_class($assoc, $options);
$this->attributes[$association] = $serialized->to_a();;
--
2.1.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment