MyBB Community Forums

Full Version: Strange behaviour of "find_replace_templatesets"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
With MyBB 1.8, I've noticed some strange behaviour of the find_replace_templatesets function. Using the following code:

    find_replace_templatesets('headerinclude', '/$/', '{$myalerts_js}');

Causes all global templates to be updated. This is due to the following query being ran by the function:

SELECT tid, sid, template FROM mybb_templates WHERE title = 'headerinclude' AND sid>0 OR sid=-1;

This query results in the following (where I have one global template, with the content "this is a test global template...":

[Image: HFTH3k3.png]
The expected result would be for only the "header include" template to be returned, not all global templates.

I believe the actual query that should be ran is as follows:

SELECT tid, sid, template FROM mybb_templates WHERE title = 'headerinclude' AND (sid>0 OR sid=-1);

This query returns only the "headerinclude" template.

This code was changed in this July 2014 commit, so I'm surprised it's taken this long to cause problems...
You're right. And my recent bugfix failed because of the lack of parentheses.

Hi,

Thank you for your report. We have pushed this issue to our Github repository for further analysis where you can track our commits and progress with fixing this bug. Discussions regarding this bug may also take place there too.

Follow this link to visit the issue on Github: https://github.com/mybb/mybb/issues/2016

Thanks for contributing to MyBB!

Regards,
The MyBB Group
Any quick fix for it? It causes some annoying glitches with many plugins.
(2015-06-04, 05:16 PM)TBO29 Wrote: [ -> ]Any quick fix for it? It causes some annoying glitches with many plugins.

This should fix it, but I haven't tested it yet: https://github.com/mybb/mybb/pull/2021
Great @Euan, that did it. Saved me a lot of headaches. I tested the failing plugins on 1805 and they work as they should.