<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Unirgy &#187; Bugs</title>
	<atom:link href="http://www.unirgy.com/blog/category/bugs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.unirgy.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 16 Mar 2011 20:34:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Bug in Magento Product Collections (UPDATE: it&#8217;s a feature)</title>
		<link>http://www.unirgy.com/blog/2011/03/bug-in-magento-product-collections-update-its-a-feature/</link>
		<comments>http://www.unirgy.com/blog/2011/03/bug-in-magento-product-collections-update-its-a-feature/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 18:52:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://www.unirgy.com/blog/?p=131</guid>
		<description><![CDATA[If you ever had issues with products disappearing from collections when they shouldn&#8217;t be, here&#8217;s one of the possible reasons: There&#8217;s a 1Mage_Bundle_Model_Observer::loadProductOptions() method, which calls 1$collection-&#62;addPriceData() on EVERY product collection, which has some nasty consequences. For example, if you have configured System > Configuration > Inventory > Stock Options > Display Out of Stock [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever had issues with products disappearing from collections when they shouldn&#8217;t be, here&#8217;s one of the possible reasons:</p>
<p>There&#8217;s a</p>
<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Mage_Bundle_Model_Observer::loadProductOptions()</div></td></tr></tbody></table></div>
<p>method, which calls</p>
<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$collection-&gt;addPriceData()</div></td></tr></tbody></table></div>
<p>on <strong>EVERY</strong> product collection, which has some nasty consequences.</p>
<p>For example, if you have configured <strong>System > Configuration > Inventory > Stock Options > Display Out of Stock Products</strong> to <strong>No</strong>, then all the out of stock products will not show up in <strong>ANY</strong> product collection, because $collection->addPriceData() inner joins with price index table, which doesn&#8217;t have entries for products not shown on the frontend (Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection::_productLimitationJoinPrice)</p>
<p>Anyways, I hope this saved you few minutes (hours) of debugging&#8230; I will update this post when or if I&#8217;ll find an acceptable solution.</p>
<p><strong>UPDATE:</strong> Got a clarification from senior Magento developer: This is an intended behavior.<br />
All the product collections, when not in admin, will be forced to hide products out of stock if this is configured.<br />
I don&#8217;t like it, and don&#8217;t think that should be the case, but I guess that&#8217;s life.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unirgy.com/blog/2011/03/bug-in-magento-product-collections-update-its-a-feature/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dangerous bug in MySQL 5.0.90</title>
		<link>http://www.unirgy.com/blog/2010/04/dangerous-bug-in-mysql-5-0-90/</link>
		<comments>http://www.unirgy.com/blog/2010/04/dangerous-bug-in-mysql-5-0-90/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 00:46:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.unirgy.com/blog/?p=105</guid>
		<description><![CDATA[Yesterday encountered a weird bug in MySQL 5.0.90, not sure about other 5.0.x versions, but 5.1.x seems to be OK. The issue presented itself here: // $skus = array(&#039;A&#039;,&#039;B&#039;,&#039;123&#039;); $_conn-&#62;fetchAll(&#34;select entity_id, sku from catalog_product_entity where sku in (?)&#34;, $skus); Normally this would select only the records which has `sku` one of provided in the $skus [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday encountered a weird bug in MySQL 5.0.90, not sure about other 5.0.x versions, but 5.1.x seems to be OK.</p>
<p>The issue presented itself here:</p>
<pre class="brush: php; ">

// $skus = array(&#039;A&#039;,&#039;B&#039;,&#039;123&#039;);
$_conn-&gt;fetchAll(&quot;select entity_id, sku from catalog_product_entity where sku in (?)&quot;, $skus);
</pre>
<p>Normally this would select only the records which has `sku` one of provided in the $skus array. But it seemed like it returned ALL records in the table, which was very curious.</p>
<p>The reason was that some of $skus were numeric, and PDO automatically converted them to numbers instead of keeping them as strings, and it confused this specific version of MySQL to have both numbers and strings in the &#8220;IN&#8221; condition, and it returned ALL records that started with alphanumeric character.</p>
<p>Isolated test case:</p>
<pre class="brush: sql; ">

-- create table
create table test (sku varchar(255) primary key);
-- create test data
insert into test values (&#039;a&#039;),(&#039;b&#039;),(&#039;c&#039;);

-- this will show ALL records with SKU starting with a letter
select * from test where sku in (&#039;&#039;,1);
</pre>
<p>This is a very dangerous issue, which can lead not only to huge memory consumption and performance degradation, but also unwarranted updates of records that should not be updated.</p>
<p>My workaround was to generate the SQL condition manually:</p>
<pre class="brush: php; ">

// $skus contains all the SKUs to be selected
// $conn is the DB connection
// $table is &#039;catalog_product_entity&#039; with correct prefix
$skus1 = array();
foreach ($skus as $sku) {
    $skus1[] = is_numeric($sku) ? &quot;&#039;&quot;.$sku.&quot;&#039;&quot; : $conn-&gt;quote($sku);
}
$select = $conn-&gt;select()-&gt;from($table)
    -&gt;where(&#039;sku in (&#039;.join(&#039;,&#039;, $skus1).&#039;)&#039;);
</pre>
<p>As MySQL 5.0.90 is still installed on many servers, make sure to account for this bug in your development.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unirgy.com/blog/2010/04/dangerous-bug-in-mysql-5-0-90/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

