Skip to content

Instantly share code, notes, and snippets.

@srepn
srepn / gist:b741707d187e75148b339147ac8aa785
Created October 11, 2017 08:43
Check for broken data before unserialize
// broken data
$data = '';
function check_for_broken($serialized_string){
// security check + check if no need for fix
if ( !preg_match('/^[aOs]:/', $serialized_string) || @unserialize($serialized_string) !== false ) return $serialized_string;
return preg_replace_callback( '/s\:(\d+)\:\"(.*?)\";/s', function($matches){return 's:'.strlen($matches[2]).':"'.$matches[2].'";'; }, $serialized_string );
}

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
<block type="cms/block" name="block_name">
<action method="setBlockId"><id>block_code</id></action>
</block>
{{block type="cms/block" block_id="block_code"}}
{{block type="catalog/product_list" category_id="79" template="catalog/product/list_random.phtml"}}