wordpress/wp-content/plugins/sqlite-integration/utilities/database_maintenance.php
/**
	 * Method to check the table schemas.
	 *
	 * If there are any broken tables, it returns the array of the table names to be fixed.
	 * If not, it returns true.
	 *
	 * @return boolean|multitype:string
	 * @access private
	 */
Method to check the table schemas.
If there are any broken tables, it returns the array of the table names to be fixed.
If not, it returns true.

@return boolean|multitype:string
@access private
Method to check the table schemas . If there are any broken tables it returns the array of the table names to be fixed . If not it returns true . @return boolean|multitype : string @access private
private function sanity_check() {
		global $wpdb;
		$results_table = array();
		$columns_to_check = array(
				$wpdb->prefix.'commentmeta' => array(
					'comment_id' => '\'0\'',
					'meta_key'   => 'NULL'
				),
				$wpdb->prefix.'comments' => array(
					'comment_post_ID'      => '\'0\'',
					'comment_author_email' => '\'\'',
					'comment_author_url'   => '\'\'',
					'comment_author_IP'    => '\'\'',
					'comment_date_gmt'     => '\'0000-00-00 00:00:00\'',
					'comment_date'         => '\'0000-00-00 00:00:00\'',
					'comment_karma'        => '\'0\'',
					'comment_approved'     => '\'1\'',
					'comment_agent'        => '\'\'',
					'comment_type'         => '\'\'',
					'comment_parent'       => '\'0\'',
					'user_id'              => '\'0\''
				),
				$wpdb->prefix.'links' => array(
					'link_url'         => '\'\'',
					'link_name'        => '\'\'',
					'link_image'       => '\'\'',
					'link_target'      => '\'\'',
					'link_description' => '\'\'',
					'link_visible'     => '\'Y\'',
					'link_owner'       => '\'1\'',
					'link_rating'      => '\'0\'',
					'link_updated'     => '\'0000-00-00 00:00:00\'',
					'link_rel'         => '\'\'',
					'link_rss'         => '\'\''
				),
				$wpdb->prefix.'options' => array(
					'option_name' => '\'\'',
					'autoload' => '\'yes\''
				),
				$wpdb->prefix.'postmeta' => array(
					'post_id' => '\'0\'',
					'meta_key' => 'NULL'
				),
				$wpdb->prefix.'posts' => array(
					'post_author' => '\'0\'',
					'post_date_gmt' => '\'0000-00-00 00:00:00\'',
					'post_date' => '\'0000-00-00 00:00:00\'',
					'post_status' => '\'publish\'',
					'comment_status' => '\'open\'',
					'ping_status' => '\'open\'',
					'post_password' => '\'\'',
					'post_name' => '\'\'',
					'post_modified_gmt' => '\'0000-00-00 00:00:00\'',
					'post_modified' => '\'0000-00-00 00:00:00\'',
					'post_parent' => '\'0\'',
					'guid' => '\'\'',
					'menu_order' => '\'0\'',
					'post_type' => '\'post\'',
					'post_mime_type' => '\'\'',
					'comment_count' => '\'0\''
				),
				$wpdb->prefix.'term_relationships' => array(
					'term_order' => '0'
				),
				$wpdb->prefix.'term_taxonomy' => array(
					'taxonomy' => '\'\'',
					'parent' => '0',
					'count' => '0'
				),
				$wpdb->prefix.'terms' => array(
					'name' => '\'\'',
					'slug' => '\'\'',
					'term_group' => '0'
				),
				$wpdb->prefix.'users' => array(
					'user_login' => '\'\'',
					'user_pass' => '\'\'',
					'user_nicename' => '\'\'',
					'user_email' => '\'\'',
					'user_url' => '\'\'',
					'user_registered' => '\'0000-00-00 00:00:00\'',
					'user_activation_key' => '\'\'',
					'user_status' => '\'0\'',
					'display_name' => '\'\'',
					'spam' => '\'0\'',
					'deleted' => '\'0\''
				),
				$wpdb->prefix.'usermeta' => array(
					'user_id' => '\'0\'',
					'meta_key' => 'NULL',
				),
				$wpdb->prefix.'blog_versions' => array(
					'blog_id' => '\'0\'',
					'db_version' => '\'\'',
					'last_updated' => '\'0000-00-00 00:00:00\''
				),
				$wpdb->prefix.'blogs' => array(
					'site_id' => '\'0\'',
					'domain' => '\'\'',
					'path' => '\'\'',
					'registered' => '\'0000-00-00 00:00:00\'',
					'last_updated' => '\'0000-00-00 00:00:00\'',
					'public' => '\'1\'',
					'mature' => '\'0\'',
					'spam' => '\'0\'',
					'deleted' => '\'0\'',
					'lang_id' => '\'0\''
				),
				$wpdb->prefix.'registration_log' => array(
					'email' => '\'\'',
					'IP' => '\'\'',
					'blog_id' => '\'0\'',
					'date_registered' => '\'0000-00-00 00:00:00\''
				),
				$wpdb->prefix.'signups' => array(
					'domain' => '\'\'',
					'path' => '\'\'',
					'user_login' => '\'\'',
					'user_email' => '\'\'',
					'registered' => '\'0000-00-00 00:00:00\'',
					'activated' => '\'0000-00-00 00:00:00\'',
					'active' => '\'0\'',
					'activation_key' => '\'\'',
				),
				$wpdb->prefix.'site' => array(
					'domain' => '\'\'',
					'path' => '\'\''
				),
				$wpdb->prefix.'sitemeta' => array(
					'site_id' => '\'0\'',
					'meta_key' => 'NULL',
				)
		);
		$tables = $wpdb->tables('all');
		foreach ($tables as $table) {
			$col_infos = $wpdb->get_results("SHOW COLUMNS FROM $table");
			foreach ($col_infos as $col) {
				if (array_key_exists($col->Field, $columns_to_check[$table]) && $col->Default != $columns_to_check[$table][$col->Field]) {
					$results_table[$table] = 'damaged';
					break;
				}
			}
		}
		if (empty($results_table)) {
			return true;
		} else {
			return $results_table;
		}
	}
private function sanity_check ( ) { global $ wpdb ; $ results_table = array ( ) ; $ columns_to_check = array ( $ wpdb -> prefix . 'commentmeta' => array ( 'comment_id' => '\'0\'' , 'meta_key' => 'NULL' ) , $ wpdb -> prefix . 'comments' => array ( 'comment_post_ID' => '\'0\'' , 'comment_author_email' => '\'\'' , 'comment_author_url' => '\'\'' , 'comment_author_IP' => '\'\'' , 'comment_date_gmt' => '\'0000-00-00 00:00:00\'' , 'comment_date' => '\'0000-00-00 00:00:00\'' , 'comment_karma' => '\'0\'' , 'comment_approved' => '\'1\'' , 'comment_agent' => '\'\'' , 'comment_type' => '\'\'' , 'comment_parent' => '\'0\'' , 'user_id' => '\'0\'' ) , $ wpdb -> prefix . 'links' => array ( 'link_url' => '\'\'' , 'link_name' => '\'\'' , 'link_image' => '\'\'' , 'link_target' => '\'\'' , 'link_description' => '\'\'' , 'link_visible' => '\'Y\'' , 'link_owner' => '\'1\'' , 'link_rating' => '\'0\'' , 'link_updated' => '\'0000-00-00 00:00:00\'' , 'link_rel' => '\'\'' , 'link_rss' => '\'\'' ) , $ wpdb -> prefix . 'options' => array ( 'option_name' => '\'\'' , 'autoload' => '\'yes\'' ) , $ wpdb -> prefix . 'postmeta' => array ( 'post_id' => '\'0\'' , 'meta_key' => 'NULL' ) , $ wpdb -> prefix . 'posts' => array ( 'post_author' => '\'0\'' , 'post_date_gmt' => '\'0000-00-00 00:00:00\'' , 'post_date' => '\'0000-00-00 00:00:00\'' , 'post_status' => '\'publish\'' , 'comment_status' => '\'open\'' , 'ping_status' => '\'open\'' , 'post_password' => '\'\'' , 'post_name' => '\'\'' , 'post_modified_gmt' => '\'0000-00-00 00:00:00\'' , 'post_modified' => '\'0000-00-00 00:00:00\'' , 'post_parent' => '\'0\'' , 'guid' => '\'\'' , 'menu_order' => '\'0\'' , 'post_type' => '\'post\'' , 'post_mime_type' => '\'\'' , 'comment_count' => '\'0\'' ) , $ wpdb -> prefix . 'term_relationships' => array ( 'term_order' => '0' ) , $ wpdb -> prefix . 'term_taxonomy' => array ( 'taxonomy' => '\'\'' , 'parent' => '0' , 'count' => '0' ) , $ wpdb -> prefix . 'terms' => array ( 'name' => '\'\'' , 'slug' => '\'\'' , 'term_group' => '0' ) , $ wpdb -> prefix . 'users' => array ( 'user_login' => '\'\'' , 'user_pass' => '\'\'' , 'user_nicename' => '\'\'' , 'user_email' => '\'\'' , 'user_url' => '\'\'' , 'user_registered' => '\'0000-00-00 00:00:00\'' , 'user_activation_key' => '\'\'' , 'user_status' => '\'0\'' , 'display_name' => '\'\'' , 'spam' => '\'0\'' , 'deleted' => '\'0\'' ) , $ wpdb -> prefix . 'usermeta' => array ( 'user_id' => '\'0\'' , 'meta_key' => 'NULL' , ) , $ wpdb -> prefix . 'blog_versions' => array ( 'blog_id' => '\'0\'' , 'db_version' => '\'\'' , 'last_updated' => '\'0000-00-00 00:00:00\'' ) , $ wpdb -> prefix . 'blogs' => array ( 'site_id' => '\'0\'' , 'domain' => '\'\'' , 'path' => '\'\'' , 'registered' => '\'0000-00-00 00:00:00\'' , 'last_updated' => '\'0000-00-00 00:00:00\'' , 'public' => '\'1\'' , 'mature' => '\'0\'' , 'spam' => '\'0\'' , 'deleted' => '\'0\'' , 'lang_id' => '\'0\'' ) , $ wpdb -> prefix . 'registration_log' => array ( 'email' => '\'\'' , 'IP' => '\'\'' , 'blog_id' => '\'0\'' , 'date_registered' => '\'0000-00-00 00:00:00\'' ) , $ wpdb -> prefix . 'signups' => array ( 'domain' => '\'\'' , 'path' => '\'\'' , 'user_login' => '\'\'' , 'user_email' => '\'\'' , 'registered' => '\'0000-00-00 00:00:00\'' , 'activated' => '\'0000-00-00 00:00:00\'' , 'active' => '\'0\'' , 'activation_key' => '\'\'' , ) , $ wpdb -> prefix . 'site' => array ( 'domain' => '\'\'' , 'path' => '\'\'' ) , $ wpdb -> prefix . 'sitemeta' => array ( 'site_id' => '\'0\'' , 'meta_key' => 'NULL' , ) ) ; $ tables = $ wpdb -> tables ( 'all' ) ; foreach ( $ tables as $ table ) { $ col_infos = $ wpdb -> get_results ( " SHOW COLUMNS FROM  $ table " ) ; foreach ( $ col_infos as $ col ) { if ( array_key_exists ( $ col -> Field , $ columns_to_check [ $ table ] ) && $ col -> Default != $ columns_to_check [ $ table ] [ $ col -> Field ] ) { $ results_table [ $ table ] = 'damaged' ; break ; } } } if ( empty ( $ results_table ) ) { return true ; } else { return $ results_table ; } }
Method to check the table schemas.
Method to check the table schemas .
// for network install // for network install