Skip to content

Commit 52df1e5

Browse files
author
Oleksii Korshenko
committed
Merge remote-tracking branch 'mainline/2.2-develop' into MAGETWO-71174
2 parents ed3927f + 22b7543 commit 52df1e5

File tree

13 files changed

+192
-14
lines changed

13 files changed

+192
-14
lines changed

app/code/Magento/Customer/Model/Address.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,7 @@ public function reindex()
377377
{
378378
/** @var \Magento\Framework\Indexer\IndexerInterface $indexer */
379379
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
380-
if (!$indexer->isScheduled()) {
381-
$indexer->reindexRow($this->getCustomerId());
382-
}
380+
$indexer->reindexRow($this->getCustomerId());
383381
}
384382

385383
/**

app/code/Magento/Customer/Model/Customer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,9 +1154,7 @@ public function reindex()
11541154
{
11551155
/** @var \Magento\Framework\Indexer\IndexerInterface $indexer */
11561156
$indexer = $this->indexerRegistry->get(self::CUSTOMER_GRID_INDEXER_ID);
1157-
if (!$indexer->isScheduled()) {
1158-
$indexer->reindexRow($this->getId());
1159-
}
1157+
$indexer->reindexRow($this->getId());
11601158
}
11611159

11621160
/**

app/code/Magento/Deploy/Model/Mode.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\Config\File\ConfigFilePool;
1515
use Symfony\Component\Console\Input\InputInterface;
1616
use Symfony\Component\Console\Output\OutputInterface;
17+
use Magento\Framework\Exception\LocalizedException;
1718

1819
/**
1920
* A class to manage Magento modes
@@ -82,14 +83,24 @@ public function __construct(
8283
/**
8384
* Enable production mode
8485
*
86+
* @throws LocalizedException
8587
* @return void
8688
* @since 2.0.0
8789
*/
8890
public function enableProductionMode()
8991
{
9092
$this->enableMaintenanceMode($this->output);
91-
$this->filesystem->regenerateStatic($this->output);
92-
$this->setStoreMode(State::MODE_PRODUCTION);
93+
$previousMode = $this->getMode();
94+
try {
95+
// We have to turn on production mode before generation.
96+
// We need this to enable generation of the "min" files.
97+
$this->setStoreMode(State::MODE_PRODUCTION);
98+
$this->filesystem->regenerateStatic($this->output);
99+
} catch (LocalizedException $e) {
100+
// We have to return store mode to previous state in case of error.
101+
$this->setStoreMode($previousMode);
102+
throw $e;
103+
}
93104
$this->disableMaintenanceMode($this->output);
94105
}
95106

app/code/Magento/Deploy/Test/Unit/Model/ModeTest.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use PHPUnit_Framework_MockObject_MockObject as Mock;
1515
use Symfony\Component\Console\Input\InputInterface;
1616
use Symfony\Component\Console\Output\OutputInterface;
17+
use Magento\Framework\Config\File\ConfigFilePool;
18+
use Magento\Framework\Exception\LocalizedException;
1719

1820
/**
1921
* @inheritdoc
@@ -96,4 +98,71 @@ public function testGetMode()
9698
$this->assertSame(null, $this->model->getMode());
9799
$this->assertSame(State::MODE_DEVELOPER, $this->model->getMode());
98100
}
101+
102+
/**
103+
* Test that production mode will be enabled before static generation call.
104+
* We need this to be sure that "min" files will be generated.
105+
*/
106+
public function testEnableProductionMode()
107+
{
108+
$mode = State::MODE_DEVELOPER;
109+
$modeModel = $this->model;
110+
$dataStorage = [
111+
ConfigFilePool::APP_ENV => [
112+
State::PARAM_MODE => State::MODE_DEVELOPER,
113+
],
114+
];
115+
$this->writerMock->expects($this->once())
116+
->method("saveConfig")
117+
->willReturnCallback(function ($data) use (&$dataStorage) {
118+
$dataStorage = $data;
119+
});
120+
$this->readerMock->expects($this->any())
121+
->method('load')
122+
->willReturnCallback(function () use (&$dataStorage) {
123+
return $dataStorage[ConfigFilePool::APP_ENV];
124+
});
125+
$this->filesystemMock->expects($this->once())
126+
->method("regenerateStatic")
127+
->willReturnCallback(function () use (&$modeModel, &$mode) {
128+
$mode = $modeModel->getMode();
129+
});
130+
$this->model->enableProductionMode();
131+
$this->assertEquals(State::MODE_PRODUCTION, $mode);
132+
}
133+
134+
/**
135+
* Test that previous mode will be enabled after error during static generation call.
136+
* We need this to be sure that mode will be reverted to it previous tate.
137+
*
138+
* @expectedException \Magento\Framework\Exception\LocalizedException
139+
*/
140+
public function testEnableDeveloperModeOnFail()
141+
{
142+
$mode = State::MODE_DEVELOPER;
143+
$dataStorage = [
144+
ConfigFilePool::APP_ENV => [
145+
State::PARAM_MODE => State::MODE_DEVELOPER,
146+
],
147+
];
148+
$this->writerMock->expects($this->exactly(2))
149+
->method("saveConfig")
150+
->withConsecutive(
151+
[$this->equalTo([ConfigFilePool::APP_ENV => [State::PARAM_MODE => State::MODE_PRODUCTION]])],
152+
[$this->equalTo([ConfigFilePool::APP_ENV => [State::PARAM_MODE => State::MODE_DEVELOPER]])]
153+
)
154+
->willReturnCallback(function ($data) use (&$dataStorage) {
155+
$dataStorage = $data;
156+
});
157+
$this->readerMock->expects($this->any())
158+
->method('load')
159+
->willReturnCallback(function () use (&$dataStorage) {
160+
return $dataStorage[ConfigFilePool::APP_ENV];
161+
});
162+
$this->filesystemMock->expects($this->once())
163+
->method("regenerateStatic")
164+
->willThrowException(new LocalizedException(__('Exception')));
165+
$this->model->enableProductionMode();
166+
$this->assertEquals(State::MODE_PRODUCTION, $mode);
167+
}
99168
}

