Skip to content

Psr16Adapter should convert Traversable into array in deleteMultiple #700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
oskarakerlund opened this issue Aug 5, 2019 · 4 comments
Closed

Comments

@oskarakerlund
Copy link

Configuration

  • PhpFastCache version: 7.0.5
  • PHP version: 7.1

Describe the bug

The PSR-6 CacheItemPoolInterface requires an array as input to deleteItems however PSR-16 accepts an array or a Traversable as input to deleteMultiple. But in Psr16Adapter, the input is passed from deleteMultiple directly to deleteItems without checking if it is an array.

Using Psr16Adapter and calling deleteMultiple with the output from a generator function should work since it follows PSR-16. But currently it triggers an error:

Uncaught TypeError: Argument 1 passed to Phpfastcache\Drivers\Files\Driver::deleteItems() must be of the type array, object given, called in /var/www/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Helper/Psr16Adapter.php on line 178 and defined in /var/www/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php:297
Stack trace:
#0 /var/www/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Helper/Psr16Adapter.php(178): Phpfastcache\Drivers\Files\Driver->deleteItems(Object(Generator))
#1 /var/www/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Cells.php(492): Phpfastcache\Helper\Psr16Adapter->deleteMultiple(Object(Generator))

To Reproduce
Steps to reproduce the behavior:
Use the Psr16Adapter and call deleteMultiple using a generator function. PhpSpreadsheets does this.

Expected behavior
deleteMultiple should convert any Traversable to an array before calling deleteItems.

@Geolim4
Copy link
Member

Geolim4 commented Aug 6, 2019

Hello !

Thanks for that issue, I'll take a look this weekend.

Cheers,
Georges

@stale
Copy link

stale bot commented Aug 21, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 21, 2019
@oskar-wikinggruppen
Copy link

@Geolim4 will you make sure this issue stays open?

@stale stale bot removed the wontfix label Aug 27, 2019
@Geolim4
Copy link
Member

Geolim4 commented Aug 27, 2019

Yeah, I'm a little sick these day, I will treat all the pending issues on a row :)

bylexus added a commit to bylexus/phpfastcache that referenced this issue Sep 3, 2019
…rts $keys to an array.

The internal Psr\Cache\CacheItemPoolInterface::deleteItems requires an array as argument. Some popular tools like PhpSpreadsheet use a Traversable instead.
This is the fix for the v6 branch.
bylexus added a commit to bylexus/phpfastcache that referenced this issue Sep 3, 2019
…Traversable $keys in an array

The internal array_map function can only be used with native arrays.
bylexus added a commit to bylexus/phpfastcache that referenced this issue Sep 3, 2019
…nverts Traversable $keys in an array

The internal array_map function can only be used with native arrays.
Geolim4 added a commit that referenced this issue Sep 4, 2019
fixes #700 for v6: Psr16Adapter::deleteMultiple converts $keys to an array
@Geolim4 Geolim4 closed this as completed in 05d62ec Sep 4, 2019
Geolim4 added a commit that referenced this issue Sep 4, 2019
fixes #700: Psr16Adapter::deleteMultiple converts $keys to an array.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants