confirm_box() no longer works

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
KaileyT
Community Team Member
Community Team Member
Posts: 2933
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

confirm_box() no longer works

Post by KaileyT »

So, in my bestanswer extension, I use a confirm box to verify the user wants to mark or unmark an answer (relevant controller code). This worked fine in phpBB 3.2.1, but when I click "Yes" or "No", my URL gets changed to http://www.project-w.local/community/answer/answer/mark_answer?p=2&confirm_key=82ZFNE6AF8 (notice the extra "answer"?). I'm hoping it's not something in my code. Can anyone provide insight as to why this isn't working anymore?

Here's a phpBB 3.2.1 board where it's working - https://dev.project-w.org/viewtopic.php?p=11#p11
Kailey Truscott - Community Team
User avatar
david63
Registered User
Posts: 19060
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: confirm_box() no longer works

Post by david63 »

What do you mean by?
kinerity wrote:
Thu Jan 04, 2018 3:02 am
This worked fine in phpBB 3.2.1
Has it suddenly stopped working or are you using 3.2.1-RC1? If the latter then you should post it in the bug tracker - if the former then what else has changed?
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
User avatar
KaileyT
Community Team Member
Community Team Member
Posts: 2933
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: confirm_box() no longer works

Post by KaileyT »

david63 wrote:
Thu Jan 04, 2018 6:59 am
What do you mean by?
kinerity wrote:
Thu Jan 04, 2018 3:02 am
This worked fine in phpBB 3.2.1
Has it suddenly stopped working
Yes, for whatever reason, my extension works fine in phpBB 3.2.1. As soon as I upgraded to phpBB 3.2.2-RC1, it started adding the second answer string in the URL. I looked through the changed files and don't see any changed to the confirm_box() function itself. I just wanted to make sure it wasn't something I was doing wrong first.
Kailey Truscott - Community Team
User avatar
mrgoldy
Development Team Member
Development Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: confirm_box() no longer works

Post by mrgoldy »

I've had this problem myself a couple of times aswell. I believe it has to do with the URL-rewriting settings.
I found a (bad) work around by checking if that setting is enabled or not.
Mostly I had this problem when I was using AJAX calls to a confirm box.

Could you post the link to the bug tracker, kinerity? Then I can follow any responses there.

P.S. Shouldn't there also be build_hidden_fields in the confirm_box(false) part?
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
User avatar
KaileyT
Community Team Member
Community Team Member
Posts: 2933
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: confirm_box() no longer works

Post by KaileyT »

posey wrote:
Thu Jan 04, 2018 1:07 pm
I've had this problem myself a couple of times aswell. I believe it has to do with the URL-rewriting settings.
I found a (bad) work around by checking if that setting is enabled or not.
I've tried with the URL rewrite setting on and off, no difference (all it does is change the URL to http://www.project-w.local/community/app.php/answer/app.php/answer/mark_answer?p=2&confirm_key=82ZFNE6AF8, basically duplicating app.php).
posey wrote:
Thu Jan 04, 2018 1:07 pm
Mostly I had this problem when I was using AJAX calls to a confirm box.
If I could wrap my head around the exact code to get AJAX to work, I would go with that. All it needs to do is update 2 rows in the database, but I don't understand it.
posey wrote:
Thu Jan 04, 2018 1:07 pm
P.S. Shouldn't there also be build_hidden_fields in the confirm_box(false) part?
No, the only thing required is the check (true/false). See https://wiki.phpbb.com/Function.confirm_box
Kailey Truscott - Community Team
User avatar
KaileyT
Community Team Member
Community Team Member
Posts: 2933
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: confirm_box() no longer works

Post by KaileyT »

Kailey Truscott - Community Team
User avatar
mrgoldy
Development Team Member
Development Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: confirm_box() no longer works

Post by mrgoldy »

Thanks for the tracker link, will keep an eye on it.

And yeah I understand that it works with only the first two parameters supplied, but isn't it best practice to include the hidden fields?
Generally, you will need to supply the first three parameters, while the remaining two are usually fine left default. The second parameter should be a language key used to explain to the user what the confirm box is about. The third parameter, $hidden, should hold html for hidden fields containing all (user-)submitted values needed to get the current script to exactly the state where it is when calling the function.
Anyway this is getting off topic, once again, thanks for the link.
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
User avatar
KaileyT
Community Team Member
Community Team Member
Posts: 2933
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: confirm_box() no longer works

Post by KaileyT »

Posted this in the ticket but it's worth mentioning here.
Was finally able to track down the code that broke this. Line 2188 in /includes/functions.php - it's from this commit.

Code: Select all

$u_action = reapply_sid($phpbb_path_helper->get_valid_page($use_page, $config['enable_mod_rewrite']), $phpbb_path_helper->is_router_used());
Kailey Truscott - Community Team
User avatar
3Di
Former Team Member
Posts: 16166
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Name: Marco
Contact:

Re: confirm_box() no longer works

Post by 3Di »

kinerity wrote:
Fri Jan 05, 2018 5:03 am
Posted this in the ticket but it's worth mentioning here.
... snip ...
Do the same also here pls
https://area51.phpbb.com/phpBB/viewtopi ... 81&t=52806
a blocker like this need to be noticed in time, before to release a version which can potentially break many extensions.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
Post Reply

Return to “Extension Writers Discussion”