Recent Posts


Validating a Magento Connect Extension


Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

This entry is part 35 of 43 in the series Miscellaneous Magento Articles. Earlier posts include Magento Front Controller, Reinstalling Magento Modules, Clearing the Magento Cache, Magento's Class Instantiation Abstraction and Autoload, Magento Development Environment, Logging Magento's Controller Dispatch, Magento Configuration Lint, Slides from Magento Developer's Paradise, Generated Magento Model Code, Magento Knowledge Base, Magento Connect Role Directories, Magento Base Directories, PHP Error Handling and Magento Developer Mode, Magento Compiler Mode, Magento: Standard OOP Still Applies, Magento: Debugging with Varien Object, Generating Google Sitemaps in Magento, IE9 fix for Magento, Magento's Many 404 Pages, Magento Quickies, Commerce Bug in Magento CE 1.6, Welcome to Magento: Pre-Innovate, Magento's Global Variable Design Patterns, Magento 2: Factory Pattern and Class Rewrites, Magento Block Lifecycle Methods, Goodnight and Goodluck, Magento Attribute Migration Generator, Fixing Magento Flat Collections with Chaos, Pulse Storm Launcher in Magento Connect, StackExchange and the Year of the Site Builder, Scaling Magento at Copious, Incremental Migration Scripts in Magento, A Better Magento 404 Page, and Anatomy of the Magento PHP 5.4 Patch. Later posts include Magento Cross Area Sessions, Review of Grokking Magento, Imagine 2014: Magento 1.9 Infinite Theme Fallback, Magento Ultimate Module Creator Review, Magento Imagine 2014: Parent/Child Themes, Early Magento Session Instantiation is Harmful, Using Squid for Local Hostnames on iPads, and Magento, Varnish, and Turpentine.

If you’ve followed my work here, on Stack Overflow, or on Twitter, you know I have a perpetual bee in my bonnet over Magento Connect’s file permissions issues. There’s a few common cases where Magento Connect will tell you an extension is installed, but in actuality Connect couldn’t install the extension because of insufficient file permissions. Permissions are always a thorn in a developer’s side — but the Connect application’s willingness to lie to its users about an extension being installed crosses some invisible line of unacceptable behavior.

The Magento 2 team at eBay is aware of the problem, and working on it, but that leaves working Magento developers with the problem of never knowing what’s actually installed when clients or customers use Magento Connect. That’s why I’ve created a new command for n98-magerun called extension:validate. Today we’ll cover how to use the command, as well as discuss some implementation details so you understand what the command is doing.

Using the Command

The extension:validate command requires no arguments. If you run it you’ll see something like this

$ n98-magerun extension:validate




Problem: /path/to/magento/app/code/community/Webshopapps/Matrixrate/etc/config.xml
    Hash: MISMATCH
Problem: /path/to/magento/app/etc/modules/Webshopapps_Matrixrate.xml

When invoked with no options, extension:validate will look at all the third party Magento Connect extensions a user has installed on their system, and validate their contents against the package.xml manifest.

In the above example, our system has the Magento Connect extensions Customchecoutstep, Pulsestorm_Commercebug, and Auctionmaid_Matrxrate installed. Customchecoutstep and Pulsestorm_Commercebug were fine, but the Auctionmaid_Matrxrate was missing a file (Webshopapps_Matrixrate.xml), and one of the files didn’t match the stored hash (config.xml). Not matching the stored hash means the file’s been modified/edited.

Troubleshooting Connect Details

While this tool is useful, it’s not a cure all. Once you’ve detected problems with an extension you’ll need to figure out why they happened. In other words, are they real problems or intended changes from more reckless developers. There’s a good chance the original package for an extension will be in the


folder. This where Magento Connect downloads the packages prior to installing them. Copying a package from here and extracting the files will let you replace missing files or run a diff to see what’s changed.

The extension:validate command reads the package information from the


