Blog
Magento Image Cache Storage Requirements
Published: March 5, 2020
Recently I’ve been working with a client whose server is running low on disk space. I found that their media/catalog/product
folder was 174 GB, 128 GB of which was in media/catalog/product/cache
. This seemed like a lot to me, so I did some quick math and realized that the size of their image cache was nearly 3X that of the total size of the source images. This made me curious…what does this ratio look on other Magento installations? I decided to do a little research on this and wanted to share my findings.
Get Lines of Code Changed in git diff Excluding Directory
Published: March 3, 2020
Recently I was faced with large amount of code requiring review. I needed to get back to the individual who requested the review with an estimate of how long it would take.
To give an informed estimate, it’s useful to have a sense of how many lines of code have changed. This is generally easy to do with the --shortstat
diff option (GitHub also conveniently displays this when looking at a pull request):
$ git diff --shortstat 2.0.0 2.3.0
209 files changed, 30020 insertions(+), 2531 deletions(-)
However a quick glance at the changeset told me that the majority of the changes were unit test files, which I wasn’t particularly interested in reviewing here (this was a review of 3rd party code). I wanted to figure out how many lines of code had changed, excluding test files.
Render a Category page via a Standalone script in Magento 2
Published: February 5, 2020
In this post I’ll share a standalone script that can be used to render a Magento 2 category page programmatically. This script can come in handy when debugging production issues on category pages (e.g. unexpected product set). For example, it can be executed under strace
to review files opened, queries sent, and their corresponding results.
WTF Happened to Custom Layout Updates in Magento v2.3.4
Published: January 30, 2020
In versions on Magento prior to v2.3.4, users had the ability to add custom layout updates to category, product and cms pages via a textarea input from the Magento admin panel.
These updates would then be merged with layout definitions from the theme on the website to impact the overall frontend page rendering.
Per Magento’s release notes, as of Magento v2.3.4, this ability has been removed:
Removal of custom layout updates and the deprecation of layout updates to remove the opportunity for Remote Code Execution (RCE). The Custom Layout Update field on the CMS Page Edit, Category Edit, and Product Edit pages has now been converted to a selector
https://devdocs.magento.com/guides/v2.3/release-notes/release-notes-2-3-4-open-source.html
I dug into this a bit and shared some info in this Twitter thread. Here, I’d like to present my findings in a slightly more formal manner, and also offer some additional details.
Forcing HTTP Version with PHP cURL
Published: January 8, 2020
A colleague recently reported a strange bug to me:
I’m troubleshooting an issue where data fails to sync the a 3rd party and I’ve identified this error when curl_exec runs
HTTP2 framing layer error
From what I gather online is that this typically a somewhat generic error and could have multiple causes.
New Relic Alert When No Data is Received
Published: November 4, 2019
There is a known bug with the New Relic PHP agent that causes it to stop reporting data when it is upgraded.
When I ran into this recently it made me think, “it would be nice if I could have New Relic send me an alert when it stops receiving data from the application.”