Make WordPress Core

Ticket #3254: prevent_plugin_fatal_errors.001.diff

File prevent_plugin_fatal_errors.001.diff, 1.9 KB (added by markjaquith, 17 years ago)
  • wp-admin/plugins.php

     
    1111                if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
    1212                        wp_die(__('Plugin file does not exist.'));
    1313                if (!in_array($plugin, $current)) {
     14                        wp_redirect('plugins.php?error=true'); // we'll override this later if the plugin can be included without fatal error
     15                        @include(ABSPATH . PLUGINDIR . '/' . $plugin);
    1416                        $current[] = $plugin;
    1517                        sort($current);
    1618                        update_option('active_plugins', $current);
    17                         include(ABSPATH . PLUGINDIR . '/' . $plugin);
    1819                        do_action('activate_' . $plugin);
    1920                }
    20                 wp_redirect('plugins.php?activate=true');
     21                wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above
    2122        } else if ('deactivate' == $_GET['action']) {
    2223                check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
    2324                $current = get_option('active_plugins');
     
    5859}
    5960?>
    6061
    61 <?php if (isset($_GET['activate'])) : ?>
    62 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p>
    63 </div>
     62<?php if ( isset($_GET['error']) ) : ?>
     63        <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p></div>
     64<?php elseif ( isset($_GET['activate']) ) : ?>
     65        <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
     66<?php elseif ( isset($_GET['deactivate']) ) : ?>
     67        <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
    6468<?php endif; ?>
    65 <?php if (isset($_GET['deactivate'])) : ?>
    66 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p>
    67 </div>
    68 <?php endif; ?>
    6969
    7070<div class="wrap">
    7171<h2><?php _e('Plugin Management'); ?></h2>