Skip to:
Content

bbPress.org

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#2954 closed enhancement (fixed)

function bbp_get_topic_statuses misuse in topics/template.php or bad function declaration in topics/functions.php

Reported by: jyd44's profile jyd44 Owned by: johnjamesjacoby's profile johnjamesjacoby
Milestone: 2.6 Priority: normal
Severity: normal Version: 2.0
Component: Component - Any/All Keywords:
Cc:

Description (last modified by netweb)

In the file topics/template.php, the function bbp_get_topic_statuses is called with one parameter (the id of the topic:)

<?php
foreach ( bbp_get_topic_statuses( $r['topic_id'] ) as $key => $label ) :

.
Unfortunately, the declaration and the definition of this function in the file topics/functions.php does not mention this parameter.

<?php
function bbp_get_topic_statuses() {
        return apply_filters( 'bbp_get_topic_statuses', array(
                bbp_get_public_status_id()  => _x( 'Open',    'Open the topic',        'bbpress' ),
                bbp_get_closed_status_id()  => _x( 'Closed',  'Close the topic',       'bbpress' ),
                bbp_get_spam_status_id()    => _x( 'Spam',    'Spam the topic',        'bbpress' ),
                bbp_get_trash_status_id()   => _x( 'Trash',   'Trash the topic',       'bbpress' ),
                bbp_get_pending_status_id() => _x( 'Pending', 'Mark topic as pending', 'bbpress' ),
        ) );
}

Adding the topic_id as a parameter to the function and to the call to apply_filters would give the opportunity to filter the available topic statuses when creating a topic (I do not see any good reason to set the status to trash or spam when creating a ticket).

Change History (4)

#1 @netweb
9 years ago

  • Description modified (diff)

#2 @johnjamesjacoby
9 years ago

  • Owner set to johnjamesjacoby
  • Resolution set to fixed
  • Status changed from new to closed

In 6026:

Statuses, Types, Visibilities: Pass the forum, topic, or reply ID into helper functions.

These ID's pass additional context into respective filters, useful for fine-grained control over UI elements.

This commit normalizes the way these functions work across all of bbPress where applicable, by ensuring all similar functions accept an ID and assume 0 by default. Note that there are currently 2 locations where no ID exists to pass context into, which is by design.

Fixes #2954.

#3 @johnjamesjacoby
9 years ago

  • Component changed from General to Component - Any/All
  • Milestone changed from Awaiting Review to 2.6
  • Version set to 2.0

#4 @johnjamesjacoby
9 years ago

In 6027:

Statuses, Types, Visibilities: bbp_get_topic_types() usages were missed in r6026.

See #2954.

Note: See TracTickets for help on using tickets.