app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
<referenceContainer name="content">
1414
<block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\Create" name="sales_creditmemo_create">
1515
<block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\Create\Form" name="form" template="Magento_Sales::order/creditmemo/create/form.phtml">
16-
<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="Magento_Sales::order/view/info.phtml"/>
16+
<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="Magento_Sales::order/view/info.phtml">
17+
<container name="extra_customer_info"/>
18+
</block>
1719
<block class="Magento\Sales\Block\Adminhtml\Order\Payment" name="order_payment"/>
1820
<block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\Create\Items" name="order_items" template="Magento_Sales::order/creditmemo/create/items.phtml">
1921
<block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="default" template="Magento_Sales::order/creditmemo/create/items/renderer/default.phtml"/>

app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_view.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
<referenceContainer name="content">
1313
<block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\View" name="sales_creditmemo_view">
1414
<block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\View\Form" name="form" template="Magento_Sales::order/creditmemo/view/form.phtml">
15-
<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="Magento_Sales::order/view/info.phtml"/>
15+
<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="Magento_Sales::order/view/info.phtml">
16+
<container name="extra_customer_info"/>
17+
</block>
1618
<block class="Magento\Sales\Block\Adminhtml\Order\Payment" name="order_payment"/>
1719
<block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\View\Items" name="creditmemo_items" template="Magento_Sales::order/creditmemo/view/items.phtml">
1820
<block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="default" template="Magento_Sales::order/creditmemo/view/items/renderer/default.phtml"/>

app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_new.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
<referenceContainer name="content">
1717
<block class="Magento\Sales\Block\Adminhtml\Order\Invoice\Create" name="sales_invoice_create">
1818
<block class="Magento\Sales\Block\Adminhtml\Order\Invoice\Create\Form" name="form" template="Magento_Sales::order/invoice/create/form.phtml">
19-
<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="Magento_Sales::order/view/info.phtml"/>
19+
<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="Magento_Sales::order/view/info.phtml">
20+
<container name="extra_customer_info"/>
21+
</block>
2022
<block class="Magento\Sales\Block\Adminhtml\Order\Payment" name="order_payment"/>
2123
<block class="Magento\Sales\Block\Adminhtml\Order\Invoice\Create\Items" name="order_items" template="Magento_Sales::order/invoice/create/items.phtml">
2224
<block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="default" template="Magento_Sales::order/invoice/create/items/renderer/default.phtml"/>

app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_view.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
<referenceContainer name="content">
1414
<block class="Magento\Sales\Block\Adminhtml\Order\Invoice\View" name="sales_invoice_view">
1515
<block class="Magento\Sales\Block\Adminhtml\Order\Invoice\View\Form" name="form" template="Magento_Sales::order/invoice/view/form.phtml">
16-
<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="Magento_Sales::order/view/info.phtml"/>
16+
<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="Magento_Sales::order/view/info.phtml">
17+
<container name="extra_customer_info"/>
18+
</block>
1719
<block class="Magento\Sales\Block\Adminhtml\Order\Payment" name="order_payment"/>
1820
<block class="Magento\Sales\Block\Adminhtml\Order\Invoice\View\Items" name="invoice_items" template="Magento_Sales::order/invoice/view/items.phtml">
1921
<block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="default" template="Magento_Sales::order/invoice/view/items/renderer/default.phtml"/>

app/code/Magento/Shipping/view/adminhtml/layout/adminhtml_order_shipment_new.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
<referenceContainer name="content">
1212
<block class="Magento\Shipping\Block\Adminhtml\Create" name="sales_shipment_create">
1313
<block class="Magento\Shipping\Block\Adminhtml\Create\Form" name="form" template="Magento_Shipping::create/form.phtml">
14-
<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="Magento_Sales::order/view/info.phtml"/>
14+
<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="Magento_Sales::order/view/info.phtml">
15+
<container name="extra_customer_info"/>
16+
</block>
1517
<block class="Magento\Sales\Block\Adminhtml\Order\Payment" name="order_payment"/>
1618
<block class="Magento\Shipping\Block\Adminhtml\Create\Items" name="order_items" template="Magento_Shipping::create/items.phtml">
1719
<block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" name="default" as="default" template="Magento_Shipping::create/items/renderer/default.phtml"/>

app/code/Magento/Shipping/view/adminhtml/layout/adminhtml_order_shipment_view.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
<referenceContainer name="content">
1212
<block class="Magento\Shipping\Block\Adminhtml\View" name="sales_shipment_view">
1313
<block class="Magento\Shipping\Block\Adminhtml\View\Form" name="form" template="Magento_Shipping::view/form.phtml">
14-
<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="Magento_Sales::order/view/info.phtml"/>
14+
<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="Magento_Sales::order/view/info.phtml">
15+
<container name="extra_customer_info"/>
16+
</block>
1517
<block class="Magento\Sales\Block\Adminhtml\Order\Payment" name="order_payment"/>
1618
<block class="Magento\Shipping\Block\Adminhtml\View\Items" name="shipment_items" template="Magento_Shipping::view/items.phtml">
1719
<block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" name="default" as="default" template="Magento_Shipping::view/items/renderer/default.phtml"/>

0 commit comments

Comments
 (0)