eCommerce

Upgrading Magento 2 Safely: Extensions, Themes and Security Patches

Most Magento 2 upgrades go wrong in the same places: an extension that replaces core code, a theme template copied years ago, or a server a PHP version behind. Here is how we plan a 2.4.x upgrade, test it, and keep security patches flowing afterwards.

Gloved hand welding a metal panel with a gas torch, sparks glowing at the joint

A Magento 2 store that has fallen a few releases behind is in an awkward spot. Every security bulletin from Adobe is a reminder that it needs patching, but the last upgrade broke the checkout for a day, the agency that installed half the extensions has moved on, and nobody is quite sure what the theme overrides. So the upgrade waits, and the gap grows.

Much of our Magento and Adobe Commerce development work involves upgrades like this. The core platform upgrades reasonably well; what breaks is the code layered on top of it. This is the process we follow to move a store to a current 2.4.x release and keep it there.

Why Staying Current Is Not Optional

Adobe supports each 2.4 minor release for a fixed period and only publishes security fixes for releases still inside that window. Once your version drops out of support, newly discovered vulnerabilities simply stay open on your store. Magento is a well-known target: the CosmicSting flaw disclosed in 2024 (CVE-2024-34102) let attackers read files from unpatched servers, including the configuration file that holds the store's encryption key, and it was exploited widely within weeks.

Staying current also matters for the stack underneath. Each 2.4 release supports a specific range of PHP, MySQL or MariaDB, OpenSearch, Redis, Varnish and Composer versions. Fall far enough behind and your hosting provider retires the PHP version your store needs, which turns a planned upgrade into an emergency. Adobe's system requirements page for your target release is the first thing we read.

Step One: Audit What Is Actually Installed

Before choosing a target version, we build an inventory of everything that is not core Magento:

  • Composer packages. Every third-party module, its installed version, and whether the vendor has released a version that declares support for your target Magento and PHP versions.
  • Code in app/code. Modules dropped in by hand, often copies of marketplace extensions that can no longer be updated through Composer. These cause the most surprises.
  • Preferences and plugins. We search every di.xml for preference entries that replace core classes. A preference swaps out a whole class, so any fix Adobe makes to the original is silently lost. Plugins are far safer, but plugins on methods whose signatures changed will still fail.
  • Theme overrides. Every template, layout XML and JavaScript file the theme copies from a core module.
  • Patches already applied. Hotfixes applied by hand or through composer-patches, which may conflict with, or already be included in, the new release.
  • Integrations. ERP, PIM, payment, shipping and marketplace connections that call the REST or GraphQL APIs.

On Adobe Commerce, the Upgrade Compatibility Tool automates part of this by flagging custom code that uses deprecated or removed core APIs for a chosen target version. Any extension whose vendor has disappeared, or which has not been updated in years, gets a decision: replace it, rewrite the small part you actually use as your own module, or remove it. Removing unused modules is often the cheapest performance gain in the project, as we explain in our Magento 2 performance tuning guide.

Themes: Where Old Overrides Hide

A theme that overrides a core template keeps a frozen copy of it. When Adobe later fixes a bug or adds a field in the original, your copy does not get the change. After several releases, checkout and customer account templates in particular can drift far enough that features break quietly: a missing form key, output that is no longer escaped, a JavaScript component expecting markup that is no longer there.

For every overridden file we compare the theme's copy with the original from the version it was copied from, then with the target version, and reapply only the deliberate customisation.

Luma-based themes also feel the effect of JavaScript libraries upgraded inside Magento, such as jQuery, jQuery UI and TinyMCE, so custom widgets and admin WYSIWYG content need checking. Hyvä-based themes avoid most of the RequireJS and Knockout layer, but every extension with a front-end component needs a Hyvä compatibility module, and those need updating too. Since 2.4.7, Magento also enforces a restrictive Content Security Policy on checkout payment pages to support PCI DSS 4.0, so tag managers, chat widgets and analytics scripts on checkout must be explicitly allowed or they will be blocked.

Running the Upgrade on Staging

We never run an upgrade for the first time on production. The sequence on a staging copy usually looks like this:

  1. Copy production code and database to staging, with customer personal data anonymised, and match the target PHP, database and search engine versions.
  2. Update the Magento metapackage and extension versions in composer.json, then let Composer resolve dependencies. Conflicts here are useful information: each points at an extension that is not ready.
  3. Run bin/magento setup:upgrade to apply schema and data patches, then setup:di:compile and setup:static-content:deploy for each locale. Compilation errors are where incompatible plugins and preferences show up.
  4. Reindex, flush caches, and confirm cron and the message queue consumers are running.
  5. Work through a written regression checklist.

Jumping several minor versions in one go is usually fine for the core, because Magento applies each schema and data patch in order. Extensions sometimes need intermediate versions, so the Composer step may have to be done in stages.

What We Test Before Go-Live

  • Checkout with every payment method, including 3D Secure challenges, saved cards and express buttons such as PayPal or Apple Pay.
  • Tax and shipping for each store view, country and customer group, plus coupons and cart price rules.
  • Transactional emails, invoices and credit memos.
  • Search results and layered navigation after a full reindex.
  • The admin tasks your team does daily: creating orders, editing products, imports and exports.
  • Every API integration, end to end, against the staging store.

Go-live is then a short maintenance window: a fresh database backup, deployment of the tested build, setup:upgrade against live data, and a smoke test. With a build step that compiles code and static content before the switch, downtime stays at minutes. The rollback plan, a database snapshot plus the previous release kept on disk, is written down before anyone starts.

Keeping Patched Between Upgrades

