Index: wp-includes/wp-db.php
===================================================================
--- wp-includes/wp-db.php	(revision 10840)
+++ wp-includes/wp-db.php	(working copy)
@@ -323,8 +323,12 @@
 
 		if ( defined('DB_COLLATE') )
 			$this->collate = DB_COLLATE;
-
+		/** MYSQL **/
+		/** mysqli
+		$this->dbh = @mysqli_connect($dbhost, $dbuser, $dbpassword);
+		**/
 		$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword, true);
+		/** /MYSQL **/
 		if (!$this->dbh) {
 			$this->bail(sprintf(/*WP_I18N_DB_CONN_ERROR*/"
 <h1>Error establishing a database connection</h1>
@@ -343,8 +347,14 @@
 
 		if ( $this->has_cap( 'collation' ) ) {
 			if ( !empty($this->charset) ) {
+				/** MYSQL **/
+				/** mysqli
+				if ( function_exists('mysqli_set_charset') ) {
+					mysqli_set_charset($this->dbh, $this->charset);
+				**/
 				if ( function_exists('mysql_set_charset') ) {
 					mysql_set_charset($this->charset, $this->dbh);
+				/** /MYSQL **/
 					$this->real_escape = true;
 				} else {
 					$collation_query = "SET NAMES '{$this->charset}'";
@@ -412,7 +422,12 @@
 	 * @return null Always null.
 	 */
 	function select($db) {
+		/** MYSQL **/
+		/** mysqli
+		if (!@mysqli_select_db($this->dbh, $db)) {
+		**/
 		if (!@mysql_select_db($db, $this->dbh)) {
+		/** /MYSQL **/
 			$this->ready = false;
 			$this->bail(sprintf(/*WP_I18N_DB_SELECT_DB*/'
 <h1>Can&#8217;t select database</h1>
@@ -433,7 +448,12 @@
 
 	function _real_escape($string) {
 		if ( $this->dbh && $this->real_escape )
+			/** MYSQL **/
+			/** mysqli
+			return mysqli_real_escape_string( $this->dbh, $string );
+			**/
 			return mysql_real_escape_string( $string, $this->dbh );
+			/** /MYSQL **/
 		else
 			return addslashes( $string );
 	}
@@ -524,7 +544,12 @@
 	function print_error($str = '') {
 		global $EZSQL_ERROR;
 
+		/** MYSQL **/
+		/** mysqli
+		if (!$str) $str = mysqli_error($this->dbh);
+		**/
 		if (!$str) $str = mysql_error($this->dbh);
+		/** /MYSQL **/
 		$EZSQL_ERROR[] = array ('query' => $this->last_query, 'error_str' => $str);
 
 		if ( $this->suppress_errors )
@@ -648,39 +673,75 @@
 		if ( defined('SAVEQUERIES') && SAVEQUERIES )
 			$this->timer_start();
 
+		/** MYSQL **/
+		/** mysqli
+		$this->result = @mysqli_query($this->dbh, $query);
+		**/
 		$this->result = @mysql_query($query, $this->dbh);
+		/** /MYSQL **/
 		++$this->num_queries;
 
 		if ( defined('SAVEQUERIES') && SAVEQUERIES )
 			$this->queries[] = array( $query, $this->timer_stop(), $this->get_caller() );
 
 		// If there is an error then take note of it..
+		/** MYSQL **/
+		/** mysqli
+		if ( $this->last_error = mysqli_error($this->dbh) ) {
+		**/
 		if ( $this->last_error = mysql_error($this->dbh) ) {
+		/** /MYSQL **/
 			$this->print_error();
 			return false;
 		}
 
 		if ( preg_match("/^\\s*(insert|delete|update|replace|alter) /i",$query) ) {
+			/** MYSQL **/
+			/** mysqli
+			$this->rows_affected = mysqli_affected_rows($this->dbh);
+			**/
 			$this->rows_affected = mysql_affected_rows($this->dbh);
+			/** /MYSQL **/
 			// Take note of the insert_id
 			if ( preg_match("/^\\s*(insert|replace) /i",$query) ) {
+				/** MYSQL **/
+				/** mysqli
+				$this->insert_id = mysqli_insert_id($this->dbh);
+				**/
 				$this->insert_id = mysql_insert_id($this->dbh);
+				/** /MYSQL **/
 			}
 			// Return number of rows affected
 			$return_val = $this->rows_affected;
 		} else {
 			$i = 0;
+			/** MYSQL **/
+			/** mysqli
+			while ($i < @mysqli_num_fields($this->result)) {
+				$this->col_info[$i] = @mysqli_fetch_field($this->result);
+			**/
 			while ($i < @mysql_num_fields($this->result)) {
 				$this->col_info[$i] = @mysql_fetch_field($this->result);
+			/** /MYSQL **/
 				$i++;
 			}
 			$num_rows = 0;
+			/** MYSQL **/
+			/** mysqli
+			while ( $row = @mysqli_fetch_object($this->result) ) {
+			**/
 			while ( $row = @mysql_fetch_object($this->result) ) {
+			/** /MYSQL **/
 				$this->last_result[$num_rows] = $row;
 				$num_rows++;
 			}
 
+			/** MYSQL **/
+			/** mysqli
+			@mysqli_free_result($this->result);
+			**/
 			@mysql_free_result($this->result);
+			/** /MYSQL **/
 
 			// Log number of rows the query returned
 			$this->num_rows = $num_rows;
@@ -1056,7 +1117,12 @@
 	 * @return false|string false on failure, version number on success
 	 */
 	function db_version() {
+		/** MYSQL **/
+		/** mysqli
+		return preg_replace('/[^0-9.].*/', '', mysqli_get_server_info( $this->dbh ));
+		**/
 		return preg_replace('/[^0-9.].*/', '', mysql_get_server_info( $this->dbh ));
+		/** /MYSQL **/
 	}
 }
 
Index: wp-settings.php
===================================================================
--- wp-settings.php	(revision 10840)
+++ wp-settings.php	(working copy)
@@ -15,7 +15,14 @@
 if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
 	@ini_set('memory_limit', WP_MEMORY_LIMIT);
 
+/** PHP **/
+/** >4.4.9
+**/
+/** <=5.2.9
 set_magic_quotes_runtime(0);
+**/
+set_magic_quotes_runtime(0);
+/** /PHP **/
 @ini_set('magic_quotes_sybase', 0);
 
 /**
@@ -140,7 +147,12 @@
 	}
 }
 
+/** MYSQL **/
+/** mysqli
+if ( !extension_loaded('mysqli') && !file_exists(WP_CONTENT_DIR . '/db.php') )
+**/
 if ( !extension_loaded('mysql') && !file_exists(WP_CONTENT_DIR . '/db.php') )
+/** /MYSQL **/
 	die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ );
 
 /**
@@ -565,7 +577,15 @@
  * @global object $wp_the_query
  * @since 2.0.0
  */
+/** PHP **/
+/** <5.0.0
 $wp_the_query =& new WP_Query();
+**/
+/** >4.4.9
+$wp_the_query = new WP_Query();
+**/
+$wp_the_query =& new WP_Query();
+/** /PHP **/
 
 /**
  * Holds the reference to @see $wp_the_query
@@ -580,21 +600,45 @@
  * @global object $wp_rewrite
  * @since 1.5.0
  */
+/** PHP **/
+/** <5.0.0
 $wp_rewrite   =& new WP_Rewrite();
+**/
+/** >4.4.9
+$wp_rewrite   = new WP_Rewrite();
+**/
+$wp_rewrite   =& new WP_Rewrite();
+/** /PHP **/
 
 /**
  * WordPress Object
  * @global object $wp
  * @since 2.0.0
  */
+/** PHP **/
+/** <5.0.0
 $wp           =& new WP();
+**/
+/** >4.4.9
+$wp           = new WP();
+**/
+$wp           =& new WP();
+/** /PHP **/
 
 /**
  * WordPress Widget Factory Object
  * @global object $wp_widget_factory
  * @since 2.8.0
  */
+/** PHP **/
+/** <5.0.0
 $wp_widget_factory =& new WP_Widget_Factory();
+**/
+/** >4.4.9
+$wp_widget_factory = new WP_Widget_Factory();
+**/
+$wp_widget_factory =& new WP_Widget_Factory();
+/** /PHP **/
 
 do_action('setup_theme');
 
@@ -630,7 +674,15 @@
  * @global object $wp_locale
  * @since 2.1.0
  */
+/** PHP **/
+/** <5.0.0
 $wp_locale =& new WP_Locale();
+**/
+/** >4.4.9
+$wp_locale = new WP_Locale();
+**/
+$wp_locale =& new WP_Locale();
+/** /PHP **/
 
 // Load functions for active theme.
 if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH . '/functions.php') )
Index: wp-admin/install.php
===================================================================
--- wp-admin/install.php	(revision 10840)
+++ wp-admin/install.php	(working copy)
@@ -14,6 +14,9 @@
  */
 define('WP_INSTALLING', true);
 
+/** Do version adjustments */
+require_once('wp-adjust.php');
+
 /** Load WordPress Bootstrap */
 require_once('../wp-load.php');
 
