Possible Bug with Query Monitor Plugin?

Just tried to install Query Monitor – WordPress-Plugin | WordPress.org Deutsch on a site together with L&L, but for some reason query monitor throws a fatal error as soon as both of the plugins are activated. When i deactivate L&L everything works again. Is this a known bug or idid anyone else experience the same behaviour?

Hmm, you’re right, when I install Query Monitor I get a fatal error when I try to activate or deactivate either plugin. The error message I’m getting seems to be coming from the Query Monitor side of things though:

Fatal error: Uncaught Error: preg_split() expects parameter 2 to be string, integer given in \wp-content\plugins\query-monitor\classes\Hook.php on line 65

Is that the same error you’re getting? I’m not a dev, but it seems like this might be something that would need to be solved by Query Monitor. The support on their repo page you linked looks pretty responsive though, so it seems like posting on there might be your best bet. Let me know how that goes and if that doesn’t work out, let me know and I’ll see what we can do!

Hi @benjamin and thank you very much for your reply. I opened a ticket at the other plugin’s support page. I’ll keep you updated.

Not sure if i should create a new forum post for this, but the reason I wanted to investigate the queries with the plugin is that I tried to use L&L templates within this plugin: https://wpgridbuilder.com/ . Basically it is something like an Elementor or Beaver Builder post widget or Facet WP. However, the problem is that the template does not use the correct post ID.

From other forum posts I have seen that this should work with Get local variable and it does. But the problem is that this way I have to use the template in combination with a loop tag and this causes unnecessary database queries.

This is my current setup:

<Loop type=post id="{Get local=post_ids}">

Used shortcode within WP Grid Builder
[template id=824 post_ids={{post.id}}]

Is there any way to accomplish this without the loop tag?

I have just received a reply from the developer of Query Monitor. According to him, an invalid hook name within L&L is the cause of the problem. Here is the full answer:

Thanks for the report! The cause here is the Tangible Loops and Logic plugin is triggering an action with an invalid hook name. The hook name appears to be boolean false, which internally gets converted to integer zero by the WordPress hook system, and this is what gets passed onto QM and causes the fatal error. A hook name must be a string, and anything such as boolean false is not going to work and needs to be fixed.

You should report this to the developers of the Loops and Logic plugin. The problematic code is here: https://plugins.trac.wordpress.org/browser/tangible-loops-and-logic/tags/3.1.1/vendor/tangible/plugin-framework/tangible-module.php?marks=173#L173 . The value of $this->ready at this point is boolean false.

Nice, glad they were able to clear that up! I’ll pass this along to a dev to get this addressed and I’ll follow up in this thread when the issue has been resolved.

Glad to hear your workaround gets your template working, but you’re right that that’s not ideal. In theory, you wouldn’t need to set a local variable and then add a loop to pass the right context to your L&L template. L&L should be able to understand what the “current” post is and be able to get fields and context from that post. It seems that with a few plugins, like WPGridBuilder in your case, that context isn’t getting through so L&L isn’t quite sure where to get data from the current post. Are you using the standalone WP Grid Builder plugin or are you using it through its add-on for Elementor or Beaver Builder?

Thanks for your assistance Benjamin, appreciate it.

Regarding WP Grid Builder:
I usually use it in combination with Elementor, but just tried it with a Gutenberg only site. Unfortunately with the same result. It only works with a local variable and a loop tag.

@benjamin, sorry to bother you with this again, but you said that this should actually work automatically without a loop tag. Do you have any idea why it doesn’t work here or how to solve this?

I’m not a dev so unfortunately I don’t have great insight into why exactly this is happening, but I know the big-brained folks I work with are working on it. To clarify, when I said it “should” work, I really meant that that’s how it’s supposed to work but obviously that doesn’t seem to be the case for you currently in WP Grid Builder.

What I do know is that L&L relies on the default loop of the current page to understand the context of where it should be getting data. That’s why if you placed an L&L template on a regular page or post and just wrote <Field title /> inside the template, L&L would display the title of the current post. You wouldn’t need to write <Loop type=post id=current><Field title /></Loop>.

