Skip to content

Commit 8a4610e

Browse files
oshmyheliukshiftedreality
authored andcommitted
MAGECLOUD-3866: Warm up functionality does not work if no store with 'default' code (#560)
1 parent 775c310 commit 8a4610e

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

src/Process/PostDeploy/WarmUp/UrlsPattern.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ public function get(string $warmUpPattern): array
5959
list($entity, $pattern, $storeId) = explode(':', $warmUpPattern);
6060

6161
$command = 'config:show:urls';
62-
$commandArguments = [sprintf('--entity-type="%s"', $entity)];
62+
$commandArguments = [sprintf('--entity-type=%s', $entity)];
6363
if ($storeId && $storeId !== '*') {
64-
$commandArguments [] = sprintf('--store-id="%s"', $storeId);
64+
$commandArguments [] = sprintf('--store-id=%s', $storeId);
6565
}
6666

6767
$process = $this->magentoShell->execute($command, $commandArguments);

src/Test/Unit/Process/PostDeploy/WarmUp/UrlsPatternTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ public function getDataProvider(): array
8282
[
8383
'category:*:1',
8484
[
85-
'--entity-type="category"',
86-
'--store-id="1"'
85+
'--entity-type=category',
86+
'--store-id=1'
8787
],
8888
[],
8989
[],
9090
],
9191
[
9292
'category:*:*',
93-
['--entity-type="category"'],
93+
['--entity-type=category'],
9494
[
9595
'http://site1.com/category1',
9696
'http://site1.com/category2',
@@ -102,7 +102,7 @@ public function getDataProvider(): array
102102
],
103103
[
104104
'category:/category.*/:*',
105-
['--entity-type="category"'],
105+
['--entity-type=category'],
106106
[
107107
'http://site1.com/category1',
108108
'http://site1.com/category2',
@@ -116,7 +116,7 @@ public function getDataProvider(): array
116116
],
117117
[
118118
'category:cat1:*',
119-
['--entity-type="category"'],
119+
['--entity-type=category'],
120120
[
121121
'http://site1.com/category1',
122122
'http://site1.com/cat1',
@@ -152,7 +152,7 @@ public function testGetNotValidJsonReturned()
152152
->willReturn('wrong_json');
153153
$this->magentoShellMock->expects($this->once())
154154
->method('execute')
155-
->with('config:show:urls', ['--entity-type="category"'])
155+
->with('config:show:urls', ['--entity-type=category'])
156156
->willReturn($processMock);
157157
$this->loggerMock->expects($this->once())
158158
->method('error')

src/Test/Unit/Util/UrlManagerTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public function testGetBaseUrl()
376376

377377
$this->magentoShellMock->expects($this->once())
378378
->method('execute')
379-
->with('config:show:store-url default')
379+
->with('config:show:default-url')
380380
->willReturn($processMock);
381381

382382
$this->environmentMock->expects($this->never())
@@ -397,7 +397,7 @@ public function testExpandUrl()
397397

398398
$this->magentoShellMock->expects($this->once())
399399
->method('execute')
400-
->with('config:show:store-url default')
400+
->with('config:show:default-url')
401401
->willReturn($processMock);
402402

403403
$this->assertSame('https://example.com/products/123', $this->manager->expandUrl('/products/123'));
@@ -461,12 +461,24 @@ public function testGetBaseUrlWithEmptyStoreUrls()
461461

462462
$this->magentoShellMock->expects($this->once())
463463
->method('execute')
464-
->with('config:show:store-url default')
464+
->with('config:show:default-url')
465465
->willThrowException(new ShellException('some error'));
466466

467467
$this->environmentMock->expects($this->once())
468468
->method('getRoutes')
469469
->willReturn(['http://example.com/' => ['original_url' => 'https://{default}', 'type' => 'upstream']]);
470+
$this->loggerMock->expects($this->once())
471+
->method('error')
472+
->with(
473+
'Cannot fetch base URL using the config:show:default-url command. ' .
474+
'Instead, using the URL from the MAGENTO_CLOUD_ROUTES variable.'
475+
);
476+
$this->loggerMock->expects($this->exactly(2))
477+
->method('debug')
478+
->withConsecutive(
479+
['some error'],
480+
[$this->anything()]
481+
);
470482

471483
$this->assertEquals(
472484
'https://example.com/',

src/Util/UrlManager.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,15 @@ public function getBaseUrl(): string
155155
{
156156
if ($this->baseUrl === null) {
157157
try {
158-
$process = $this->magentoShell->execute('config:show:store-url default');
158+
$process = $this->magentoShell->execute('config:show:default-url');
159159

160160
$this->baseUrl = $process->getOutput();
161161
} catch (ShellException $e) {
162-
$this->logger->error('Can\'t fetch base url. ' . $e->getMessage());
162+
$this->logger->error(
163+
'Cannot fetch base URL using the config:show:default-url command. ' .
164+
'Instead, using the URL from the MAGENTO_CLOUD_ROUTES variable.'
165+
);
166+
$this->logger->debug($e->getMessage());
163167
$this->baseUrl = $this->getSecureUrls()[''];
164168
}
165169
}

0 commit comments

Comments
 (0)