Support » Plugin: WP twitter feeds » Fatal error when including more than one widget on a page

  • We were running plugin version 1.4.7 successfully on a site until recently when we upgraded to 1.4.9

    We have two Twitter widgets in our sidebar and found that occasionally the page would crash on loading with a Fatal Error.

    The full error was:

    PHP Fatal error: Cannot redeclare class viwptf_TwitterOAuth in /xxx/wp-content/plugins/wp-twitter-feeds/controller/twitteroauth/twitteroauth.php on line 11

    Tracing this through, the OAuth file is being called from line 223 of controller/twitter_widget_class.php

    In 1.4.7 the OAuth file was included with require_once(), in 1.4.9 it’s included with include()

    Because the OAuth file declares a class, it must not be included more than once – that’s what’s causing the fatal error.

    The reason that the error only occurs occasionally is that the plugin is caching its data from Twitter in a transient. It only talks to Twitter (and hence only has a need of the OAuth class) if its transient has expired. So the first time you load the page you’ll see the fatal error. Refreshing the page will then display correctly. Waiting until the transient has expired (default 4 minutes) and then hitting refresh will cause the plugin to have to talk to Twitter again and so the error will reappear.

    The fix is very easy. In wp-twitter-feeds/controller/twitter_widget_class.php on line 223, change ‘include’ back to ‘require_once’

    The twitteroauth.php file is also loaded from a call in views/slider.php but that call is a require_once() in both 1.4.7 and 1.4.9 – so that’s still safe.

    If you’ve been having problems with this plugin then hopefully that helps you out.

    If you’re the plugin author, could you add this change into the next release please? Thanks!

  • The topic ‘Fatal error when including more than one widget on a page’ is closed to new replies.