Once a store is on a supported release, the aim is never to fall behind again:

  • Apply security patch releases (the -p1, -p2 versions) soon after Adobe's bulletin, through the same staging process with a shorter checklist.
  • Use Adobe's Quality Patches Tool for specific known bugs rather than hand-editing vendor code.
  • Plan a minor-version upgrade once a year, well before the current line leaves support.
  • Keep admin two-factor authentication on, use a non-default admin path, and patch the server software underneath.
  • Monitor for unexpected file changes and new admin users, which are early signs of compromise.

This is ongoing maintenance and support rather than a one-off project, and on the server side it overlaps with our hosting and server management. If a store has already been compromised, patching alone is not enough; it needs a proper clean-up and security review first.

When an Upgrade Is the Wrong Answer

Sometimes the audit shows that the store would need most of its extensions replaced and its theme rebuilt just to reach a supported version. At that point it is worth comparing the cost with moving platform. For smaller catalogues without complex B2B rules, our Magento to Shopify migration guide covers what that involves. For stores that genuinely need Magento's flexibility, a clean upgrade with fewer, better-maintained extensions is usually the stronger long-term position.

If your store is several releases behind, or you are not sure which version you are running, send us your composer.json and the version shown in the admin footer. We will tell you what the upgrade path looks like and where the risk sits.

Frequently Asked Questions

How long does a Magento 2 upgrade usually take?

It depends far more on the extensions and theme than on Magento itself. A store with a handful of well-maintained Composer extensions and a lightly customised theme can often be upgraded and tested within a couple of weeks. A store with hand-installed modules, many template overrides and several integrations takes longer, because each of those has to be checked, updated or replaced before go-live.

Can we apply security patches without doing a full upgrade?

Only while your 2.4 minor release is still inside Adobe's support window; patch releases such as 2.4.7-p3 are the security route for supported lines. For older, unsupported versions Adobe occasionally publishes isolated patches for severe issues, but relying on those is not a plan. Once a release leaves support, the safe option is to upgrade to a supported one.

Will upgrading Magento affect our search rankings?

A version upgrade does not change product or category URLs, because the URL rewrites stay in the database. Rankings are at risk only if something breaks along the way, such as a theme change removing structured data, a misconfigured robots setting on staging copied to live, or a slow front end. We check those as part of the regression tests.

Should we move to the Hyvä theme at the same time as upgrading?

We usually keep them as separate projects. An upgrade is easier to test when the front end stays the same, so any problem can be traced to the new version. Once the store is on a supported release, a Hyvä rebuild can follow as its own project with its own testing, often with a clear performance benefit.

Is the upgrade process different for Adobe Commerce and Magento Open Source?

The core process is the same: Composer, setup:upgrade, compilation and testing. Adobe Commerce adds licensed features such as B2B modules that need their own regression tests, access to the Upgrade Compatibility Tool, and, on Adobe Commerce Cloud, a deployment pipeline with its own tooling and environment rules.

How We Can Help

Services Related to This Article

The work we do with the technologies discussed above — with pricing, process and real examples on each page.

  • Magento & Adobe Commerce

    Magento Open Source and Adobe Commerce builds, custom modules, B2B and multi-store setups, performance tuning and upgrades from Magento 1.

  • Website Maintenance & Support

    Proactive updates, backups, monitoring and on-demand fixes that keep your website secure, fast and always online.

  • Hosting, Server & DNS Management

    Nginx, Apache, Docker and cloud servers configured, secured and kept running — plus DNS, SSL and Cloudflare set up correctly the first time.

  • Hacked Website Cleanup & Security

    Malware removed, the entry point closed, blacklists cleared and the site hardened so it does not happen again — usually within a day.

In Practice

Case Studies on This Topic

Projects where we put these ideas to work, each with a live demo.

  • Gears Chains — Hartwell Industrial
    • Magento 2
    • PHP 8
    • MySQL

    Magento eCommerce

    Industrial Parts B2B Store

    An 84,000-SKU Magento 2 store with contract pricing, quick order and ERP-synced stock for trade accounts.

  • Living Room — Ashcroft Lettings
    • Laravel
    • PHP 8
    • Blade & Livewire

    Web Application Development

    Property Management & Tenant Portal

    A Laravel platform managing 1,140 units — tenancies, maintenance jobs, contractor scheduling and owner statements.

  • Free big open, multiple level — Faculty of Science
    • Drupal 10
    • PHP 8
    • Twig

    Drupal Website

    University Faculty & Research Portal

    A multilingual Drupal portal for 6,800 pages, 140 editors and three languages, built to WCAG 2.2 AA.

Keep Reading

  • Illustrated icons for a MySQL database, REST APIs, third-party integrations and cloud deployment

    Firebase Authentication: Sign-In Methods, Account Linking and Security

    Firebase Authentication is quick to add but its early decisions are hard to undo. Here is how we choose sign-in methods, link accounts so one person has one login, use tokens and custom claims safely, and harden sign-in against abuse.

  • Tablet on a wooden table showing an app dashboard with charts, beside a phone and a white coffee cup

    Adding Kotlin Multiplatform to an Existing Android App

    If you have a mature Kotlin Android app and an iOS app that keeps falling behind, Kotlin Multiplatform lets you share the logic without a rewrite. Here is what moves, which dependencies need replacing and the gradual path we follow.

  • Person typing on a laptop at an outdoor wooden table, with a smartphone, notebook and pen beside it

    Native Device Features in an Ionic App: Camera, Location, Push and Files

    Capacitor gives an Ionic app access to the camera, location, push notifications and the file system, but each comes with permissions, platform differences and store rules. Here is how we make these four features reliable on real devices.

Let’s Connect

Let’s Build Something Amazing Together

Share your project details and our experts will get back to you within one business day with the best solution — free consultation, no obligation.