Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix calls to get_error_message() #25

Closed
wants to merge 2 commits into from

2 participants

@jkovis

When trying to install a couple of the recommended plugins I was receiving 503 errors on the ajax request.

The fix is to call $failed_request->get_error_message() instead of get_error_message( $failed_request ) since $failed_request is an instance of WP_Error.

For reference, my debug log had these two entries:

PHP Fatal error: Call to undefined function get_error_message() in /path-to-wp-content/plugins/developer/developer.php on line 347
PHP Fatal error: Call to undefined function get_error_message() in /path-to-wp-content/plugins/developer/developer.php on line 363

@danielbachhuber

There were a couple more places with this copy-pasta error so I've fixed in c4e01c3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 23, 2012
  1. @jkovis
  2. @jkovis
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 5 deletions.
  1. +5 −5 developer.php
View
10 developer.php
@@ -339,7 +339,7 @@ public function ajax_handler( $action ) {
$api = plugins_api( 'plugin_information', array( 'slug' => $_POST['plugin_slug'], 'fields' => array( 'sections' => false ) ) );
if ( is_wp_error( $api ) )
- die( sprintf( __( 'ERROR: Error fetching plugin information: %s', 'a8c-developer' ), get_error_message( $api ) ) );
+ die( sprintf( __( 'ERROR: Error fetching plugin information: %s', 'a8c-developer' ), $api->get_error_message() ) );
$upgrader = new Plugin_Upgrader( new Automattic_Developer_Empty_Upgrader_Skin( array(
'nonce' => 'install-plugin_' . $_POST['plugin_slug'],
@@ -350,12 +350,12 @@ public function ajax_handler( $action ) {
$install_result = $upgrader->install( $api->download_link );
if ( ! $install_result || is_wp_error( $install_result ) )
- die( sprintf( __( 'ERROR: Failed to install plugin: %s', 'a8c-developer' ), get_error_message( $api ) ) );
+ die( sprintf( __( 'ERROR: Failed to install plugin: %s', 'a8c-developer' ), $install_result->get_error_message() ) );
$activate_result = activate_plugin( $this->get_path_for_recommended_plugin( $_POST['plugin_slug'] ) );
if ( is_wp_error( $activate_result ) )
- die( sprintf( __( 'ERROR: Failed to activate plugin: %s', 'a8c-developer' ), get_error_message( $api ) ) );
+ die( sprintf( __( 'ERROR: Failed to activate plugin: %s', 'a8c-developer' ), $activate_result->get_error_message() ) );
exit( '1' );
@@ -371,7 +371,7 @@ public function ajax_handler( $action ) {
$activate_result = activate_plugin( $_POST['path'] );
if ( is_wp_error( $activate_result ) )
- die( sprintf( __( 'ERROR: Failed to activate plugin: %s', 'a8c-developer' ), get_error_message( $api ) ) );
+ die( sprintf( __( 'ERROR: Failed to activate plugin: %s', 'a8c-developer' ), $activate_result->get_error_message() ) );
exit( '1' );
}
@@ -624,4 +624,4 @@ private function get_project_types() {
}
}
-$automattic_developer = new Automattic_Developer();
+$automattic_developer = new Automattic_Developer();
Something went wrong with that request. Please try again.