Skip to content

Fix for running bin/magento without proper database connection (removes db connection attempts from DI constructors) #37424

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

Closed
wants to merge 6 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

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;
Expand All @@ -23,11 +22,6 @@ class GetEntityContent implements GetEntityContentsInterface
*/
private $config;

/**
* @var Product
*/
private $productResource;

/**
* @var ResourceConnection
*/
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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;
Expand Down Expand Up @@ -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 DateTimeFactory $dateFactory
* @param LoggerInterface $log
* @param GetFileInfo $getFileInfo
* @param GetAssetsByPathsInterface $getAssetsByPaths
Expand All @@ -76,15 +76,15 @@ class SynchronizeFiles implements SynchronizeFilesInterface
public function __construct(
File $driver,
Filesystem $filesystem,
DateTime $date,
DateTimeFactory $dateFactory,
LoggerInterface $log,
GetFileInfo $getFileInfo,
GetAssetsByPathsInterface $getAssetsByPaths,
ImportFilesInterface $importFiles
) {
$this->driver = $driver;
$this->filesystem = $filesystem;
$this->date = $date;
$this->dateFactory = $dateFactory;
$this->log = $log;
$this->getFileInfo = $getFileInfo;
$this->getAssetsByPaths = $getAssetsByPaths;
Expand Down Expand Up @@ -148,7 +148,7 @@ private function getPathsToUpdate(array $paths): array
*/
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()
);
Expand Down