-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running setup:config:set can crash in certain situations, seems to be bug introduced in Magento 2.4.1 #37409
Comments
Hi @hostep. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
After a git bisecting session, it seems like the issue was introduced by commit: ec098d2, now to figure out why exactly ... |
Okay, it has something to do with the class Injecting a proxy of the diff --git a/app/code/Magento/MediaContentSynchronization/etc/di.xml b/app/code/Magento/MediaContentSynchronization/etc/di.xml
index d4615c15206..100f364b305 100644
--- a/app/code/Magento/MediaContentSynchronization/etc/di.xml
+++ b/app/code/Magento/MediaContentSynchronization/etc/di.xml
@@ -14,6 +14,11 @@
</argument>
</arguments>
</type>
+ <type name="Magento\MediaContentSynchronization\Console\Command\Synchronize">
+ <arguments>
+ <argument name="synchronizeContent" xsi:type="object">Magento\MediaContentSynchronizationApi\Api\SynchronizeInterface\Proxy</argument>
+ </arguments>
+ </type>
<type name="Magento\MediaGallerySynchronization\Model\Consume">
<plugin name="synchronize_media_content"
type="Magento\MediaContentSynchronization\Plugin\SynchronizeMediaContent"/> Update: hmm, was testing this on an in-between commit between 2.4.0 and 2.4.1 and that solved the issue, but it didn't solve the issue on 2.4.1 nor 2.4-develop, grmbl, still digging around ... |
Okay, it was due to yet another command that was added that has the same problem. diff --git a/app/code/Magento/MediaContentSynchronization/etc/di.xml b/app/code/Magento/MediaContentSynchronization/etc/di.xml
index e5347f1a115..ed096340e70 100644
--- a/app/code/Magento/MediaContentSynchronization/etc/di.xml
+++ b/app/code/Magento/MediaContentSynchronization/etc/di.xml
@@ -15,6 +15,11 @@
</argument>
</arguments>
</type>
+ <type name="Magento\MediaContentSynchronization\Console\Command\Synchronize">
+ <arguments>
+ <argument name="synchronizeContent" xsi:type="object">Magento\MediaContentSynchronizationApi\Api\SynchronizeInterface\Proxy</argument>
+ </arguments>
+ </type>
<type name="Magento\MediaGallerySynchronization\Model\Consume">
<plugin name="synchronize_media_content"
type="Magento\MediaContentSynchronization\Plugin\SynchronizeMediaContent"/>
diff --git a/app/code/Magento/MediaGallerySynchronization/etc/di.xml b/app/code/Magento/MediaGallerySynchronization/etc/di.xml
index 82bd1303eda..2d793825b89 100644
--- a/app/code/Magento/MediaGallerySynchronization/etc/di.xml
+++ b/app/code/Magento/MediaGallerySynchronization/etc/di.xml
@@ -47,6 +47,11 @@
</argument>
</arguments>
</type>
+ <type name="Magento\MediaGallerySynchronization\Console\Command\Synchronize">
+ <arguments>
+ <argument name="synchronizeAssets" xsi:type="object">Magento\MediaGallerySynchronizationApi\Api\SynchronizeInterface\Proxy</argument>
+ </arguments>
+ </type>
<type name="Magento\Framework\App\Config\Value">
<plugin name="admin_system_config_adobe_stock_save_plugin" type="Magento\MediaGallerySynchronization\Plugin\MediaGallerySyncTrigger"/>
</type> I'll see if I can find some time next week for a PR ... |
Hi @engcom-November. Thank you for working on this issue.
|
Found some more time to dig into this, after going through dependencies of dependencies of dependencies, ..., it turned out that this fixes the issue as well: diff --git a/app/code/Magento/MediaContentCatalog/Model/ResourceModel/GetEntityContent.php b/app/code/Magento/MediaContentCatalog/Model/ResourceModel/GetEntityContent.php
index c3766484ce4..9136f245492 100644
--- a/app/code/Magento/MediaContentCatalog/Model/ResourceModel/GetEntityContent.php
+++ b/app/code/Magento/MediaContentCatalog/Model/ResourceModel/GetEntityContent.php
@@ -7,7 +7,6 @@ declare(strict_types=1);
namespace Magento\MediaContentCatalog\Model\ResourceModel;
-use Magento\Catalog\Model\ResourceModel\Product;
use Magento\Framework\App\ResourceConnection;
use Magento\MediaContentApi\Model\GetEntityContentsInterface;
use Magento\MediaContentApi\Api\Data\ContentIdentityInterface;
@@ -23,11 +22,6 @@ class GetEntityContent implements GetEntityContentsInterface
*/
private $config;
- /**
- * @var Product
- */
- private $productResource;
-
/**
* @var ResourceConnection
*/
@@ -36,15 +30,12 @@ class GetEntityContent implements GetEntityContentsInterface
/**
* @param Config $config
* @param ResourceConnection $resourceConnection
- * @param Product $productResource
*/
public function __construct(
Config $config,
- ResourceConnection $resourceConnection,
- Product $productResource
+ ResourceConnection $resourceConnection
) {
$this->config = $config;
- $this->productResource = $productResource;
$this->resourceConnection = $resourceConnection;
}
diff --git a/app/code/Magento/MediaGallerySynchronization/Model/SynchronizeFiles.php b/app/code/Magento/MediaGallerySynchronization/Model/SynchronizeFiles.php
index eebb172e482..01465eb2b27 100644
--- a/app/code/Magento/MediaGallerySynchronization/Model/SynchronizeFiles.php
+++ b/app/code/Magento/MediaGallerySynchronization/Model/SynchronizeFiles.php
@@ -12,7 +12,7 @@ use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\ReadInterface;
use Magento\Framework\Filesystem\Driver\File;
-use Magento\Framework\Stdlib\DateTime\DateTime;
+use Magento\Framework\Stdlib\DateTime\DateTimeFactory;
use Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface;
use Magento\MediaGallerySynchronizationApi\Model\ImportFilesInterface;
use Magento\MediaGallerySynchronizationApi\Api\SynchronizeFilesInterface;
@@ -60,14 +60,14 @@ class SynchronizeFiles implements SynchronizeFilesInterface
private $importFiles;
/**
- * @var DateTime
+ * @var DateTimeFactory
*/
- private $date;
+ private $dateFactory;
/**
* @param File $driver
* @param Filesystem $filesystem
- * @param DateTime $date
+ * @param DateTime $dateFactory
* @param LoggerInterface $log
* @param GetFileInfo $getFileInfo
* @param GetAssetsByPathsInterface $getAssetsByPaths
@@ -76,7 +76,7 @@ class SynchronizeFiles implements SynchronizeFilesInterface
public function __construct(
File $driver,
Filesystem $filesystem,
- DateTime $date,
+ DateTimeFactory $dateFactory,
LoggerInterface $log,
GetFileInfo $getFileInfo,
GetAssetsByPathsInterface $getAssetsByPaths,
@@ -84,7 +84,7 @@ class SynchronizeFiles implements SynchronizeFilesInterface
) {
$this->driver = $driver;
$this->filesystem = $filesystem;
- $this->date = $date;
+ $this->dateFactory = $dateFactory;
$this->log = $log;
$this->getFileInfo = $getFileInfo;
$this->getAssetsByPaths = $getAssetsByPaths;
@@ -148,7 +148,7 @@ class SynchronizeFiles implements SynchronizeFilesInterface
*/
private function getFileModificationTime(string $path): string
{
- return $this->date->gmtDate(
+ return $this->dateFactory->create()->gmtDate(
self::DATE_FORMAT,
$this->getFileInfo->execute($this->getMediaDirectory()->getAbsolutePath($path))->getMTime()
); Both these dependencies made somehow a connection to the database from within their constructor (or dependency parent constructors), and that is really not needed at the time of the constructor. In case of the |
Hi @hostep
|
✅ Jira issue https://jira.corp.adobe.com/browse/AC-8607 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-November. Thank you for verifying the issue. |
Preconditions and environment
2.4-develop
is impactedSteps to reproduce
app/etc/env.php
and search for the correct db username in thedb/connection/default/username
pathapp/etc/env.php
file and change thedb/connection/default/username
to a non-existing database user (usingwrong-user
in example below)bin/magento setup:config:set -n --db-user=xxx
(where you replacexxx
with the correct database user you found in step 2)app/etc/env.php
file afterwards to see if the username got updated correctlyExpected result
Actual result
Additional information
We have a certain workflow where we expect to have a wrong db user in the
app/etc/env.php
file and expect it to be able to change it without errors usingbin/magento setup:config:set
This used to work before Magento 2.4.1, but seems to have been broken ever since Magento 2.4.1, which is kind of annoying for us.
It looks like the config change does work in that command, but the updated configuration isn't being reloaded before it tries to do whatever it crashes on a bit later.
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: