WordPress.org

Making WordPress.org

Changeset 7500


Ignore:
Timestamp:
07/25/2018 06:39:38 PM (14 months ago)
Author:
coreymckrill
Message:

WordCamp applications: Adjustments to the rate limiter

The rate limiter was ignoring posts in the trash when determining if too many
had been sent during the hour time window. This fixes it by using
get_post_stati instead of specifying any, which ignores the trash.

This also prevents the submission form from rendering at all if the rate limit
has been triggered.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/applications/wordcamp.php

    r6651 r7500  
    4646    ob_start();
    4747
    48     if ( isset( $_POST['submit-application'] ) ) {
     48    if ( is_rate_limited() ) {
     49        $message        = 'You have submitted too many applications recently. Please wait and try again in a few hours.';
     50        $notice_classes = 'notice-error';
     51
     52        require( dirname( __DIR__ ) . '/views/applications/common/submission-results.php' );
     53    } elseif ( isset( $_POST['submit-application'] ) ) {
    4954        $application_data = validate_data( $_POST );
    5055
    51         if ( is_rate_limited() ) {
    52             $message        = 'You have submitted too many applications recently. Please wait and try again in a few hours.';
    53             $notice_classes = 'notice-error';
    54         } else if ( is_wp_error( $application_data ) ) {
     56        if ( is_wp_error( $application_data ) ) {
    5557            $message = $application_data->get_error_message();
    5658            $notice_classes = 'notice-error';
     
    8587    $previous_entries = get_posts( array(
    8688        'post_type'      => WCPT_POST_TYPE_ID,
    87         'post_status'    => 'any',
     89        'post_status'    => get_post_stati(), // This will include trashed posts, unlike 'any'.
    8890        'posts_per_page' => $limit,
    8991        'orderby'        => 'date',
Note: See TracChangeset for help on using the changeset viewer.