file. Despite being named cache.cfg, this really isn’t a cache file — it’s the file Magento Connect reads from when it lists out the installed packages on the system, and effectively acts as the source of truth for what is and isn’t installed.

If I speculate, the reason this file is named cache is it’s a cached list of what’s installed on the system. In other words the entire Magento system itself is the actual thing, and this file is just a cache. However, this falls apart when you consider there’s no way to query the Magento system itself for a list of installed packages, and the Magento Connect downloader always reads from this file. Another example of “The best laid plans …” problem.

Command Options

The extension:validate command will also let you check a single extension. Just pass in the extension’s name as the first argument

$ n98-magerun extension:validate Auctionmaid_Matrxrate


Problem: /path/to/magento/app/code/community/Webshopapps/Matrixrate/etc/config.xml
    Hash: MISMATCH
Problem: /path/to/magento/app/etc/modules/Webshopapps_Matrixrate.xml

This is useful to run right after you’ve installed an extension to make sure it’s installed correctly. Keep in mind you need to use the Magento Connect Name for an extension, and not the Namespace_Modulename module name. (Auctionmaid_Matrxrate vs Webshopapps_Matrixrate above)

If you only want to do a specific type of check — that is only check if a file is missing, or if the hash matches — there’s options to skip each test type.

$ n98-magerun help extension:validate
 --skip-file           If set, command will skip reporting the existence of package files
 --skip-hash           If set, command will skip validating the package file hashes

You use them like this.

n98-magerun extension:validate --skip-file 
n98-magerun extension:validate --skip-hash

n98-magerun extension:validate Auctionmaid_Matrxrate --skip-file 
n98-magerun extension:validate Auctionmaid_Matrxrate --skip-hash

There’s also the --full-report command which will list all the files for an extension — not just the problematic ones.

$ n98-magerun extension:validate Auctionmaid_Matrxrate --full-report


Checking: /path/to/magento/app/code/community/Webshopapps/Matrixrate/Block/Adminhtml/Shipping/Carrier/Matrixrate/Grid.php
    Path: OK
    Hash: OK
Checking: /path/to/magento/app/code/community/Webshopapps/Matrixrate/Block/Adminhtml/System/Config/Form/Field/Exportmatrix.php
    Path: OK
    Hash: OK
Checking: /path/to/magento/app/etc/modules/Webshopapps_Matrixrate.xml
Problem: /path/to/magento/app/etc/modules/Webshopapps_Matrixrate.xml

Useful if you’re curious what, exactly, a Magento Connect package has dropped on your server.

Magento Connect for Upgrades

In addition to installing third party extensions, Magento Connect’s other big feature is enabling package based updates of the Magento system itself. It does this by having the following 36 packages installed by default when you initialize a Magento Connect system.


This has always struck me as a little bit crazy. Because Magento Connect installations aren’t transactional, this creates a situation where an install that fails due to network connectivity issues or un-handled corner cases can leave a Magento installation in a “half-upgraded” state. If you’ve spent any time on the Magento forums or the various Stack Exchange sites, you know this is more than a theoretically concern.

Regardless, if you or your client are managing upgrades via Magento Connect, you may include these packages with the --include-default flag.

$ n98-magerun extension:validate --include-default

Be warned though, since it’s effectively running through every Connect managed file in your Magento application it’ll take a bit longer to finish. This is also a potentially useful way to keep your application “core hack” free. Finally, these extension names are hard-coded into the extension:validate command. If Magento adds any packages in the future, extension:validate will see them as 3rd party extensions until the n98-magerun command is updated with a new extension list. If anyone know a way to query something for a list of official packages, pull requests are welcome.

Wrap Up

The extension:validate command is available in the develop branch of the n98-magerun source. It looks like the application is getting monthly-ish releases, so this should be available in the official release soon. If you run into problems or have feature suggestions, please let me know.

Originally published June 9, 2014
Series Navigation<< Anatomy of the Magento PHP 5.4 PatchMagento Cross Area Sessions >>

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 9th June 2014

email hidden; JavaScript is required