Making WordPress.org

Changeset 8638


Ignore:
Timestamp:
04/15/2019 06:28:20 AM (6 years ago)
Author:
dd32
Message:

Support Forums: More term fixing where a non-ascii term could cause an OOM or fatal upon accessing a WP_Error like an array.

See #4342.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php

    r8634 r8638  
    293293            // not yet exist as a compat term.
    294294            if ( ! $this->term && $this->get_object( $this->slug() ) ) {
    295                 $term = wp_insert_term( $this->slug(), $this->taxonomy() );
     295                $term_name = $this->slug();
     296                if ( ! sanitize_title( $term_name ) ) {
     297                    // This happens when the slug is all non-ascii such as %e5%8f%8b%e8%a8%80, which fails to insert.
     298                    $term_name = urldecode( $term_name );
     299                }
     300                $term = wp_insert_term( $term_name, $this->taxonomy(), array( 'slug' => $this->slug() ) );
    296301
    297302                // Term exists already? Race-condition, or get_term_by() couldn't find $slug..
    298303                if ( is_wp_error( $term ) && $term->get_error_data( 'term_exists' ) ) {
    299304                    $this->term = get_term( $term->get_error_data( 'term_exists' ) );
    300                 } elseif ( isset( $term['term_id'] ) ) {
     305                } elseif ( ! is_wp_error( $term ) && isset( $term['term_id'] ) ) {
    301306                    $this->term = get_term( $term['term_id'] );
    302307                }
Note: See TracChangeset for help on using the changeset viewer.