While that’s easy on a singular page or an archive, things get tricky when you add third-party plugins into the mix like Beaver Builder/Themer, WP Grid Builder, and others. These plugins need to be able to do fancy stuff like previewing a theme layout, making things look different on the front end and back end, etc. So from my (limited) understanding, this makes it more complicated for L&L to know what that default loop context should be when its templates are placed inside those plugin interfaces because it can’t just look at the default current WP loop and display data from there. This seems to cause some unexpected behaviors like the one you’re experiencing. When these plugins use L&L’s shortcodes, the general workaround is to do as you’re doing by:

  1. Getting the current page ID from the plugin you’re working with (sounds like that’s {{post.id}} in WP Grid Builder and it’s [wpbb post:id] in Beaver Builder/Themer)
  2. Passing that ID to a local variable in the shortcode (like [template id=824 post_id={{post.id}}] in your example or [template id=200 post_id="[wpbb post:id]"] in BB)
  3. Wrapping your template in a loop (as you’ve done with <Loop type=post id="{Get local=post_id}">)

I hope that explains why it’s not always a simple matter for L&L to understand the loop context in third-party plugins. The team is continuously working on improving compatibility while juggling additional priorities so I expect that compatibility will improve over time and that eventually passing the current post ID through a variable will no longer be necessary.

I just tested out WP Grid Builder (either I’m missing something or that plugin has got a really terrible default card layout haha!) and luckily I was able to replicate the issue you were describing. I’ll pass the information along to the team to see if they can address this.

As I was writing that, a new version of L&L dropped! It looks like this version solves the Query Monitor issue that started this thread so do let me know if that’s working for you now.

It also looks like the update has solved the issue of needing this workaround in the Beaver Builder context but didn’t solve whatever is causing your issue with WP Grid Builder so I’ll still have someone take a look at that.

Great, i can confirm that the issue with query monitor is solved. Thanks a lot for the quick fix!

Thanks also for the detailed explanation regarding the Post ID issue and third party plugins. I absolutely understand that this is not easy to do, especially since there are thousands of plugins. I was just hoping that there might be a similar solution for this as with Beaver Builder and it might be quick to resolve. After all, it could also be due to WP Grid Builder itself that this doesn’t work as intended.

Anyway, I’m already very grateful that you guys are taking a closer look. After all, L&L is a free plugin (btw, I would pay for it :)) and it’s not a given that you guys care about compatibility with rather small third-party plugins. I really appreciate your great plugin and your outstanding customer support.

1 Like

Glad to hear the fix worked!

About the WP Grid Builder workaround, you’re right that it’s tricky to support all the different ways that every WP plugin modifies the site’s default queries. Our main priority is to maintain compatibility with the big builders (Gutenberg, Elementor, Beaver Builder) and their add-ons, but it can sometimes be valuable to look into how other plugins work in case we can expand that net of compatibility to include them without needing to build a one-off integration for every possible WordPress plugin. The nice thing is that L&L is built in such a robust way that even when there isn’t native compatibility with every plugin, there are usually workarounds to achieve whatever you’re trying to do, like the one we discussed above. All that to say we’ll see what we can do with your request!

On another note, I appreciate your recognition of the efforts we put into the plugin and our support. We’re trying to build a game-changing templating system with this plugin and your feedback and support really help. We’re never planning on charging for the base version of Loops & Logic, but if you’re looking for some way to support the project, posting a five-star review on the WP repo always helps :slight_smile: I think our current average rating is 4.8 stars so we’re trying to keep that average up!

Hi Stefan, I had a dev look into your issue with WP Grid Builder and they were able to confirm that the reason this wasn’t working for you and you needed to use the workaround of passing the post ID to L&L is because WP Grid Builder doesn’t use the global wp_query system that’s standard in WordPress and that system is what L&L expects when establishing its loop context.

We haven’t had a chance to properly document this yet, but I wanted to let you know that in the latest version of Loops & Logic (3.1.3) there’s a new integration for WP Grid Builder that add the ability to select a template to add to your grid. This will be added to the docs shortly but for now, you can check out this thread for more info.

If you haven’t reviewed the plugin on the WP repo already, hopefully this new feature we added for you is worth a five-star rating :slight_smile:

Hi Benjamin, please apologize the late reply and thanks so much for the great support. I’m almost drowning in work right now, but as soon as I have some time, I definitely will.

I already tested the integration for WP-Grid Builder and it works perfectly. Big kudos to your developers here.

As a side note, I happened to come across a bug regarding the formatting of dates. I can’t say if this was caused by the latest update or if it existed before, but currently it seems to be impossible to format dates. I’ll create a new topic for this issue.

Thanks again for the outstanding support, Benjamin!