From 45b62dab7f3717f2edfc33a1c4aa41d8212415c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 3 Nov 2010 17:12:48 +0000 Subject: [PATCH] Fixed renaming of column names, added/rewritten some debug lines: - Fixed renaming of column names, the wrong index was checked - Added debug line for skipped DROP queries - Rewritten all debugOutput() lines to logDebugMessage() in database layer which caused a 'Headers already sent' error - TODOs.txt updated --- DOCS/TODOs.txt | 21 +++++++++++---------- inc/db/lib-mysql3.php | 23 +++++++++-------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 5d848ce57e..cc4191a904 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -4,6 +4,7 @@ ./beg.php:171: // @TODO Opps, what is missing here??? ./birthday_confirm.php:93: // @TODO Try to rewrite the following unset() ./inc/autopurge/purge-inact.php:55: // @TODO Rewrite these if() blocks to a filter +./inc/cache/config-local.php:126:// @TODO Rewrite the following three constants, somehow... ./inc/classes/cachesystem.class.php:472: // @TODO Add support for more types which break in last else-block ./inc/config-functions.php:139: // @TODO Make this all better... :-/ ./inc/expression-functions.php:164:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again @@ -45,7 +46,7 @@ ./inc/functions.php:1591: // @TODO Are these convertions still required? ./inc/functions.php:1609:// @TODO Rewrite this function to use readFromFile() and writeToFile() ./inc/functions.php:179:// @TODO Rewrite this to an extension 'smtp' -./inc/functions.php:2273: // @TODO This is still very static, rewrite it somehow +./inc/functions.php:2275: // @TODO This is still very static, rewrite it somehow ./inc/gen_sql_patches.php:94:// @TODO Rewrite this to a filter ./inc/install-functions.php:57: // @TODO DEACTIVATED: changeDataInFile(getCachePath() . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); ./inc/language/de.php:1091:// @TODO Rewrite these two constants @@ -176,20 +177,20 @@ ./inc/monthly/monthly_bonus.php:67: // @TODO Rewrite this to a filter ./inc/mysql-manager.php:1183: // @TODO Rewrite this to a filter ./inc/mysql-manager.php:1438: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1546: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1917: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1961:// @TODO Fix inconsistency between last_module and getWhat() +./inc/mysql-manager.php:1544: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1915: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1959:// @TODO Fix inconsistency between last_module and getWhat() ./inc/mysql-manager.php:368: // @TODO Try to rewrite this to one or more functions ./inc/mysql-manager.php:44:// @TODO Can we cache this? ./inc/reset/reset_beg.php:49:// @TODO This should be converted in a daily beg rallye ./inc/reset/reset_birthday.php:89: // @TODO 4 is hard-coded here, should we move it out in config? ./inc/revision-functions.php:169:// @TODO This function does also set and get in 'cache_array' -./inc/template-functions.php:1046: // @TODO Deprecate this thing -./inc/template-functions.php:1057: // @TODO Deprecate this thing -./inc/template-functions.php:1144: // @TODO This can be easily moved out after the merge from EL branch to this is complete -./inc/template-functions.php:1177: // @TODO Add a little more infos here -./inc/template-functions.php:1465:// @TODO Lame description for this function -./inc/template-functions.php:1484: // @TODO Move this in a filter +./inc/template-functions.php:1044: // @TODO Deprecate this thing +./inc/template-functions.php:1055: // @TODO Deprecate this thing +./inc/template-functions.php:1142: // @TODO This can be easily moved out after the merge from EL branch to this is complete +./inc/template-functions.php:1175: // @TODO Add a little more infos here +./inc/template-functions.php:1463:// @TODO Lame description for this function +./inc/template-functions.php:1485: // @TODO Move this in a filter ./inc/template-functions.php:187: * @TODO On some pages this is buggy ./inc/template-functions.php:263: // @TODO Remove this sanity-check if all is fine ./inc/template-functions.php:576:// @TODO $simple/$constants are deprecated diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 747da66559..1b00955cee 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -77,7 +77,7 @@ function SQL_QUERY ($sqlString, $F, $L, $enableCodes = true) { $querytimeBefore = microtime(true); // Run SQL command - //* DEBUG: */ debugOutput('F=' . basename($F) . ',L=' . $L . 'sql=' . encodeEntities($GLOBALS['last_sql'])); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'F=' . basename($F) . ',L=' . $L . ',sql=' . encodeEntities($GLOBALS['last_sql'])); $result = mysql_query($GLOBALS['last_sql'], SQL_GET_LINK()) or debug_report_bug($F, $L, 'file='. basename($F) . ',line=' . $L . ':mysql_error()=' . mysql_error() . "\n". 'Query string:' . $GLOBALS['last_sql']); @@ -274,12 +274,6 @@ function SQL_QUERY_ESC ($sqlString, $data, $F, $L, $run = true, $strip = true, $ // Generate query $query = call_user_func_array('sprintf', $dataSecured); - // Debugging - // - //* DEBUG: */ $fp = fopen(getCachePath() . 'escape_debug.log', 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write debug.log!'); - //* DEBUG: */ fwrite($fp, $F . '(' . $L . '): ' . str_replace("\r", '', str_replace("\n", ' ', $eval)) . "\n"); - //* DEBUG: */ fclose($fp); - if ($run === true) { // Run SQL query (default) return SQL_QUERY($query, $F, $L); @@ -310,7 +304,6 @@ function SQL_ESCAPE ($str, $secureString = true, $strip = true) { $ret = escapeQuotes($str); } elseif (function_exists('mysql_real_escape_string')) { // The new and improved version - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str='.$str); $ret = mysql_real_escape_string($str, SQL_GET_LINK()); } elseif (function_exists('mysql_escape_string')) { // The obsolete function @@ -382,7 +375,7 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) { $tableName = str_replace('`', '', $tableArray[2]); // Debug log - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sql=' . $sql . ',tableName=' . $tableName); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sql=' . $sql . ',tableName=' . $tableName); // Shall we add/drop? if (((strpos($sql, 'ADD') !== false) || (strpos($sql, 'DROP') !== false) || (strpos($sql, 'CHANGE') !== false)) && ($noIndex === true)) { @@ -392,6 +385,7 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) { if (!isset($tableArray[$idx])) { // Debug log this logDebugMessage(__FUNCTION__, __LINE__, 'columnName=' . $columnName . ',idx=' . $idx . ',sql=' . $sql . ' is missing!'); + break; } // END - if // And column name as well @@ -406,7 +400,7 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) { // Do we have no entry on ADD or an entry on DROP/CHANGE? // 123 4 43 3 4 4 32 23 4 4 3 3 4 4 32 23 4 43 3 4 4 3 3 321 - if (((SQL_HASZERONUMS($result)) && (strpos($sql, 'ADD') !== false)) || ((!SQL_HASZERONUMS($result)) && (strpos($sql, 'DROP') !== false)) || ((!SQL_HASZERONUMS($result)) && (strpos($sql, 'CHANGE') !== false) && ($idx == 5))) { + if (((SQL_HASZERONUMS($result)) && (strpos($sql, 'ADD') !== false)) || ((!SQL_HASZERONUMS($result)) && (strpos($sql, 'DROP') !== false)) || ((!SQL_HASZERONUMS($result)) && (strpos($sql, 'CHANGE') !== false) && ($idx == 4))) { // Do the query //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Executing: ' . $sql); $result = SQL_QUERY($sql, $F, $L, false); @@ -416,10 +410,11 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) { // 1234 5 54 4 5 5 43 34 5 54 4 5 5 43 3 4 4 32 2 21 } elseif ((((!SQL_HASZERONUMS($result)) && (strpos($sql, 'ADD') !== false)) || ((!SQL_HASZERONUMS($result)) && (strpos($sql, 'DROP') !== false)) || (strpos($sql, 'CHANGE') !== false)) && ($columnName != 'KEY')) { // Abort here because it is alreay there - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: ' . $sql); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: sql=' . $sql . ',columnName=' . $columnName . ',idx=' . $idx); break; } elseif ((SQL_HASZERONUMS($result)) && (strpos($sql, 'DROP') !== false)) { // Abort here because we tried to drop a column which is not there (never created maybe) + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'No drop: ' . $sql); break; } elseif ($columnName != 'KEY') { // Something didn't fit, we better log it @@ -428,10 +423,10 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) { } // END - foreach } elseif ((getConfig('_TABLE_TYPE') == 'InnoDB') && (strpos($sql, 'FULLTEXT') !== false)) { // Skip this query silently - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Skipped FULLTEXT: sql=%s,columnName=%s,idx=%d,hasZeroNums=%d,file=%s,line=%s", $sql, $columnName, $idx, intval(SQL_HASZERONUMS($result)), $F, $L)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Skipped FULLTEXT: sql=%s,tableName=%s,hasZeroNums=%d,file=%s,line=%s", $sql, $tableName, intval((is_bool($result)) ? 0 : SQL_HASZERONUMS($result)), $F, $L)); } elseif ($noIndex === false) { // And column name as well - //* DEBUG: */ debugOutput(__LINE__.':tableArray=
' . print_r($tableArray, true) . '
'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableArray=
' . print_r($tableArray, true) . '
'); $keyName = str_replace('`', '', $tableArray[5]); // Is this "UNIQUE" or so? FULLTEXT has been handled the elseif() block above @@ -468,7 +463,7 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) { // Walk through all while ($content = SQL_FETCHARRAY($result)) { // Is it found? - //* DEBUG: */ debugOutput(__LINE__.':columnName='.$keyName.',content=
' . print_r($content, true) . '
'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'columnName='.$keyName.',content=
' . print_r($content, true) . '
'); if (($content['Key_name'] == $keyName) && ($tableArray[3] == 'ADD')) { // Skip this query! //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("ADD: Skiped: %s", $sql)); -- 2.39.2