Description
Cached results throw a PHP fatal error if a custom HTTP reponse code is set.
Steps to reproduce :
Create a REST application (...) and write create a controller that extends ezpRestMvcController, that contains :
My API controller
class GVSAPIController extends ezpRestMvcController { public function doGetTest() { $result = new ezpRestMvcResult(); $result->status = new ezpRestHttpResponse(204, "Nothing found"); return $result; } }
The doGetTest() method defines an HTTP code.
Enable caching in rest.ini and run the API once. Right, it outputs the custom message and the result gets cached.
But when you run it again, the cached PHP file throws the following error :
Fatal error: Call to undefined method ezpRestHttpResponse::__set_state()
I just implemented and tested the missing method of ezpRestHttpResponse :
kernel/private/rest/classes/status/http_response.php
/** * Returns a new instance of this class with the data specified by $array. * * $array contains all the data members of this class in the form: * array('member_name'=>value). * * __set_state makes this class exportable with var_export. * var_export() generates code, that calls this method when it * is parsed with PHP. * * @param array(string=>mixed) $array * @return ezpRestHttpResponse */ static public function __set_state( array $array ) { return new ezpRestHttpResponse( $array['code'], $array['message'] ); }
Add it in the mentionned file and the bug will be fixed.
PS : i'm not sure about the version. I use eZ Publish Community 2012.8.