magemojo/m2-ce-cron

Cannot "setup:install" new Magento app with module installed

mattwellss opened this issue · 6 comments

Requested info Value
Magento version 2.2.8
executed ./bin/magento setup:install
expected Fresh Magento app installed
actual [PDOException]...Base table or view not found: 1146 Table 'lfidb.core_config_data' doesn't exist

The problem is MageMojo\Cron\Model\Schedule requests core_config_data information eagerly. This can be mitigated by creating a preference for that class as a proxy:

<preference for="MageMojo\Cron\Model\Schedule" type="MageMojo\Cron\Model\Schedule\Proxy" />

This also causes integration tests to fail.

My recommendation above caused an infinite loop 😨. This is how we've patched it ourselves:

diff --git a/etc/di.xml b/etc/di.xml
index f74cbee9..c86efc49 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -15,5 +15,16 @@
             </argument>
         </arguments>
     </type>
+    <type name="MageMojo\Cron\Console\Command\CronCommand">
+        <arguments>
+            <argument name="schedule" xsi:type="object">MageMojo\Cron\Model\Schedule\Proxy</argument>
+        </arguments>
+    </type>
+
+    <type name="MageMojo\Cron\Console\Command\CronExecuteCommand">
+        <arguments>
+            <argument name="schedule" xsi:type="object">MageMojo\Cron\Model\Schedule\Proxy</argument>
+        </arguments>
+    </type>
 </config>

@mattwellss @lukeconvertdigital We're not able to reproduce on default 2.2.8. What other extensions are in your installation?

cc @gnuzealot

@ericvhileman to clarify: you can first install this module and then initialize the database?

In my experience, both the cron commands listed here read from core_config_data during their construction (or rather, one of their dependencies does). As such, when they're constructed as part of the CLI application init, a PDOException occurs, caused by the missing table.

@mattwellss we cannot reproduce on Open Source 2.2.8. Are you using Open Source or Commerce?

This was resolved in latest version.