MyBB Community Forums

Full Version: ThankYou Plugin causing preg_replace failure (error log)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Plugin
https://community.mybb.com/mods.php?action=view&pid=67

Problem
After successful install/activation, when visiting showthread all thread "content" is missing while everything else is visible - postbit, quickreply, etc.

Test
Manually deactivating ThankYou plugin in "Plugins" configuration page fixes this problem.

- Thread content reappears.

Error Log
<error>
<dateline>1668901259</dateline>
<script>inc/plugins/thx.php</script>
<line>1310</line>
<type>2</type>
<friendly_type>Warning</friendly_type>
<message>preg_replace(): Compilation failed: range out of order in character class at offset 9</message>
<back_trace>#0  errorHandler->error() called at [/inc/class_error.php:153]
#1  errorHandler->error_callback() called at [[PHP]: ]
#2  preg_replace() called at [/inc/plugins/thx.php:1310]
#3  thx_code() called at [/inc/class_plugins.php:142]
#4  pluginSystem->run_hooks() called at [/inc/class_parser.php:244]
#5  postParser->parse_message() called at [/inc/functions_post.php:817]
#6  build_postbit() called at [/showthread.php:1118]
</back_trace>
</error>

Any idea on how to remedy this?
Did you have changed any setting in your plugin ?

I have a more recent version where i was fixed some issues for an user, but i am not sure if this version works for you, if you want to test it let me know or if you can sent me more detailed information about how to reproduce the issue, because i have it already installed but all works fine without issues.

I am running php 7.4 and mybb 1.8.31 by the way.
Issue was a human error. Settings field for hide tag I had enter "[thankyou]" while the correct format is "thankyou" - without brackets. If I enter with brackets then it throws an error.

[attachment=45585]

Clearly it says in the settings description to use text only. Sorry for the worry there!

(2022-11-20, 04:33 AM)Whiteneo Wrote: [ -> ]Did you have changed any setting in your plugin ?
I have a more recent version where i was fixed some issues for an user, but i am not sure if this version works for you, if you want to test it let me know or if you can sent me more detailed information about how to reproduce the issue, because i have it already installed but all works fine without issues.
I am running php 7.4 and mybb 1.8.31 by the way.

Thank you for your swift reply Whiteneo. Your time is much appreciated.



If I may bring to your attention a problem that's driving me nuts.

It seems either the ThankYou plugin is not compatible with MyBB global custom templates or the XThreads by Zinga.

Problem
Hidetag works fine in posts on showthread by pulling "postbit"/"postbit_classic" templates

However

If global custom template is created using MyBB "postbit_firstpost" / "postbit_firstpost_classic" template or templates "postbit_first" / "postbit_first_classic" using XThreads by Zinga then Thx script fails to run on the custom templates despite both templates sharing the same exact template codes but fails to work on Firstpost while it works on all other posts:

Postbit_classic
{$ignore_bit}
<a name="pid{$post['pid']}" id="pid{$post['pid']}"></a>
<div class="post first {$unapproved_shade}" style="{$post_visibility}" id="post_{$post['pid']}">
<div class="post_flexible">
<div class="post_content">
<div class="post_body scaleimages" id="pid_{$post['pid']}">
{$post['thx_counter']}<div id="thxpid_{$post['pid']}">{$post['message']}</div>{$post['thx_list']}
</div>

</div>
</div>
<div style="float:right;padding:2% 2%;">{$post['thanks']} <br><br> {$post['button_report']}</div>


<div class="postbit_buttons post_management_buttons float_right">
{$post['button_edit']}{$post['button_quickdelete']}{$post['button_quickrestore']}{$post['button_warn']}{$post['button_purgespammer']}
</div>

</div>


</div>

Postbit_first_classic
{$ignore_bit}
<a name="pid{$post['pid']}" id="pid{$post['pid']}"></a>
<div class="post first {$unapproved_shade}" style="{$post_visibility}" id="post_{$post['pid']}">
<div class="post_flexible">
<div class="post_content">
<div class="post_body scaleimages" id="pid_{$post['pid']}">
{$post['thx_counter']}<div id="thxpid_{$post['pid']}">{$post['message']}</div>{$post['thx_list']}
</div>

