Skip to content

Magento 2.4: Unable to apply setup/src/Magento/Setup patch

I’m trying to apply a patch but it’s not working:

composer.json

"patches": {
    "magento/setup": {
        "Setup Patch Take4": "patches/composer/setup_patch.patch"
    }
}

setup_patch.patch

diff --git a/Model/Installer.php b/Model/Installer.php
index ddd1ab51a..b9175dbad 100644
--- a/Model/Installer.php
+++ b/Model/Installer.php
@@ -1047,7 +1047,7 @@ class Installer
             }
             $schemaListener->setModuleName($moduleName);
             $this->log->log("Module '{$moduleName}':");
-            $configVer = $this->moduleList->getOne($moduleName)['setup_version'];
+            $configVer = $this->moduleList->getOne($moduleName) ? $this->moduleList->getOne($moduleName)['setup_version'] : null;
             $currentVersion = $moduleContextList[$moduleName]->getVersion();
             // Schema/Data is installed
             if ($configVer !== null && $currentVersion !== '') {

patched file path:
magento24/setup/src/Magento/Setup/Model/Installer.php