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

Attempting to filter by no taxonomy shows an error #1916

Closed
mikemartin opened this Issue May 8, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@mikemartin

mikemartin commented May 8, 2018

Describe the bug
I think this might be related to #1257. Since the 2.8.12 update a number of my pages with taxonomy related content are outputting an error. Do I need to update my collection conditions or is this a bug?

For example:

{{ collection:videos limit="3" as="videos" :url:not="url" :taxonomy:topics:any="topics" }}

returns the error: ErrorException in CollectionTags.php line 214: array_filter() expects parameter 1 to be array, null given

Environment details (please complete the following information):

  • Statamic Version 2.8.12

Additional context

Whoops, looks like something went wrong.
1/1
ErrorException in CollectionTags.php line 214:
array_filter() expects parameter 1 to be array, null given
in CollectionTags.php line 214
at HandleExceptions->handleError('2', 'array_filter() expects parameter 1 to be array, null given', '/Users/mike/Sites/api-academy/statamic/bundles/Collection/CollectionTags.php', '214', array('terms' => null, 'param' => 'taxonomy:topics:any', 'parts' => array('taxonomy', 'topics', 'any'), 'taxonomy' => 'topics', 'method' => 'any'))
at array_filter(null) in CollectionTags.php line 214
at CollectionTags->Statamic\Addons\Collection\{closure}(null, 'taxonomy:topics:any')
at array_map(object(Closure), array('taxonomy:topics:any' => null), array('taxonomy:topics:any')) in Collection.php line 469
at Collection->map(object(Closure)) in CollectionTags.php line 217
at CollectionTags->getTaxonomyCollectionFromParams('videos') in CollectionTags.php line 154
at CollectionTags->getTaxonomyCollection('videos') in CollectionTags.php line 124
at CollectionTags->getCollection('videos') in CollectionTags.php line 94
at CollectionTags->collect('videos') in CollectionTags.php line 82
at CollectionTags->__call('videos', array())
at call_user_func(array(object(CollectionTags), 'videos')) in Engine.php line 163
``
@jasonvarga

This comment has been minimized.

Member

jasonvarga commented May 8, 2018

Are you trying to filter by topics named "topics"? Or are you referencing a variable named topics?

@mikemartin

This comment has been minimized.

mikemartin commented May 8, 2018

@jasonvarga referencing a variable named topics:

topics:
  - microservices

However, i just realized for this particular post topics does not exist.

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented May 8, 2018

That'll do it then. Can you maybe wrap the whole thing in {{ if topics }}?

@mikemartin

This comment has been minimized.

mikemartin commented May 8, 2018

@jasonvarga I can do that. thx!

@mikemartin mikemartin closed this May 8, 2018

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented May 8, 2018

You can leave this open. We should check for nulls instead of causing an error.

@jasonvarga jasonvarga reopened this May 8, 2018

@mikemartin

This comment has been minimized.

mikemartin commented May 8, 2018

@jasonvarga was hoping you might say this. At least this is a future proof workaround. 👍

@jasonvarga jasonvarga changed the title from Bug: Interpolated taxonomy parameters outputting errors since 2.8.12 update to Attempting to filter by no taxonomy shows an error May 9, 2018

@jackmcdade jackmcdade self-assigned this Jun 4, 2018

@jackmcdade jackmcdade closed this Jun 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment