Attached Files |
crc32_signed_problem_core.patch [^] (8,730 bytes) 2012-03-27 06:45
[Show Content]
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
crc32_signed_problem_modules.patch [^] (7,639 bytes) 2012-03-27 06:46
[Show Content]
Index: in-auction/units/sections/ebay_eh.php
===================================================================
--- in-auction/units/sections/ebay_eh.php (revision 15165)
+++ in-auction/units/sections/ebay_eh.php (working copy)
@@ -1771,7 +1771,7 @@
$product->Load($product_id);
- $options_salt = crc32($Item->ItemID.$Transaction->TransactionID);
+ $options_salt = kUtil::crc32($Item->ItemID.$Transaction->TransactionID);
$price = isset($Transaction->TransactionPrice->_) ? $Transaction->TransactionPrice->_ : $Transaction->TransactionPrice;
Index: in-commerce/install/install_schema.sql
===================================================================
--- in-commerce/install/install_schema.sql (revision 15165)
+++ in-commerce/install/install_schema.sql (working copy)
@@ -89,26 +89,26 @@
);
CREATE TABLE OrderItems (
- OrderItemId int(11) NOT NULL auto_increment,
- OrderId int(11) NOT NULL default '0',
- ProductId int(11) NOT NULL default '0',
- ProductName varchar(255) NOT NULL default '',
- Quantity int(11) NOT NULL default '0',
- QuantityReserved int(11) default NULL,
- FlatPrice decimal(10,4) NOT NULL default '0.0000',
- Price decimal(10,4) NOT NULL default '0.0000',
- Cost double(10,4) NOT NULL default '0.0000',
- BackOrderFlag tinyint(4) default '0',
- Weight double default NULL,
- ShippingTypeId varchar(255) default NULL,
+ OrderItemId int(11) NOT NULL AUTO_INCREMENT,
+ OrderId int(11) NOT NULL DEFAULT '0',
+ ProductId int(11) NOT NULL DEFAULT '0',
+ ProductName varchar(255) NOT NULL DEFAULT '',
+ Quantity int(11) NOT NULL DEFAULT '0',
+ QuantityReserved int(11) DEFAULT NULL,
+ FlatPrice decimal(10,4) NOT NULL DEFAULT '0.0000',
+ Price decimal(10,4) NOT NULL DEFAULT '0.0000',
+ Cost double(10,4) NOT NULL DEFAULT '0.0000',
+ BackOrderFlag tinyint(4) DEFAULT '0',
+ Weight double DEFAULT NULL,
+ ShippingTypeId varchar(255) DEFAULT NULL,
ItemData text,
- OptionsSalt int(11) default '0',
- SplitShippingGroup int(11) NOT NULL default '0',
- PackageNum int(11) NOT NULL default '0',
- ReturnType tinyint(3) unsigned NOT NULL default '0',
- ReturnAmount decimal(10,2) NOT NULL default '0.00',
- ReturnedOn int(10) unsigned default NULL,
- PRIMARY KEY (OrderItemId),
+ OptionsSalt bigint(11) DEFAULT '0',
+ SplitShippingGroup int(11) NOT NULL DEFAULT '0',
+ PackageNum int(11) NOT NULL DEFAULT '0',
+ ReturnType tinyint(3) unsigned NOT NULL DEFAULT '0',
+ ReturnAmount decimal(10,2) NOT NULL DEFAULT '0.00',
+ ReturnedOn int(10) unsigned DEFAULT NULL,
+ PRIMARY KEY (OrderItemId),
KEY OrderId (OrderId),
KEY ProductId (ProductId),
KEY BackOrderFlag (BackOrderFlag),
@@ -672,7 +672,7 @@
CombinationId int(11) NOT NULL AUTO_INCREMENT,
ProductId int(11) NOT NULL DEFAULT '0',
Combination text,
- CombinationCRC int(11) NOT NULL DEFAULT '0',
+ CombinationCRC bigint(11) NOT NULL DEFAULT '0',
PriceType tinyint(1) DEFAULT '3',
Price float DEFAULT NULL,
WeightType tinyint(1) DEFAULT '3',
Index: in-commerce/install/upgrades.sql
===================================================================
--- in-commerce/install/upgrades.sql (revision 15213)
+++ in-commerce/install/upgrades.sql (working copy)
@@ -265,3 +265,12 @@
SET main_table.CachedReviewsQty = (SELECT COUNT(*) FROM <%TABLE_PREFIX%>CatalogReviews review_table WHERE review_table.ItemId = main_table.ResourceId);
# ===== v 5.2.0-B3 =====
+ALTER TABLE OrderItems CHANGE OptionsSalt OptionsSalt BIGINT(11) NULL DEFAULT '0';
+UPDATE OrderItems
+SET OptionsSalt = CAST((OptionsSalt & 0xFFFFFFFF) AS UNSIGNED INTEGER)
+WHERE OptionsSalt < 0;
+
+ALTER TABLE ProductOptionCombinations CHANGE CombinationCRC CombinationCRC BIGINT(11) NOT NULL DEFAULT '0';
+UPDATE ProductOptionCombinations
+SET CombinationCRC = CAST((CombinationCRC & 0xFFFFFFFF) AS UNSIGNED INTEGER)
+WHERE CombinationCRC < 0;
Index: in-commerce/units/product_option_combinations/product_option_combinations_event_handler.php
===================================================================
--- in-commerce/units/product_option_combinations/product_option_combinations_event_handler.php (revision 15165)
+++ in-commerce/units/product_option_combinations/product_option_combinations_event_handler.php (working copy)
@@ -37,7 +37,7 @@
$options = unserialize($object->GetDBField('Combination'));
ksort($options);
- $object->SetDBField('CombinationCRC', crc32(serialize($options)));
+ $object->SetDBField('CombinationCRC', kUtil::crc32(serialize($options)));
break;
case 'OnMassDelete':
@@ -97,7 +97,7 @@
$salt = $fields['Combination'];
ksort($salt);
- $object->Load(crc32(serialize($salt)), 'CombinationCRC');
+ $object->Load(kUtil::crc32(serialize($salt)), 'CombinationCRC');
$object->SetFieldsFromHash($fields);
$this->customProcessing($event,'before');
if ( $object->isLoaded() ) { // Update if such combination already exists
@@ -142,7 +142,7 @@
$salt = $fields['Combination'];
ksort($salt);
// try to load combination by salt - if loaded, it will update the combination
- $object->Load(crc32(serialize($salt)), 'CombinationCRC');
+ $object->Load(kUtil::crc32(serialize($salt)), 'CombinationCRC');
if ( !$object->isLoaded() ) {
$object->Load($edit_id);
}
@@ -350,7 +350,7 @@
ksort($n_combs);
$n_combs = serialize($n_combs);
- $n_crc = crc32($n_combs);
+ $n_crc = kUtil::crc32($n_combs);
$object->SetDBField('Combination', $n_combs);
$object->SetDBField('CombinationCRC', $n_crc);
}
Index: in-commerce/units/product_options/product_options_event_handler.php
===================================================================
--- in-commerce/units/product_options/product_options_event_handler.php (revision 15165)
+++ in-commerce/units/product_options/product_options_event_handler.php (working copy)
@@ -72,7 +72,7 @@
}
ksort($n_combs);
$n_combs = serialize($n_combs);
- $n_crc = crc32($n_combs);
+ $n_crc = kUtil::crc32($n_combs);
$sql = 'UPDATE ' . $poc_table . '
SET
Combination = ' . $this->Conn->qstr($n_combs) . ',
Index: in-commerce/units/product_options/product_options_helper.php
===================================================================
--- in-commerce/units/product_options/product_options_helper.php (revision 15165)
+++ in-commerce/units/product_options/product_options_helper.php (working copy)
@@ -74,7 +74,7 @@
}
if ( !$comb_only ) {
ksort($options);
- return crc32(serialize($options));
+ return kUtil::crc32(serialize($options));
}
$option_keys = array_keys($options);
Index: in-news/units/articles/articles_event_handler.php
===================================================================
--- in-news/units/articles/articles_event_handler.php (revision 15165)
+++ in-news/units/articles/articles_event_handler.php (working copy)
@@ -290,7 +290,7 @@
} while ( ($sub_node =& $sub_node->NextSibling()) );
// create/update article
- $article_crc = crc32($data['LINK'].$data['TITLE']);
+ $article_crc = kUtil::crc32($data['LINK'].$data['TITLE']);
$article_id = getArrayValue($feed_articles, $article_crc);
if ($article_id) {
$object->Load($article_id);
@@ -382,7 +382,7 @@
} while ( ($sub_node =& $sub_node->NextSibling()) );
// create/update article
- $article_crc = crc32($data['LINK'].$data['TITLE']);
+ $article_crc = kUtil::crc32($data['LINK'].$data['TITLE']);
$article_id = getArrayValue($feed_articles, $article_crc);
if ($article_id) {
$object->Load($article_id);
|