Opened 13 years ago
Closed 13 years ago
#2230 closed defect (bug) (fixed)
Sticky are not saved when topic is first submited
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 2.3 | Priority: | normal |
| Severity: | normal | Version: | trunk |
| Component: | Component - Topics | Keywords: | has-patch |
| Cc: |
Description
When on the form to first create a topic, a dropdown list allow us to select the type of topic (normal, sticky, super sticky). Choosing Normal or super sticky is correctly saved. But when the topic author choose "Sticky", the topic type is not saved.
When bbp_new_topic_handler() is called, and just after inserting the topic, bbp_stick_topic() is used to check if the topic type is sticky or super sticky.
In /includes/topics/functions.php at line 2909, this function tries to get the forum id thanks to the function bbp_get_topic_forum_id and defaults to 0 if no forum id was found.
As at this time, the post meta '_bbp_forum_id' is not set for the topic id, bbp_get_topic_forum_id returns 0.
As a result, the topic is not sticky.
Once the topic is created, if you click in the admin links on the Sticky link, it add the sticky type to the topic.
If you edit the topic, and use the selectbox to activate the option 'Sticky', it's also adding the type sticky to the topic.
So the issue only concerns the submission of a new topic.
The patch simply uses bbp_update_topic_forum_id() once the topic is inserted so that bbp_get_topic_forum_id() returns the forum id instead of 0 and then stick the topic.
(In [4782]) Move new topic sticky-check after 'bbp_new_topic' action, to ensure forum ID meta is saved via bbp_update_topic(). Also move sticky-check in edit-topic handler, so correct forum ID is used when moving a sticky topic. Props imath. Fixes #2230.