Skip to content

Commit f0c7398

Browse files
committed
Remove obsolete ResourceModel\Product dependency and reworked DateTime to DateTimeFactory. Both of these caused unnecessary connections to be made to the database when executing bin/magento commands.
1 parent 9c0e123 commit f0c7398

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

app/code/Magento/MediaContentCatalog/Model/ResourceModel/GetEntityContent.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\MediaContentCatalog\Model\ResourceModel;
99

10-
use Magento\Catalog\Model\ResourceModel\Product;
1110
use Magento\Framework\App\ResourceConnection;
1211
use Magento\MediaContentApi\Model\GetEntityContentsInterface;
1312
use Magento\MediaContentApi\Api\Data\ContentIdentityInterface;
@@ -23,11 +22,6 @@ class GetEntityContent implements GetEntityContentsInterface
2322
*/
2423
private $config;
2524

26-
/**
27-
* @var Product
28-
*/
29-
private $productResource;
30-
3125
/**
3226
* @var ResourceConnection
3327
*/
@@ -36,15 +30,12 @@ class GetEntityContent implements GetEntityContentsInterface
3630
/**
3731
* @param Config $config
3832
* @param ResourceConnection $resourceConnection
39-
* @param Product $productResource
4033
*/
4134
public function __construct(
4235
Config $config,
43-
ResourceConnection $resourceConnection,
44-
Product $productResource
36+
ResourceConnection $resourceConnection
4537
) {
4638
$this->config = $config;
47-
$this->productResource = $productResource;
4839
$this->resourceConnection = $resourceConnection;
4940
}
5041

app/code/Magento/MediaGallerySynchronization/Model/SynchronizeFiles.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Magento\Framework\Filesystem;
1313
use Magento\Framework\Filesystem\Directory\ReadInterface;
1414
use Magento\Framework\Filesystem\Driver\File;
15-
use Magento\Framework\Stdlib\DateTime\DateTime;
15+
use Magento\Framework\Stdlib\DateTime\DateTimeFactory;
1616
use Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface;
1717
use Magento\MediaGallerySynchronizationApi\Model\ImportFilesInterface;
1818
use Magento\MediaGallerySynchronizationApi\Api\SynchronizeFilesInterface;
@@ -60,14 +60,14 @@ class SynchronizeFiles implements SynchronizeFilesInterface
6060
private $importFiles;
6161

6262
/**
63-
* @var DateTime
63+
* @var DateTimeFactory
6464
*/
65-
private $date;
65+
private $dateFactory;
6666

6767
/**
6868
* @param File $driver
6969
* @param Filesystem $filesystem
70-
* @param DateTime $date
70+
* @param DateTime $dateFactory
7171
* @param LoggerInterface $log
7272
* @param GetFileInfo $getFileInfo
7373
* @param GetAssetsByPathsInterface $getAssetsByPaths
@@ -76,15 +76,15 @@ class SynchronizeFiles implements SynchronizeFilesInterface
7676
public function __construct(
7777
File $driver,
7878
Filesystem $filesystem,
79-
DateTime $date,
79+
DateTimeFactory $dateFactory,
8080
LoggerInterface $log,
8181
GetFileInfo $getFileInfo,
8282
GetAssetsByPathsInterface $getAssetsByPaths,
8383
ImportFilesInterface $importFiles
8484
) {
8585
$this->driver = $driver;
8686
$this->filesystem = $filesystem;
87-
$this->date = $date;
87+
$this->dateFactory = $dateFactory;
8888
$this->log = $log;
8989
$this->getFileInfo = $getFileInfo;
9090
$this->getAssetsByPaths = $getAssetsByPaths;
@@ -148,7 +148,7 @@ private function getPathsToUpdate(array $paths): array
148148
*/
149149
private function getFileModificationTime(string $path): string
150150
{
151-
return $this->date->gmtDate(
151+
return $this->dateFactory->create()->gmtDate(
152152
self::DATE_FORMAT,
153153
$this->getFileInfo->execute($this->getMediaDirectory()->getAbsolutePath($path))->getMTime()
154154
);

0 commit comments

Comments
 (0)