Index: install/install_schema.sql =================================================================== --- install/install_schema.sql (revision 15230) +++ install/install_schema.sql (working copy) @@ -675,16 +675,16 @@ ); CREATE TABLE SlowSqlCapture ( - CaptureId int(10) unsigned NOT NULL auto_increment, + CaptureId int(10) unsigned NOT NULL AUTO_INCREMENT, TemplateNames text, - Hits int(10) unsigned NOT NULL default '0', - LastHit int(11) NOT NULL default '0', + Hits int(10) unsigned NOT NULL DEFAULT '0', + LastHit int(11) NOT NULL DEFAULT '0', SqlQuery text, - TimeMin decimal(40,20) unsigned NOT NULL default '0.00000000000000000000', - TimeAvg decimal(40,20) unsigned NOT NULL default '0.00000000000000000000', - TimeMax decimal(40,20) unsigned NOT NULL default '0.00000000000000000000', - QueryCrc int(11) NOT NULL default '0', - PRIMARY KEY (CaptureId), + TimeMin decimal(40,20) unsigned NOT NULL DEFAULT '0.00000000000000000000', + TimeAvg decimal(40,20) unsigned NOT NULL DEFAULT '0.00000000000000000000', + TimeMax decimal(40,20) unsigned NOT NULL DEFAULT '0.00000000000000000000', + QueryCrc bigint(11) NOT NULL DEFAULT '0', + PRIMARY KEY (CaptureId), KEY Hits (Hits), KEY LastHit (LastHit), KEY TimeMin (TimeMin), @@ -1015,7 +1015,7 @@ CREATE TABLE ImportCache ( CacheId int(11) NOT NULL AUTO_INCREMENT, CacheName varchar(255) NOT NULL DEFAULT '', - VarName int(11) NOT NULL DEFAULT '0', + VarName bigint(11) NOT NULL DEFAULT '0', VarValue text, PRIMARY KEY (CacheId), KEY CacheName (CacheName), @@ -1065,7 +1065,7 @@ CREATE TABLE PageContent ( PageContentId int(11) NOT NULL AUTO_INCREMENT, - ContentNum int(11) NOT NULL DEFAULT '0', + ContentNum bigint(11) NOT NULL DEFAULT '0', PageId int(11) NOT NULL DEFAULT '0', RevisionId int(11) NOT NULL, l1_Content text, @@ -1231,7 +1231,7 @@ UrlId int(11) NOT NULL AUTO_INCREMENT, Url varchar(255) NOT NULL DEFAULT '', DomainId int(11) NOT NULL DEFAULT '0', - `Hash` int(11) NOT NULL DEFAULT '0', + `Hash` bigint(11) NOT NULL DEFAULT '0', Prefixes varchar(255) NOT NULL DEFAULT '', ParsedVars text, Cached int(10) unsigned DEFAULT NULL, Index: install/upgrades.sql =================================================================== --- install/upgrades.sql (revision 15235) +++ install/upgrades.sql (working copy) @@ -2689,3 +2689,23 @@ INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:item_filters.add', 11, 1, 1, 0); INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:item_filters.edit', 11, 1, 1, 0); INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:item_filters.delete', 11, 1, 1, 0); + +ALTER TABLE SlowSqlCapture CHANGE QueryCrc QueryCrc BIGINT(11) NOT NULL DEFAULT '0'; +UPDATE SlowSqlCapture +SET QueryCrc = CAST((QueryCrc & 0xFFFFFFFF) AS UNSIGNED INTEGER) +WHERE QueryCrc < 0; + +ALTER TABLE ImportCache CHANGE VarName VarName BIGINT(11) NOT NULL DEFAULT '0'; +UPDATE ImportCache +SET VarName = CAST((VarName & 0xFFFFFFFF) AS UNSIGNED INTEGER) +WHERE VarName < 0; + +ALTER TABLE PageContent CHANGE ContentNum ContentNum BIGINT(11) NOT NULL DEFAULT '0'; +UPDATE PageContent +SET ContentNum = CAST((ContentNum & 0xFFFFFFFF) AS UNSIGNED INTEGER) +WHERE ContentNum < 0; + +ALTER TABLE CachedUrls CHANGE Hash Hash BIGINT(11) NOT NULL DEFAULT '0'; +UPDATE CachedUrls +SET Hash = CAST((Hash & 0xFFFFFFFF) AS UNSIGNED INTEGER) +WHERE Hash < 0; Index: kernel/application.php =================================================================== --- kernel/application.php (revision 15239) +++ kernel/application.php (working copy) @@ -1283,7 +1283,7 @@ */ public function logSlowQuery($slow_sql, $time) { - $query_crc = crc32($slow_sql); + $query_crc = kUtil::crc32($slow_sql); $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'SlowSqlCapture Index: kernel/globals.php =================================================================== --- kernel/globals.php (revision 15226) +++ kernel/globals.php (working copy) @@ -677,6 +677,17 @@ return $path; } } + + /** + * Calculates the crc32 polynomial of a string (always positive number) + * + * @param string $str + * @return int + */ + public static function crc32($str) + { + return sprintf('%u', crc32($str)); + } } /** Index: kernel/managers/rewrite_url_processor.php =================================================================== --- kernel/managers/rewrite_url_processor.php (revision 15226) +++ kernel/managers/rewrite_url_processor.php (working copy) @@ -189,7 +189,7 @@ $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'CachedUrls - WHERE Hash = ' . crc32($url) . ' AND DomainId = ' . (int)$this->Application->siteDomainField('DomainId'); + WHERE Hash = ' . kUtil::crc32($url) . ' AND DomainId = ' . (int)$this->Application->siteDomainField('DomainId'); $data = $this->Conn->GetRow($sql); if ($data) { @@ -261,7 +261,7 @@ $fields_hash = Array ( 'Url' => $url, - 'Hash' => crc32($url), + 'Hash' => kUtil::crc32($url), 'DomainId' => (int)$this->Application->siteDomainField('DomainId'), 'Prefixes' => $prefixes ? '|' . implode('|', $prefixes) . '|' : '', 'ParsedVars' => serialize($data), Index: units/categories/categories_tag_processor.php =================================================================== --- units/categories/categories_tag_processor.php (revision 15165) +++ units/categories/categories_tag_processor.php (working copy) @@ -1164,7 +1164,7 @@ $name = getArrayValue($params, 'name'); if ( $name ) { - $num = crc32($name); + $num = kUtil::crc32($name); } } Index: units/helpers/cat_dbitem_export_helper.php =================================================================== --- units/helpers/cat_dbitem_export_helper.php (revision 15241) +++ units/helpers/cat_dbitem_export_helper.php (working copy) @@ -115,34 +115,38 @@ function storeCache($cache_types) { + $fields_hash = Array (); $cache_types = explode(',', $cache_types); - $values_sql = ''; foreach ($cache_types as $cache_type) { - $sql_mask = '('.$this->Conn->qstr($cache_type).',%s,%s),'; + $fields_hash = Array ('CacheName' => $cache_type); $cache = getArrayValue($this->cacheStatus, $cache_type); - if (!$cache) $cache = Array(); + + if ( !$cache ) { + $cache = Array (); + } + foreach ($cache as $var_name => $cache_status) { - $var_value = $this->cache[$cache_type][$var_name]; - $values_sql .= sprintf($sql_mask, $this->Conn->qstr($var_name), $this->Conn->qstr($var_value) ); + $fields_hash['VarName'] = $var_name; + $fields_hash['VarValue'] = $this->cache[$cache_type][$var_name]; + + $this->Conn->doInsert($fields_hash, $this->cacheTable, 'INSERT', false); } } - $values_sql = substr($values_sql, 0, -1); - - if ($values_sql) { - $sql = 'INSERT INTO '.$this->cacheTable.'(`CacheName`,`VarName`,`VarValue`) VALUES '.$values_sql; - $this->Conn->Query($sql); + if ( isset($fields_hash['VarName']) ) { + $this->Conn->doInsert($fields_hash, $this->cacheTable, 'INSERT'); } - } function loadCache() { - $sql = 'SELECT * FROM '.$this->cacheTable; - $records = $this->Conn->Query($sql); + $this->cache = Array (); - $this->cache = Array(); + $sql = 'SELECT * + FROM ' . $this->cacheTable; + $records = $this->Conn->GetIterator($sql); + foreach ($records as $record) { $this->addToCache($record['CacheName'], $record['VarName'], $record['VarValue'], false); } @@ -815,7 +819,7 @@ foreach ($this->curItem->CategoryPath as $category_index => $category_name) { if (!$category_name) continue; - $category_key = crc32( implode(':', array_slice($this->curItem->CategoryPath, 0, $category_index + 1) ) ); + $category_key = kUtil::crc32( implode(':', array_slice($this->curItem->CategoryPath, 0, $category_index + 1) ) ); $category_id = $this->getFromCache('category_names', $category_key); if ($category_id === false) { @@ -915,7 +919,7 @@ } $where_clause = substr($where_clause, 0, -5); - $item_id = $this->getFromCache('new_ids', crc32($where_clause)); + $item_id = $this->getFromCache('new_ids', kUtil::crc32($where_clause)); if (!$item_id) { if ($this->exportOptions['CheckDuplicatesMethod'] == 2) { // by other fields @@ -963,7 +967,7 @@ if ($load_keys && ($save_method == 'Create') && $this->exportOptions['ReplaceDuplicates']) { // map new id to old id - $this->addToCache('new_ids', crc32($where_clause), $this->curItem->GetID() ); + $this->addToCache('new_ids', kUtil::crc32($where_clause), $this->curItem->GetID() ); } // assign item to categories