@@ -102,7 +102,7 @@ private function invalidateCache($key) {
102102 $ keys = array_keys ($ this ->objectCache ->getData ());
103103 $ keyLength = strlen ($ key );
104104 foreach ($ keys as $ existingKey ) {
105- if (substr ($ existingKey , 0 , $ keyLength ) === $ keys ) {
105+ if (substr ($ existingKey , 0 , $ keyLength ) === $ key ) {
106106 unset($ this ->objectCache [$ existingKey ]);
107107 }
108108 }
@@ -244,17 +244,22 @@ private function batchDelete($path = null) {
244244 $ params ['Prefix ' ] = $ path . '/ ' ;
245245 }
246246 try {
247+ $ connection = $ this ->getConnection ();
247248 // Since there are no real directories on S3, we need
248249 // to delete all objects prefixed with the path.
249250 do {
250251 // instead of the iterator, manually loop over the list ...
251- $ objects = $ this -> getConnection () ->listObjects ($ params );
252+ $ objects = $ connection ->listObjects ($ params );
252253 // ... so we can delete the files in batches
253- $ this ->getConnection ()->deleteObjects (array (
254- 'Bucket ' => $ this ->bucket ,
255- 'Objects ' => $ objects ['Contents ' ]
256- ));
257- $ this ->testTimeout ();
254+ if (isset ($ objects ['Contents ' ])) {
255+ $ connection ->deleteObjects ([
256+ 'Bucket ' => $ this ->bucket ,
257+ 'Delete ' => [
258+ 'Objects ' => $ objects ['Contents ' ]
259+ ]
260+ ]);
261+ $ this ->testTimeout ();
262+ }
258263 // we reached the end when the list is no longer truncated
259264 } while ($ objects ['IsTruncated ' ]);
260265 } catch (S3Exception $ e ) {
0 commit comments