Making WordPress.org

Changeset 1106


Ignore:
Timestamp:
01/08/2015 06:53:48 PM (10 years ago)
Author:
iandunn
Message:

Central Theme: Make sure that the Twitter API response is an array.

If the request fails because of authentication then json_decode() will return null. That previously passed the success checks on the server and client sides, and resulted in empty output with no indication to the user that something went wrong.

Location:
sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/functions.php

    r1105 r1106  
    469469                 * so we have to request more tweets than we actually want and then cut it down here.
    470470                 */
    471                 if ( $tweets['tweets'] ) {
     471                if ( is_array( $tweets['tweets'] ) ) {
    472472                    $tweets['tweets']      = array_slice( $tweets['tweets'], 0, 3 );
    473473                    $tweets['tweets']      = self::sanitize_format_tweets( $tweets['tweets'] );
  • sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/js/central.js

    r1105 r1106  
    7777
    7878                // Check for success
    79                 if ( response.hasOwnProperty( 'data' ) && response.data.hasOwnProperty( 'tweets' ) ) {
     79                if ( response.hasOwnProperty( 'data' ) && response.data.hasOwnProperty( 'tweets' ) && response.data.tweets === Array ) {
    8080                    tweets = response.data.tweets;
    8181                } else {
Note: See TracChangeset for help on using the changeset viewer.