@@ -152,22 +152,24 @@ protected function doHandleRequest(RequestInterface $request, callable $next, ca
152152
153153 if ($ cacheItem ->isHit ()) {
154154 $ data = $ cacheItem ->get ();
155- // The array_key_exists() is to be removed in 2.0.
156- if (array_key_exists ('expiresAt ' , $ data ) && (null === $ data ['expiresAt ' ] || time () < $ data ['expiresAt ' ])) {
157- // This item is still valid according to previous cache headers
158- $ response = $ this ->createResponseFromCacheItem ($ cacheItem );
159- $ response = $ this ->handleCacheListeners ($ request , $ response , true , $ cacheItem );
160-
161- return new FulfilledPromise ($ response );
162- }
155+ if (is_array ($ data )) {
156+ // The array_key_exists() is to be removed in 2.0.
157+ if (array_key_exists ('expiresAt ' , $ data ) && (null === $ data ['expiresAt ' ] || time () < $ data ['expiresAt ' ])) {
158+ // This item is still valid according to previous cache headers
159+ $ response = $ this ->createResponseFromCacheItem ($ cacheItem );
160+ $ response = $ this ->handleCacheListeners ($ request , $ response , true , $ cacheItem );
161+
162+ return new FulfilledPromise ($ response );
163+ }
163164
164- // Add headers to ask the server if this cache is still valid
165- if ($ modifiedSinceValue = $ this ->getModifiedSinceHeaderValue ($ cacheItem )) {
166- $ request = $ request ->withHeader ('If-Modified-Since ' , $ modifiedSinceValue );
167- }
165+ // Add headers to ask the server if this cache is still valid
166+ if ($ modifiedSinceValue = $ this ->getModifiedSinceHeaderValue ($ cacheItem )) {
167+ $ request = $ request ->withHeader ('If-Modified-Since ' , $ modifiedSinceValue );
168+ }
168169
169- if ($ etag = $ this ->getETag ($ cacheItem )) {
170- $ request = $ request ->withHeader ('If-None-Match ' , $ etag );
170+ if ($ etag = $ this ->getETag ($ cacheItem )) {
171+ $ request = $ request ->withHeader ('If-None-Match ' , $ etag );
172+ }
171173 }
172174 }
173175
0 commit comments