Skip to content
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

"Notice: Undefined offset: 0 " from VarnishPurger when purging a single tag #3893

Closed
varacti opened this issue Dec 8, 2020 · 4 comments
Closed

Comments

@varacti
Copy link

varacti commented Dec 8, 2020

API Platform version(s) affected: 2.5.8

Description
An exception is thrown from ApiPlatform\Core\HttpCache\VarnishPurger line 70 with the message "Notice: Undefined offset: 0" when purging a single tag.

The purged tags are defined in class ApiPlatform\Core\Bridge\Doctrine\EventListener\PurgeHttpCacheListener as an associative array [ string => string ], for example in function gatherResourceAndItemTags :

114     $iri = $this->iriConverter->getIriFromResourceClass($resourceClass);
        // $iri is supposed to be a string here because of getIriFromResourceClass signature !!!
115     $this->tags[$iri] = $iri;

Then this array is directly send to VarnishPurger from PurgeHttpCacheListener :

106     $this->purger->purge($this->tags);

But if this array contains a single asociation, VarnishPurger fails line 70 and throws an exception.

Possible Solution
Replace "ApiPlatform\Core\HttpCache\VarnishPurger" Line 70 :

yield $parts[0];

with:

yield array_shift($parts)
@julienfalque
Copy link
Contributor

Woops, likely related to #3843, I'll have a look.

@julienfalque
Copy link
Contributor

See #3894.

@stale
Copy link

stale bot commented Nov 5, 2022

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 Nov 5, 2022
@julienfalque
Copy link
Contributor

This issue can be closed as #3894 was merged.

@stale stale bot removed the wontfix label Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants