diff --git a/README.md b/README.md index b462d4ac6288b3bca3d4297f37f843a763dfc5a3..f2bf98b803c7e35b28010e0cbc3e5f49422780c9 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ In particolare ci sono 2 file importanti: * La release di Wordpress core * Temi e plugins (e i mu-plugins) * I language pack - * I plugins drop-in, tipo hyperdb + * I plugins drop-in, tipo hyperdb/ludicrousdb * Codice che abbiamo scritto noi, r2db, etc. * Le patch che abbiamo deciso di applicare ai sorgenti upstream più le informazioni su dove installare tutte queste cose. Si può modificare sia a mano che usando composer. diff --git a/composer.patches.json b/composer.patches.json index e33d28b849e7f41eb4b98a92520c63b77d66c56c..56b21bdae4536f1e17ca59151a7e28e965464ced 100644 --- a/composer.patches.json +++ b/composer.patches.json @@ -10,9 +10,6 @@ "wpackagist-plugin/disable-wordpress-updates": { "Run update checks during cron": "patches/plugins/disable-wordpress-updates.patch" }, - "wpackagist-plugin/hyperdb": { - "Added optional logging": "patches/hyperdb/0158-Added-optional-logging.patch" - }, "wpackagist-plugin/more-privacy-options": { "Do send mail on privacy setting change": "patches/plugins/more-privacy-options.patch" }, diff --git a/docker/wp-config.php b/docker/wp-config.php index 277d10a280c834e4c9ac9e51b143c78937275ed9..1b464007a992a92c565586768059e0af62a356f6 100644 --- a/docker/wp-config.php +++ b/docker/wp-config.php @@ -149,10 +149,8 @@ if (array_key_exists('debug_cookie_name', $noblogs_config) && define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false); - define('AI_LOG_HYPERDB',true); } else { define('WP_DEBUG', false); - define('AI_LOG_HYPERDB',false); } /* That's all, stop editing! Happy blogging. */ diff --git a/patches/hyperdb/0158-Added-optional-logging.patch b/patches/hyperdb/0158-Added-optional-logging.patch deleted file mode 100644 index 33f5df02f75c43f18a44b8c854dc04ecf0a707df..0000000000000000000000000000000000000000 --- a/patches/hyperdb/0158-Added-optional-logging.patch +++ /dev/null @@ -1,46 +0,0 @@ -From dd05078d025695bba3907c7fac2c840a6835bbaf Mon Sep 17 00:00:00 2001 -From: Joe <joe@autistici.org> -Date: Fri, 3 May 2013 11:02:10 +0200 -Subject: [PATCH 158/229] Added optional logging - ---- - wp-content/db.php | 31 +++++++++++++++++-------------- - 1 file changed, 17 insertions(+), 14 deletions(-) - -diff --git a/wp-content/db.php b/wp-content/db.php -index abc3353e..0f9f5a1e 100644 ---- a/wp-content/db.php -+++ b/wp-content/db.php -@@ -680,16 +680,19 @@ class hyperdb extends wpdb { - $success = false; - $this->last_connection = compact('dbhname', 'host', 'port', 'user', 'name', 'tcp', 'elapsed', 'success'); - $this->db_connections[] = $this->last_connection; -- $msg = date( "Y-m-d H:i:s" ) . " Can't select $dbhname - \n"; -- $msg .= "'referrer' => '{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}',\n"; -- $msg .= "'server' => {$server},\n"; -- $msg .= "'host' => {$host},\n"; -- $msg .= "'error' => " . $this->ex_mysql_error() . ",\n"; -- $msg .= "'errno' => " . $this->ex_mysql_errno() . ",\n"; -- $msg .= "'server_state' => $server_state\n"; -- $msg .= "'lagged_status' => " . ( isset( $lagged_status ) ? $lagged_status : HYPERDB_LAG_UNKNOWN ); -- -- $this->print_error( $msg ); -+ /* Workaround to stop logging a/i */ -+ if ( AI_LOG_HYPERDB == true ) { -+ $msg = date( "Y-m-d H:i:s" ) . " Can't select $dbhname - \n"; -+ $msg .= "'referrer' => '{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}',\n"; -+ $msg .= "'server' => {$server},\n"; -+ $msg .= "'host' => {$host},\n"; -+ $msg .= "'error' => " . $this->ex_mysql_error() . ",\n"; -+ $msg .= "'errno' => " . $this->ex_mysql_errno() . ",\n"; -+ $msg .= "'server_state' => $server_state\n"; -+ $msg .= "'lagged_status' => " . ( isset( $lagged_status ) ? $lagged_status : HYPERDB_LAG_UNKNOWN ); -+ -+ $this->print_error( $msg ); -+ } - } - - if ( ! $success || ! isset( $this->dbhs[$dbhname] ) || ! $this->is_mysql_connection( $this->dbhs[$dbhname] ) ) { --- -2.17.1 - diff --git a/patches/hyperdb/hyperdb.patch b/patches/hyperdb/hyperdb.patch deleted file mode 100644 index 09f1928fa604b909d949dd1804341e453bd7f86b..0000000000000000000000000000000000000000 --- a/patches/hyperdb/hyperdb.patch +++ /dev/null @@ -1,127 +0,0 @@ -This is the diff between the version of db.php in branch noblogs and the one upstream. It should be the same as all the other patches togheter. -diff --git a/db.php b/db.php -index f900d305..8829d102 100644 ---- a/db.php -+++ b/db.php -@@ -51,6 +50,13 @@ define( 'HYPERDB_CONN_HOST_ERROR', 2003 ); // Can't connect to MySQL server on - define( 'HYPERDB_SERVER_GONE_ERROR', 2006 ); // MySQL server has gone away - - class hyperdb extends wpdb { -+ -+ /** -+ * A/I patch! -+ * store a FlexiHash() instance here. -+ */ -+ var $hash_map; -+ - /** - * The last table that was queried - * @var string -@@ -306,6 +312,12 @@ class hyperdb extends wpdb { - . ')\W([\w-]+)\W/is', $q, $maybe) ) - return $maybe[1]; - -+ // SHOW TABLES LIKE (used in some plugins) -+ if ( preg_match('/^\s*' -+ . 'SHOW\s+TABLES\s+LIKE\s+' -+ . '\W(\w+)\W/is', $q, $maybe) ) -+ return $maybe[1]; -+ - // Big pattern for the rest of the table-related queries in MySQL 5.0 - if ( preg_match('/^\s*(?:' - . '(?:EXPLAIN\s+(?:EXTENDED\s+)?)?SELECT.*?\s+FROM' -@@ -401,6 +413,11 @@ class hyperdb extends wpdb { - - $this->run_callbacks( 'dataset_found', $dataset ); - -+ if (WP_DEBUG === true) { -+ $_ai_msg = sprintf("We choose dataset %s for query '%s'", $this->dataset, $query); -+ $this->print_error($_ai_msg); -+ } -+ - if ( empty( $this->hyper_servers ) ) { - if ( $this->is_mysql_connection( $this->dbh ) ) - return $this->dbh; -@@ -665,16 +682,19 @@ class hyperdb extends wpdb { - $success = false; - $this->last_connection = compact('dbhname', 'host', 'port', 'user', 'name', 'tcp', 'elapsed', 'success'); - $this->db_connections[] = $this->last_connection; -- $msg = date( "Y-m-d H:i:s" ) . " Can't select $dbhname - \n"; -- $msg .= "'referrer' => '{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}',\n"; -- $msg .= "'server' => {$server},\n"; -- $msg .= "'host' => {$host},\n"; -- $msg .= "'error' => " . $this->ex_mysql_error() . ",\n"; -- $msg .= "'errno' => " . $this->ex_mysql_errno() . ",\n"; -- $msg .= "'server_state' => $server_state\n"; -- $msg .= "'lagged_status' => " . ( isset( $lagged_status ) ? $lagged_status : HYPERDB_LAG_UNKNOWN ); -- -- $this->print_error( $msg ); -+ /* Workaround to stop logging a/i */ -+ if ( AI_LOG_HYPERDB == true ) { -+ $msg = date( "Y-m-d H:i:s" ) . " Can't select $dbhname - \n"; -+ $msg .= "'referrer' => '{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}',\n"; -+ $msg .= "'server' => {$server},\n"; -+ $msg .= "'host' => {$host},\n"; -+ $msg .= "'error' => " . $this->ex_mysql_error() . ",\n"; -+ $msg .= "'errno' => " . $this->ex_mysql_errno() . ",\n"; -+ $msg .= "'server_state' => $server_state\n"; -+ $msg .= "'lagged_status' => " . ( isset( $lagged_status ) ? $lagged_status : HYPERDB_LAG_UNKNOWN ); -+ -+ $this->print_error( $msg ); -+ } - } - - if ( ! $success || ! isset( $this->dbhs[$dbhname] ) || ! $this->is_mysql_connection( $this->dbhs[$dbhname] ) ) { -@@ -709,6 +729,15 @@ class hyperdb extends wpdb { - - $this->set_charset($this->dbhs[$dbhname], $charset, $collate); - -+ if ( !isset( $charset ) ) -+ $charset = null; -+ -+ if ( !isset( $collate ) ) -+ $collate = null; -+ -+ // AI workaround: set all queries to latin1 -+ $this->set_charset($this->dbhs[$dbhname], 'latin1'); -+ - $this->dbh = $this->dbhs[$dbhname]; // needed by $wpdb->_real_escape() - - $this->last_used_server = compact('host', 'user', 'name', 'read', 'write'); -@@ -857,6 +886,11 @@ class hyperdb extends wpdb { - $statement_after_query = $this->run_callbacks( 'statement_after_query' ); - $query_for_log = $query; - -+ // A/I: prevent mysql-proxy to cache the admin section -+ if (strpos($_SERVER['REQUEST_URI'], '/wp-admin/') !== false) { -+ $query .= ' /* NO CACHE */'; -+ } -+ - $this->timer_start(); - if ( $statement_before_query ) { - $query_for_log = "$statement_before_query; $query_for_log"; -@@ -1428,6 +1462,23 @@ class hyperdb extends wpdb { - - } // class hyperdb - --$wpdb = new hyperdb(); -+/** -+ * AI custom: Logs all queries for debugging purposes -+ */ -+function ai_log_db_queries($query, $time, $backtrace=null, hyperdb $obj ) { -+ $fh = fopen( ABSPATH . '/profiling/noblogs_queries_'. date('Ymd') . '.log', 'a'); -+ if (!$fh) { -+ return array($query, $time, $backtrace); -+ } -+ fwrite($fh, sprintf("##\n#Date: %s\n#Query time: %s\n%s\n", date('r'), $time, $query)); -+ fclose($fh); -+ return array($query, $time, $backtrace); -+} -+ - -+$wpdb = new hyperdb(); -+if ( AI_DB_PROFILER === true ) { -+ $wpdb->save_queries = true; -+ $wpdb->save_query_callback = 'ai_log_db_queries'; -+} - require( DB_CONFIG_FILE );