Permalink
Browse files

Don't install each time if DB structure didn't change

  • Loading branch information...
1 parent f012952 commit d3de3aeee26196a268abb0e3a278b6b51bc5e946 @nb committed Aug 5, 2011
Showing with 17 additions and 2 deletions.
  1. +17 −2 bin/install.php
View
@@ -20,6 +20,20 @@
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
require_once ABSPATH . '/wp-includes/wp-db.php';
+define( 'WP_TESTS_DB_VERSION_FILE', ABSPATH . '.wp-tests-db-version' );
+
+$wpdb->suppress_errors();
+$wpdb->hide_errors();
+$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
+
+if ( $installed && file_exists( WP_TESTS_DB_VERSION_FILE ) ) {
+ $install_db_version = file_get_contents( WP_TESTS_DB_VERSION_FILE );
+ $db_version = get_option( 'db_version' );
+ if ( $db_version == $install_db_version ) {
+ return;
+ }
+}
+
$wpdb->query( 'DROP DATABASE IF EXISTS '.DB_NAME.";" );
$wpdb->query( 'CREATE DATABASE '.DB_NAME.";" );
$wpdb->select( DB_NAME, $wpdb->dbh );
@@ -30,5 +44,6 @@
}
return $queries;
});
-
-wp_install( "Baba's blog", 'admin', 'admin@baba.net', true, '', 'a' );
+echo "Installing…\n";
+wp_install( "Baba's blog", 'admin', 'admin@baba.net', true, '', 'a' );
+file_put_contents( WP_TESTS_DB_VERSION_FILE, get_option('db_version') );

0 comments on commit d3de3ae

Please sign in to comment.