From 8ecc21e2dae261599a5b1b13ff6d9e94a21dea19 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 9 Feb 2009 19:19:38 +0000 Subject: [PATCH] Add hook "after_db_upgrade" and flush rewrite rules on the next page load after successful upgrade git-svn-id: https://develop.svn.wordpress.org/trunk@10530 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/admin.php | 12 +++++++++++- wp-admin/includes/upgrade.php | 4 +--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/wp-admin/admin.php b/wp-admin/admin.php index fc6f70780d..c88a1d4b7b 100644 --- a/wp-admin/admin.php +++ b/wp-admin/admin.php @@ -18,7 +18,17 @@ if ( defined('ABSPATH') ) else require_once('../wp-load.php'); -if ( get_option('db_version') != $wp_db_version ) { +if ( get_option('db_version') == 'db_upgraded' ) { + $wp_rewrite->flush_rules(); + update_option('db_version', $wp_db_version); + + /** + * Runs on the next page load after successful upgrade + * + * @since 2.8 + */ + do_action('after_db_upgrade'); +} elseif ( get_option('db_version') != $wp_db_version ) { wp_redirect(admin_url('upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI'])))); exit; } diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index f41422b576..922ac59642 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -278,9 +278,7 @@ function upgrade_all() { maybe_disable_automattic_widgets(); - $wp_rewrite->flush_rules(); - - update_option('db_version', $wp_db_version); + update_option('db_version', 'db_upgraded'); } /**