Magento Error Warning: mcrypt_generic_deinit(): Could not terminate encryption specifier

I ran into the below error today while working with Magento 1 and registering a customer during checkout.

[10-Apr-2018 13:49:47] WARNING: [pool www] child 1731 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Uncaught exception 'Exception' with message 'Warning: mcrypt_generic_deinit(): Could not terminate encryption specifier  in /var/www/myproject/htdocs/lib/Varien/Crypt/Mcrypt.php on line 135' in /var/www/myproject/htdocs/app/code/core/Mage/Core/functions.php:245"
[10-Apr-2018 13:49:47] WARNING: [pool www] child 1731 said into stderr: "Stack trace:"
[10-Apr-2018 13:49:47] WARNING: [pool www] child 1731 said into stderr: "#0 [internal function]: mageCoreErrorHandler(2, 'mcrypt_generic_...', '/var/www/myproject...', 135, Array)"
[10-Apr-2018 13:49:47] WARNING: [pool www] child 1731 said into stderr: "#1 /var/www/myproject/htdocs/lib/Varien/Crypt/Mcrypt.php(135): mcrypt_generic_deinit(Resource id #180)"
[10-Apr-2018 13:49:47] WARNING: [pool www] child 1731 said into stderr: "#2 /var/www/myproject/htdocs/lib/Varien/Crypt/Mcrypt.php(54): Varien_Crypt_Mcrypt->_reset()"
[10-Apr-2018 13:49:47] WARNING: [pool www] child 1731 said into stderr: "#3 [internal function]: Varien_Crypt_Mcrypt->destruct()"
[10-Apr-2018 13:49:47] WARNING: [pool www] child 1731 said into stderr: "#4 {main}"
[10-Apr-2018 13:49:47] WARNING: [pool www] child 1731 said into stderr: "  thrown in /var/www/myproject/htdocs/app/code/core/Mage/Core/functions.php on line 245"

The problem is the encryption key in app/etc/local.xml was empty. Add one to solve the problem.

The Phoenix Project book take aways

I just finished listening to the audio book of the Phoenix project. I had a few primary take aways from this book:
1. Reduce WIP (work in progress). I’ve been on projects in my career where when we’d get blocked on doing some work, we needed to keep the team busy so we’d pull in other work. Soon enough you’d have 100 initiatives going on at once that you’re able to devote to each only ten minutes per week. In this project we paused for two weeks where no new work was added and we just focused on completing the work already in progress. It reduces context switching and allows more work to get completed.

2. Automated builds and deployments. I’ve also been on teams where this has been done and it’s fantastic. Building and maintaining the tool itself takes effort, so plan for that. But, once it’s finished you can deploy all day with consistency and accuracy.

3. Identify your workflow’s constraint (bottleneck). Any improvements to the workflow that are not at the constraint are worthless.

4. Unplanned work prevents you from meeting your goals. Minimize this.

Here are a couple great resources for notes and take aways and

How to update google compute engine instance

My google compute engine instance is running Debian.  As I’ve read, those running Centos and Redhat linux have a nightly yum update, but not servers running Debian Linux.  If you’re unsure which version of linux you have, run

cat /proc/version

My Debian Linux Google compute engine has apt-get installed and not yum. Run this command to have it check for and print updates; it won’t install them.

apt list --upgradable

If you haven’t upgraded software in a while, you’ll see a long list of packages that need to be updated.

There are a few different ways to install the updates as described here and here . I usually run

apt-get -y dist-upgrade

Afterward if you run “apt list –upgradable” again it’ll just say “Listing… Done” since nothing needs to be updated.

Magento 2 vs Magento 1 pricing differences

Advanced Pricing

Advanced pricing is a section where you can setup specials and tiered pricing.  The functionality is the same as in M1, but they’ve just moved and renamed some functionality.

There are two kinds of advanced pricing in magento 2.

  1. You can set a special price for a date range, which was already available in M1.
    1. Special price to and from date is missing in Magento 2 EE. This is because Magento intentionally removed it from EE so admins would use scheduled updates instead.
    2. In addition to specifying a fixed price discount for tiered pricing, in M2 tiered pricing can be a percentage off discount.
    3. M2 has an input for product cost, which has no value that I can find.  It’s not in reports or anything; it does get inserted into the order quote though.


Configurable Products

In Magento 1, once the simple product is associated to the configurable, the simple’s price no longer matters; it’s not used.  It’s still visible when viewing the configurable’s simple products and adds confusion.  In M1 the variations’s pricing is based off the configurable’s price plus a difference of fixed amount or percentage.  The difference can be negative. 

In Magento 2, configurable variation pricing is one of the following:

  1. All simple variations inherit the price from the configurable
  2. A price is specified for each simple. The difference from M1 is, the price you specify isn’t based on the configurable’s price at all; it’s independent.  If the configurable’s price is $20, and you want this simple’s price to be $25, you’ll specify $25 in M2 instead of $5 in M1.  This works much better if you’re pulling in prices from an ERP that has the full price specified. 

A faceted navigation that’s optimal for both site visitors and SEO

A project of mine suffers from over categorization as described here . There are too many sub categories, many of which contain just a product or two, that silo the visitor into a cumbersome experience. Imagine you visited a site and viewed their TV’s and you looked at their category for 40″ TVs. But then, you decided to view other TV’s, so you viewed the 42″ category, and then the 46″ category. The same would happen if you wanted to shop TV’s by brand, type, or another feature. It would take a long time to browse all available TV’s with the features that are valuable to you! This is an example of over categorization. Instead the categories should be turned into a TV’s category with a variety of available facets (filters) that can be applied together.

Aside from a good information architecture, site speed is important. An ajax based navigation, such as this one provides a great user experience because only the products will reload when a filter is applied. An entire page reload when a filter changes is not necessary, which improves performance.

While an ajax based navigation is great for visitors, it’s terrible for search engine optimization because:

  1. The filters (facets) and combinations of filters won’t have unique meta content or in page descriptions like the previous sub categories did. With the previous over categorization there was a separate category for “Sony TV’s” that had a unique URL, page title and meta data, and a unique in page description. This is extremely important for SEO and is lost when switching to a general TV’s category with a brand filter (Sony).

    Solution –
    I was happy to find this Amasty extension solves the problem. Try out the filtering on this demo . Notice I’ve linked you directly to the category page with a few filters applied; the combination of filters produces a unique URL without a query string (dresses-long.html) that is built in the same order every time for consistency. Additionally, this unique set of filters will dynamically change the page’s meta description, heading, and show/hide cms blocks of your choosing. You get the best of both worlds here – ajax driven navigation for the user and unique page content for the search engine. The downside it is takes a fair amount of configuration, but it’s worth it. This is especially important if we’re rearranging site categories and changing unnecessary sub categories, which have link juice, info filters.

  2. The filters (facets) and combinations of filters won’t get indexed by search engines like the previous sub categories did. Take the TV’s category for example – there will be one URL for TV’s that your ecommerce solution, such as Magento, will include in the Google sitemap. If you want to link the visitor directly to Sony TV’s it’s possible but with an ugly URL that won’t be included in the google sitemap by default. This URL will be in the form of a query string like tvs.html?brand=sony&size=46, which are not preferred by search engines.

    Solution –
    Build or buy functionality that will add URL’s of your choosing to the google sitemap. Again Amasty to the rescue with this module that allows you to add URL’s of your choosing .

I found these related articles helpful