Skip to content

Instantly share code, notes, and snippets.

@luk3thomas
Created December 13, 2012 19:59
Show Gist options
  • Save luk3thomas/4279286 to your computer and use it in GitHub Desktop.
Save luk3thomas/4279286 to your computer and use it in GitHub Desktop.
A client cannot search for plugins or install plugins from the WordPress dashboard

Problem

A client cannot search for plugins or install plugins from the WordPress dashboard and Akismet will not connect to the servers. The client is on a VPS. After investigation, the error was caused becuase the server is timing out on the requtest.

In this file: /wp-admin/includes/plugin-install.php line 44

$request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'timeout' => 15, 'body' => array('action' => $action, 'request' => serialize($args))) 

In this file: /wp-content/plugins/akismet/akismet.php line 168 ( or thereabouts )

$http_args = array(
        'body'                  => $request,
        'headers'               => array(
                'Content-Type'  => 'application/x-www-form-urlencoded; ' .
                                                        'charset=' . get_option( 'blog_charset' ),
                'Host'                  => $host,
                'User-Agent'    => $akismet_ua
        ),
        'httpversion'   => '1.0',
        'timeout'               => 15
);

Solution

Increase the timeout to something larger, say 60.

/wp-admin/includes/plugin-install.php

$request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'timeout' => 60, 'body' => array('action' => $action, 'request' => serialize($args))) 

/wp-content/plugins/akismet/akismet.php

$http_args = array(
        'body'                  => $request,
        'headers'               => array(
                'Content-Type'  => 'application/x-www-form-urlencoded; ' .
                                                        'charset=' . get_option( 'blog_charset' ),
                'Host'                  => $host,
                'User-Agent'    => $akismet_ua
        ),
        'httpversion'   => '1.0',
        'timeout'               => 60
);

That fixes the initial issues the client was having, but other references to the wp_remote_post function need to be investigated since they may be timing out as well.

Other Considerations

A search of the WordPress isntallation shows the following files reference the wp_remote_post function:

./wp-content/plugins/wordpress-seo/admin/class-tracking.php
./wp-content/plugins/akismet/akismet.php
./wp-content/plugins/google-analytics-for-wordpress/class-tracking.php
./wp-content/plugins/google-analytics-for-wordpress/wp-gdata/wp-gdata.php
./wp-includes/class-wp-http-ixr-client.php
./wp-includes/comment.php
./wp-includes/cron.php
./wp-includes/http.php
./wp-includes/update.php
./wp-admin/includes/plugin-install.php
./wp-admin/includes/theme.php
./wp-admin/includes/update-core.php
./wp-admin/includes/dashboard.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment