php-activerecord icon indicating copy to clipboard operation
php-activerecord copied to clipboard

Model->to_json() fails when any included associations are null in finder results

Open netblue opened this issue 13 years ago • 0 comments

Needs a null check before creating serializer

            try {
                $assoc = $this->model->$association;

                if (!is_array($assoc))
                {
                    $serialized = new $serializer_class($assoc, $options);
                    $this->attributes[$association] = $serialized->to_a();;
                }

A PHP Error was encountered

Severity: 4096

Message: Argument 1 passed to ActiveRecord\Serialization::__construct() must be an instance of ActiveRecord\Model, null given, called in /www/hosts/codeigniter_2.1.0/common/sparks/php-activerecord/0.0.2/vendor/php-activerecord/lib/Serialization.php on line 178 and defined

Filename: lib/Serialization.php

Line Number: 96

netblue avatar Feb 07 '13 01:02 netblue