Foreach error in taxonomy-term\index.php

Hi,
with the latest version I get an error in debug.log - but did not find any issues (wrong loop results, …) caused by this.

PHP Warning: foreach() argument must be of type array|object, int given in …
tangible-loops-and-logic\vendor\tangible\template-system\loop\types\taxonomy-term\index.php on line 222

It throws that error many many times per page load. (On a page with many calls to taxonomy about 300k of error messages.

UPDATE:
Was able to eliminate the php errors in debug.log by adding before line 222

if ( is_integer($query_args[ $key ])) continue;

I do not think this is the best solutions, but at least my debug.log is not waisted - and as long I face no other issues caused by this it does the trick.

Maybe a related issue with L&L 4.1.0 and above here (no problem with 4.0.2).

Here’s my template code:

<If archive="taxonomy">
  <If check="{Get local=separator}" is value="yes"> : </If><Term title />
</If>

The shortcode used:

[template name="taxonomy-archive-title" separator="yes"]

And the output in frontend:

warning: foreach) argument must be of type array|object, int given in …/wp-content/plugins/tangible-loops-and-logic/vendor/tangible/template-system/loop/utils/args.php on line 86
warning: foreach) argument must be of type array|object, int given in …/wp-content/plugins/tangible-loops-and-logic/vendor/tangible/template-system/loop/types/taxonomy-term/index.php on line 222

After some more investigation it seems like the ‘include’ values of ‘query_args’ are returned as integer in 4.1.x and as array in 4.0.2

  function get_items_from_query( $query_args ) {

...

    // Convert slugs to IDs

    foreach ([
      'include',
      'exclude',
    ] as $key) {

      if ( ! isset($query_args[ $key ])) continue;
....
1 Like

Maybe useful to alert @benjamin :wink:

1 Like

Thanks for the report - We’re looking into solving it.

1 Like

This has been fixed in version 4.1.3.

2 Likes

Thanks @eliot,

looks good now.

1 Like

It fixed my issue as well, thanks.

1 Like