Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-22150

REST API (legacy): cached results throw PHP fatal error


    • Type: Bug Bug
    • Status: Open
    • Priority: Low Low
    • Resolution: Unresolved
    • Affects Version/s: 4.4 Maintenance
    • Fix Version/s: None
    • Component/s: None
    • Labels:


      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 :


       * 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.


        Vincent Robic created issue -
        Damien Pobel (Inactive) made changes -
        Field Original Value New Value
        Component/s REST API v2 [ 10310 ]
        Gaetano Giunta (Inactive) made changes -
        Summary REST API : cached results throw PHP fatal error REST API (legacy): cached results throw PHP fatal error
        André Rømcke made changes -
        Workflow eZ Engineering Scrumban Workflow [ 61102 ] EZ* Development Workflow [ 69315 ]
        Alex Schuster made changes -
        Workflow EZ* Development Workflow [ 69315 ] EZEE Development Workflow [ 107422 ]


          • Assignee:
            Vincent Robic
          • Votes:
            0 Vote for this issue
            1 Start watching this issue


            • Created:

              Time Tracking

              Original Estimate - 1 hour
              Remaining Estimate - 1 hour
              Time Spent - Not Specified
              Not Specified