Skip to content

EE7.2.2 Throwing Warning on exp:channel:categories With Empty Categories #2571

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
dougblackjr opened this issue Nov 28, 2022 · 7 comments · Fixed by #2681
Closed

EE7.2.2 Throwing Warning on exp:channel:categories With Empty Categories #2571

dougblackjr opened this issue Nov 28, 2022 · 7 comments · Fixed by #2681

Comments

@dougblackjr
Copy link
Contributor

dougblackjr commented Nov 28, 2022

Description of the problem

Displayed warning after using {exp:channel:categories} tag with debug on:
image

How To Reproduce
Steps to reproduce the behavior:

  1. Create template with {exp:channel:categories} tag.
  2. Run loop with an empty category.

For example,

{exp:channel:categories category_group="1"}
        {embed="embeds/category-project-loop" title="{category_name}" cat_id="{category_id}"}
{/exp:channel:categories}

Error Messages


Warning
Undefined variable $all
ee/ExpressionEngine/Addons/channel/mod.channel.php, line 3050

Severity: E_WARNING

Environment Details:

  • Version: 7.2.2
  • PHP Version 8.0
  • MySQL Version : MySQL 8
  • OS: Ubuntu
  • Web Server: nginx

Possible Solution
On line 3050 of mod.channel.php, either null coalesce $all, or ensure it is set outside of the conditional.

@dougblackjr dougblackjr changed the title EE7.2.2 Throwing Warning on Channel Entries EE7.2.2 Throwing Warning on exp:channel:categories With Empty Categories Nov 28, 2022
@intoeetive
Copy link
Contributor

@dougblackjr can you clarify what you call "Run loop with an empty category"?

@dougblackjr
Copy link
Contributor Author

@intoeetive Sure! So, in the template I run this:

{exp:channel:categories category_group="1"}
    {embed="embeds/category-project-loop" title="{category_name}" cat_id="{category_id}"}
{/exp:channel:categories}

I have two categories in this category group that have no entries in them. This is when I get the notice thrown.

If I do this:

{exp:channel:categories category_group="1" show_empty="no"}
    {embed="embeds/category-project-loop" title="{category_name}" cat_id="{category_id}"}
{/exp:channel:categories}

Then the warning disappears.

@intoeetive
Copy link
Contributor

I wasn't able to replicate :(

Is there anything in the embed that might be affecting the output?

@dougblackjr
Copy link
Contributor Author

@intoeetive Nothing I can see. Here's a video walkthrough: https://www.loom.com/share/c6ae57b78d7149efbf9b1816309ea8d3

@intoeetive
Copy link
Contributor

I think this might be related to the other channel:entries tag in this template. Can you send me the full template code, including the layout template and project-block partial?

@tyssen
Copy link

tyssen commented Dec 29, 2022

I'm getting the same thing except for me it happens with and without the show_empty parameter. Even in a completely stripped-down template with just this in it, I get the warning:

  {exp:channel:categories
    channel="articles"
    style="nested"
    show_empty="no"
  }
    <a href="{path=articles}/">{category_name}</a>
  {/exp:channel:categories}

The site I'm working on is on EE 7.2.3.

@PDXMan1
Copy link

PDXMan1 commented Dec 30, 2022

Getting this error also and tested and confirmed it in a stripped-down template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants