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

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

    Details

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

      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.

        Activity

          People

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

            Dates

            • Created:
              Updated:

              Time Tracking

              Estimated:
              Original Estimate - 1 hour
              1h
              Remaining:
              Remaining Estimate - 1 hour
              1h
              Logged:
              Time Spent - Not Specified
              Not Specified