• Hi,

    I know you’re recoding this plugin, so I wanted to note a point of failure that is throwing PHP warnings.

    If a user’s timeline contains a tweet that contains an illegal UTF-8 character sequence, such as an emoji, the following PHP error will be thrown:

    extract() expects parameter 1 to be array, string given in /home/XXXXX/public_html/wp-content/plugins/genesis-latest-tweets/lib/xhtml-widget.php on line 123

    This is actually caused by improperly escaping the returned results of the user timeline query when saving the query result as a transient.

    That happens, oddly enough, in the widget code itself, at line 111:

    set_transient( $instance['twitter_id'].'-'.$instance['twitter_num'].'-'.$instance['twitter_duration'], $tweets, $time );

    I believe this can be fixed by running an array_walk over the $tweets array, between lines 106 (where the $tweets array is sliced to remove unwanted tweets) and 111, and sanitizing the content of the tweets by regex-ing out bad characters, such as is described at stackoverflow:

    https://stackoverflow.com/questions/1401317/remove-non-utf8-characters-from-string

    I am too lazy to actually do this, since the quick fix is to simply delete any tweets with emoji or other really odd characters from my timeline.

    That said, I’m sure you plan to re-engineer how and when the plugin fetches tweets, so that it’s not running in the view-nee-widget. So as you do that, I thought this would be a helpful tip.

    https://www.ads-software.com/plugins/genesis-latest-tweets/

  • The topic ‘Fix for extract() warning’ is closed to new replies.