• fbcyborg

    (@fbcyborg)


    Hello everyone,
    in order to make troubleshooting I am trying to understand the flow that leads to the content present into the $exclude variable at row 469 in the class-wp-term-query.php file. So I hope someone here can help me to understand.

    As far as I see when the get_terms() function is called, such $args variable is valued thanks to qery_vars.

    I have understood that this is not something that comes from a database configuration but it is most likely due to a query (string?) parameter(s) received at that point, but I don’t understand why I have an exclusion a certain point of the code (like a category id = 10) which I don’t absolutely want.

    For what I see, this get_terms() function is called by query($query) function which is referenced by:

    • taxonomy.php inside get_terms() function
    • class-wp-rest-term-search-handler.php inside search_items() function
    • class-wp-tax-query.php inside transform_query() function
    • in block-template-utils.php in another function which I’m omitting now

    Now, given that, I’m using WordPress 6.1.1, User Access Manager 2.2.19 and Postie 1.9.65, with your help to understand the flow, I would like to understand why I see a category in the exclusion list. Is there any suggestion for adding some debug information?

    Thanks in advance

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator bcworkz

    (@bcworkz)

    The default is for no exclusions, so if that var has values, something added it somewhere along the way. Which way was that? There are too many possibilities. Something may have added it as one of the args when the class was instantiated. Or something could have added it through one of the many filters available.

    You could try looking through the functions called to get to that point by using debug_backtrace(). Or step through the code and check the relevant properties after every filter and action hook encountered. You can learn what callbacks were added through any specific action or filter hook through the global $wp_filter var.

    If the exclusion is inappropriate, sometimes it’s easier to remove it after it had been added than to track down the source. You just need to ensure the removal code runs after it had been added.

    Thread Starter fbcyborg

    (@fbcyborg)

    Thank you very much for the explanation. Consider that I started this thread to get help on understanding the flow, as mentioned before, but the original issue is described here and it deals with a possible conflict between two plugins: User Access Manager and Postie.

    I think removing that data after it is added is a bit risky even if it would be a temporary fix, since I suppose that function is executed by many other functions within the wordpress core.

    Moderator bcworkz

    (@bcworkz)

    Well, the truth of the matter is setting or unsetting any query var at any point could be risky if care is not taken to ensure you are only changing the query you intend to change and not any others. Using a large $priority arg when you add your callback helps ensure it’ll have the final say in the matter. Doing so often necessitates altering something that has already been set.

    If you use a small $priority there’s a fair chance something else would modify your query in an undesirable manner. Remove any risk by ensuring with conditional checks that you’re only altering the right query.

    Thread Starter fbcyborg

    (@fbcyborg)

    Thanks a lot @bcworkz !

    I’ll do that as soon as I can. It’s very weird anyway, that this problem occurs only in production. Taking the whole site and installing on localhost gives no problem.

    Moderator bcworkz

    (@bcworkz)

    Cat exclusions only occur on production? That is quite strange. The usual cause for different behavior is due to varying server configurations. Different PHP versions, different mySQL servers, different mySQL permissions, etc. I cannot imagine how cat exclusions would vary by installation, assuming all the same plugins and theme. Could there be differing plugin or theme versions?

    Sometimes hosts place must-use plugins in their WP installations that can alter behavior, but I seriously doubt they’d inject cat exclusions. Could production have some other non-host sourced MU plugin? They are not visible in the WP UI, you need to look in /wp-content/mu-plugins/ via FTP for any files. If there is no such folder, you don’t have any MU plugins.

    Thread Starter fbcyborg

    (@fbcyborg)

    Yes, it only happens in production and I tried to replicate as much as possible the prod configuration on my local environment, but let’s summarize the differences:

    • PHP: PROD: 8.0.27, localhost: 8.0.0
    • MySQL: PROD (5.5.62-38, Yes I know it’s obsolete but since an upgrade will cost money, let’s keep it as last option), localhost: 5.7.33 – MySQL Community Server)
    • Database User permissions: need to investigate in PROD, I gave everything on localhost
    • There’s no difference between theme and plugins
    Moderator bcworkz

    (@bcworkz)

    I’m at a loss for an explanation. In any case you’re kind of stuck with the situation at hand and need to react accordingly.

    Thread Starter fbcyborg

    (@fbcyborg)

    Yes, definitely. I think the best solution is to opt out for a different combination of plugins. Either change UAM or Postie. I see no other possibility.

    Thanks a lot!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘$args[‘exclude’] function in class-wp-term-query.php’ is closed to new replies.