Issue with BBCode and saving text

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
kinerity
Registered User
Posts: 1151
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Issue with BBCode and saving text

Post by kinerity » Sat Aug 12, 2017 2:15 pm

I just pushed this commit to my Knowledge Base extension. Everything works as intended except when viewing an article (BBCode/Smilies/URLs are not parsed). I can't fingure out why. If I look in the database, it's not inserting "1" for any of the options (see Figure 1). If I manually change these to "1" I still get nothing. The only thing I noticed different is how the text is stored (see Figure 2). The first line is parsed correctly, the second line is not (both articles have the same text - [i][reserved][/i]).

Figure 1
database_fields.png
database_fields.png (6.19 KiB) Viewed 309 times
Figure 2
text_field.png
text_field.png (5.16 KiB) Viewed 309 times

Can someone explain which part of my commit jacked this all up?
phpBB3 Refugees - Unofficial phpBB 3.0.x support

Image

rxu
Extensions Development Team
Posts: 2770
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Issue with BBCode and saving text

Post by rxu » Sat Aug 12, 2017 2:29 pm

kinerity wrote:
Sat Aug 12, 2017 2:15 pm
which part of my commit jacked this all up?
I guess you got this logic reversed:

Code: Select all

$article_bbcode		= (!$bbcode_status || isset($disable_bbcode)) ? false : true;
$article_smilies	= (!$smilies_status || isset($disable_smilies)) ? false : true;
$article_urls		= (isset($disable_magic_url)) ? 0 : 1;

rxu
Extensions Development Team
Posts: 2770
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Issue with BBCode and saving text

Post by rxu » Sat Aug 12, 2017 2:32 pm

In paticular, you do

Code: Select all

$disable_bbcode = $this->request->is_set_post('disable_bbcode');
and then

Code: Select all

$article_bbcode		= (!$bbcode_status || isset($disable_bbcode)) ? false : true;
but $disable_bbcode is always set as is_set_post() returns bool in any case.

User avatar
kinerity
Registered User
Posts: 1151
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Re: Issue with BBCode and saving text

Post by kinerity » Sat Aug 12, 2017 2:41 pm

Ouch, I think I just had a "duh" moment. So change it to something like

Code: Select all

$article_bbcode		= (!$bbcode_status || $disable_bbcode) ? false : true;
or "cleaner"

Code: Select all

$article_bbcode		= (!$bbcode_status || $this->request->is_set_post('disable_bbcode')) ? false : true;
:?:

Edit: Yup, that seems to do it! Thanks for the whack.
Last edited by kinerity on Sat Aug 12, 2017 2:44 pm, edited 1 time in total.
phpBB3 Refugees - Unofficial phpBB 3.0.x support

Image

rxu
Extensions Development Team
Posts: 2770
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Issue with BBCode and saving text

Post by rxu » Sat Aug 12, 2017 2:43 pm

You can do just

Code: Select all

$article_bbcode		= !$bbcode_status || $disable_bbcode;
or (if eliminate $disable_bbcode above)

Code: Select all

$article_bbcode		= !$bbcode_status || $this->request->is_set_post('disable_bbcode');

rxu
Extensions Development Team
Posts: 2770
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Issue with BBCode and saving text

Post by rxu » Sat Aug 12, 2017 2:50 pm

I meant that negated, but you got it, do you? ;)

User avatar
kinerity
Registered User
Posts: 1151
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Re: Issue with BBCode and saving text

Post by kinerity » Sat Aug 12, 2017 2:51 pm

Yeah, I got it. :)
phpBB3 Refugees - Unofficial phpBB 3.0.x support

Image

User avatar
kinerity
Registered User
Posts: 1151
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Re: Issue with BBCode and saving text

Post by kinerity » Sat Aug 12, 2017 5:51 pm

One last issue - if I (for example) disable BBCode and then edit the post again, the "disable BBCode" box is not checked (it should be). I though lines 812 - 817 would handle this, but it doesn't appear to. Thoughts?
phpBB3 Refugees - Unofficial phpBB 3.0.x support

Image

rxu
Extensions Development Team
Posts: 2770
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Issue with BBCode and saving text

Post by rxu » Sat Aug 12, 2017 6:06 pm

I think it's similar issue. Here https://github.com/kinerity/knowledgeba ... #L790-L792 you have isset() always true as $article_* vars are always set.

User avatar
kinerity
Registered User
Posts: 1151
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Re: Issue with BBCode and saving text

Post by kinerity » Sat Aug 12, 2017 7:03 pm

Figured this one out - I added the code below to my edit case.

Code: Select all

$article_bbcode = $row['enable_bbcode'];
$article_smilies = $row['enable_smilies'];
$article_urls = $row['enable_magic_url'];
Another problem I've noticed and can't figure out - my "disable smilies" and "disable urls" are switched. If I disable smilies, smilies are parsed but urls are not and vice versa. :? I promise this is the last one. :lol:
phpBB3 Refugees - Unofficial phpBB 3.0.x support

Image

rxu
Extensions Development Team
Posts: 2770
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Issue with BBCode and saving text

Post by rxu » Sun Aug 13, 2017 3:42 am

That is because you have messed up the generate_text_for_storage() arguments order here https://github.com/kinerity/knowledgeba ... r.php#L672. You have put smilies flag instead of urls one and vice versa.

User avatar
kinerity
Registered User
Posts: 1151
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Re: Issue with BBCode and saving text

Post by kinerity » Sun Aug 13, 2017 10:59 am

:oops: Thanks again! Everything appears to be working now.
phpBB3 Refugees - Unofficial phpBB 3.0.x support

Image

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 6 guests