From: Roland Häder Date: Tue, 6 Oct 2009 19:09:04 +0000 (+0000) Subject: Bug with multiple registration of filters fixed (see fix_filters.php for details) X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=509ae618cc32ba2b811cf66567d62abc597dc405 Bug with multiple registration of filters fixed (see fix_filters.php for details) --- diff --git a/.gitattributes b/.gitattributes index 35f2646bcd..7eb12c044d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -168,6 +168,7 @@ inc/extensions/ext-wernis.php -text inc/extensions/ext-yoomedia.php -text inc/fatal_errors.php -text inc/filters.php -text +inc/fix_filters.php -text inc/footer.php -text inc/functions.php -text inc/gen_mediadata.php -text diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index e07cd405b5..0d97094c82 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -70,11 +70,12 @@ function SQL_QUERY ($sql_string, $F, $L) { $querytimeBefore = array_sum(explode(' ', microtime())); // Run SQL command - //* DEBUG: */ echo $sql_string."
\n"; + //* DEBUG: */ print $sql_string."
\n"; $result = mysql_query($sql_string, SQL_GET_LINK()) or addFatalMessage(__FUNCTION__, __LINE__, $F." (".$L."):".mysql_error()."
Query string:
".$sql_string); + //* DEBUG: */ print __LINE__ . ': numRows=' . SQL_NUMROWS($result) . ',affected=' . SQL_AFFECTEDROWS() . "
\n"; // Ending time $querytimeAfter = array_sum(explode(' ', microtime())); diff --git a/inc/extensions.php b/inc/extensions.php index 5fb56a2765..22f218150d 100644 --- a/inc/extensions.php +++ b/inc/extensions.php @@ -549,7 +549,7 @@ function EXTENSION_UPDATE ($ext_name, $ext_ver, $dry_run = false) { // And load SQL queries in order of version history for ($idx = ($start + 1); $idx < count($history); $idx++) { // Set current extension name - //* DEBUG: */ print __FUNCTION__.'['.__LINE__.':] ext_name='.$ext_name.'
'; + //* DEBUG: */ print __FUNCTION__.'['.__LINE__.':] ext_name='.$ext_name."
\n"; EXT_SET_CURR_NAME($ext_name); // Set extension version diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index e4016d1815..ecb7ec650d 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -40,13 +40,13 @@ if (!defined('__SECURITY')) { $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php'; require($INC); -} +} // END - if // Version number -EXT_SET_VERSION('0.6.2'); +EXT_SET_VERSION('0.6.3'); // Version history array (add more with , '0.1.0' and so on) -EXT_SET_VER_HISTORY(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2')); +EXT_SET_VER_HISTORY(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3')); switch ($EXT_LOAD_MODE) { @@ -681,6 +681,14 @@ PRIMARY KEY (`filter_id`) // Update notes (these will be set as task text!) EXT_SET_UPDATE_NOTES("Abhängigkeit von ext-user gesetzt."); break; + + case '0.6.3': // SQL queries for v0.6.3 + // Update notes (these will be set as task text!) + EXT_SET_UPDATE_NOTES("Filter-Tabelle bereinigt um doppelte Einträge und Unique-Key auf filter_name und filter_function zusammen gesetzt."); + + // Include special filte + loadIncludeOnce('inc/fix_filters.php'); + break; } break; diff --git a/inc/fix_filters.php b/inc/fix_filters.php new file mode 100644 index 0000000000..60611539a2 --- /dev/null +++ b/inc/fix_filters.php @@ -0,0 +1,79 @@ + 0) { + // Load row by row + while ($filter = SQL_FETCHARRAY($result)) { + // Now search again for this filter and get it's total count + $count = GET_TOTAL_DATA($filter['filter_name'], 'filters', 'filter_id', 'filter_name', true, sprintf(" AND `filter_function`='%s'", $filter['filter_function'])); + + // Do we have more than one entry? + if ($count > 1) { + // Then clean them up, except one + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_filters` WHERE `filter_name`='%s' AND `filter_function`='%s' LIMIT %s", + array($filter['filter_name'], $filter['filter_function'], ($count - 1)), __FILE__, __LINE__); + } // END - while + } // END - while +} else { + // @TODO Why does this happen? In installation phase of sql_patches? + debug_report_bug(basename(__FILE__) . ' did run with no filters in database.'); +} + +// Free result +SQL_FREERESULT($result); + +// Now insert our unqiue key +SQL_QUERY("ALTER TABLE `{!_MYSQL_PREFIX!}_filters` ADD UNIQUE `name_function` (`filter_name` , `filter_function`)", __FILE__, __LINE__); + +// [EOF] +?> diff --git a/inc/functions.php b/inc/functions.php index 5f9e1229ad..db721a542e 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -3430,7 +3430,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad // Exclude '.', '..' and entries in $excludeArray automatically if (in_array($baseFile, $excludeArray, true)) { // Exclude them - //* DEBUG: */ print 'excluded=' . $baseFile . '
'; + //* DEBUG: */ print 'excluded=' . $baseFile . "
\n"; continue; } // END - if @@ -3444,9 +3444,9 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad // Check if the base filename matches an exclusion pattern and if the pattern is not empty if ((!empty($excludePattern)) && (preg_match($excludePattern, $baseFile, $match))) { // These Lines are only for debugging!! - //* DEBUG: */ print 'baseDir:' . $baseDir . '
'; - //* DEBUG: */ print 'baseFile:' . $baseFile . '
'; - //* DEBUG: */ print 'FQFN:' . $FQFN . '
'; + //* DEBUG: */ print 'baseDir:' . $baseDir . "
\n"; + //* DEBUG: */ print 'baseFile:' . $baseFile . "
\n"; + //* DEBUG: */ print 'FQFN:' . $FQFN . "
\n"; // Exclude this one continue; diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 491bf296ff..23f4621a6d 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1796,18 +1796,18 @@ function updateConfiguration ($entries, $values, $updateMode='') { if (!empty($updateMode)) { // Update entry // @TODO Find a way for updating $_CONFIG here - $all .= sprintf("%s=%s%s%s,", $entry, $entry, $updateMode, (float)$values[$idx]); + $all .= sprintf("`%s`=%s%s%s,", $entry, $entry, $updateMode, (float)$values[$idx]); } else { // Check if string or number if (($values[$idx] + 0) === $values[$idx]) { // Number detected - $all .= sprintf("%s=%s,", $entry, (float)$values[$idx]); + $all .= sprintf("`%s`=%s,", $entry, (float)$values[$idx]); } elseif ($values[$idx] == 'UNIX_TIMESTAMP()') { // Function UNIX_TIMESTAMP() detected - $all .= sprintf("%s=%s,", $entry, $values[$idx]); + $all .= sprintf("`%s`=%s,", $entry, $values[$idx]); } else { // String detected - $all .= sprintf("%s='%s',", $entry, SQL_ESCAPE($values[$idx])); + $all .= sprintf("`%s`='%s',", $entry, SQL_ESCAPE($values[$idx])); } }