Skip to:
Content

bbPress.org


Ignore:
Timestamp:
02/23/2017 11:24:29 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Common: Introduce bbp_number_not_negative() and use it in the following ways:

  • Register the relevant meta-data keys for posts & users, so updated values can never be invalid
  • Filter return values for existing database values that might be invalid on existing installs
  • Use in place of intval() or (int) casts where negative values should not exist

This has the added benefit of introducing the bbp_register_meta hook, for future meta-data registrations (of which bbPress has much of.) We'll concentrate on counts for 2.6, and integrate IDs and timestamps in future releases.

See #3059.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/filters.php

    r6301 r6302  
    207207add_filter( 'bbp_get_topic_reply_count_hidden', 'bbp_number_format', 10 );
    208208
    209 // Add intval filter to functions expecting absolute values
    210 add_filter( 'bbp_get_user_topic_count_int',         'intval', 10 );
    211 add_filter( 'bbp_get_user_reply_count_int',         'intval', 10 );
    212 add_filter( 'bbp_get_user_post_count_int',          'intval', 10 );
    213 add_filter( 'bbp_get_forum_subforum_count_int',     'intval', 10 );
    214 add_filter( 'bbp_get_forum_topic_count_int',        'intval', 10 );
    215 add_filter( 'bbp_get_forum_reply_count_int',        'intval', 10 );
    216 add_filter( 'bbp_get_forum_post_count_int',         'intval', 10 );
    217 add_filter( 'bbp_get_topic_voice_count_int',        'intval', 10 );
    218 add_filter( 'bbp_get_topic_reply_count_int',        'intval', 10 );
    219 add_filter( 'bbp_get_topic_post_count_int',         'intval', 10 );
    220 add_filter( 'bbp_get_forum_topic_count_hidden_int', 'intval', 10 );
    221 add_filter( 'bbp_get_topic_reply_count_hidden_int', 'intval', 10 );
    222 add_filter( 'bbp_get_topic_revision_count_int',     'intval', 10 );
    223 add_filter( 'bbp_get_reply_revision_count_int',     'intval', 10 );
     209// Add number-not-negative filter to values that can never be negative numbers
     210add_filter( 'bbp_get_user_topic_count_int',         'bbp_number_not_negative', 10 );
     211add_filter( 'bbp_get_user_reply_count_int',         'bbp_number_not_negative', 10 );
     212add_filter( 'bbp_get_user_post_count_int',          'bbp_number_not_negative', 10 );
     213add_filter( 'bbp_get_forum_subforum_count_int',     'bbp_number_not_negative', 10 );
     214add_filter( 'bbp_get_forum_topic_count_int',        'bbp_number_not_negative', 10 );
     215add_filter( 'bbp_get_forum_reply_count_int',        'bbp_number_not_negative', 10 );
     216add_filter( 'bbp_get_forum_post_count_int',         'bbp_number_not_negative', 10 );
     217add_filter( 'bbp_get_topic_voice_count_int',        'bbp_number_not_negative', 10 );
     218add_filter( 'bbp_get_topic_reply_count_int',        'bbp_number_not_negative', 10 );
     219add_filter( 'bbp_get_topic_post_count_int',         'bbp_number_not_negative', 10 );
     220add_filter( 'bbp_get_forum_topic_count_hidden_int', 'bbp_number_not_negative', 10 );
     221add_filter( 'bbp_get_topic_reply_count_hidden_int', 'bbp_number_not_negative', 10 );
     222add_filter( 'bbp_get_topic_revision_count_int',     'bbp_number_not_negative', 10 );
     223add_filter( 'bbp_get_reply_revision_count_int',     'bbp_number_not_negative', 10 );
    224224
    225225// Sanitize displayed user data
Note: See TracChangeset for help on using the changeset viewer.