</div>
</div>
<div style="float:right;padding:2% 2%;">{$post['thanks']} <br><br> {$post['button_report']}</div>


<div class="postbit_buttons post_management_buttons float_right">
{$post['button_edit']}{$post['button_quickdelete']}{$post['button_quickrestore']}{$post['button_warn']}{$post['button_purgespammer']}
</div>

</div>


</div>


Supporting

[attachment=45582]
[attachment=45583]
[attachment=45584]

In image above, both the "Firstpost" and Third Post are using the same [hideuntilthanks] mycode though the announcement in visible in postbit but not firstpost.

Conclusion
Conclusion I can draw from all my tests is that the Thankyou Plugin fails to run its Thx_Script on custome global threads (regardless created by mybb or third party plugins). I think all I need to do is add a hook (for postbit firstpost??) and call for the templates in the plugins script.

I did consult:
https://community.mybb.com/thread-171937.html

Could you guide me with your expertise on what would be the right way for the plugin call for the custom Postbit templates to run thx script?

I hope I am not missing something absolute obvious like last time. I am thankful for your time sir.
I am not really sure due it is into globals, but if i can remember it good it takes to show only into showthread template and it is loaded in there as a var that was loaded for that hook.

If that new plugin uses another hook, yeah it must have been added into the other hook to load the script file, but i have not used that type of plugins before, but i had helped to some users that already use it or uses it in the past.

On the end if you can provide me more details or information for i can debug it and let you know for a propertly fix Smile
(2022-11-26, 10:02 PM)Whiteneo Wrote: [ -> ]I am not really sure due it is into globals, but if i can remember it good it takes to show only into showthread template and it is loaded in there as a var that was loaded for that hook.

If that new plugin uses another hook, yeah it must have been added into the other hook to load the script file, but i have not used that type of plugins before, but i had helped to some users that already use it or uses it in the past.

On the end if you can provide me more details or information for i can debug it and let you know for a propertly fix Smile

Thank you kind sir.

Steps

Plugins
- https://community.mybb.com/mods.php?action=view&pid=67
- http://mybbhacks.zingaburga.com/showthread.php?tid=288
-- https://community.mybb.com/mods.php?action=view&pid=573

1. Activate all plugins

2. Forums & Posts - > (Forum Name) -> Edit Forum Settings -> Scroll to XThreads -> Select YES to Show first post on every showthread page
[attachment=45586]

3. Templates & Styles -> Templates -> Global Templates -> Add Template -> Template Name : Postbit_first

Insert the copy paste code from your default theme's "Postbit" template. Be sure it includes the Thanks Script code.


Now your postbit on showthread has 2 designs. Firstpost uses "postbit_first" from Globals while all other posts use your theme's default "postbit" as according to Xthreads settings.

Reproduction

1. Create thread with hide tags in first post and second post.

2. First post fails to load hide tag announcement

(Postbit_first in Globals)
<div id="thxpid_{$post['pid']}">{$post['message']}</div>

[attachment=45587]

while successfully still printing out

(Postbit_first in Globals)
{$post['thx_counter']}{$post['thx_list']}

3. Second post successfully outputs as it loads "Postbit" template from plugin

(Postbit template in default theme)
<div id="thxpid_{$post['pid']}">{$post['message']}</div> 

[attachment=45588]

Summary

Hide tag announcement seems to be executed from plugin but if it is unable to detect firstpost template then it will display working functions, but it is unable to run the Thanks Script on the template to check for user permissions for their appropiate warning announcement.

Xthreads adds custom hooks of its own:

require_once MYBB_ROOT.'inc/xthreads/xt_sthreadhooks.php';

xthreads_showthread_firstpost(); 
Line 290, /inc/plugins/xthreads.php
Ok i had added first and second post from two different users. And enter with another one, this after i had installed all plugins.

So now i see all works fine in both posts, however i only add two posts into my thread.

Do i miss something ?

Maybe i have to add more posts or ?