Skip to content

Commit 54a6742

Browse files
committed
Merge pull request #249 from magento-south/BUGS
[South] Bug fixes
2 parents 6a55821 + 36b6695 commit 54a6742

File tree

25 files changed

+558
-65
lines changed

25 files changed

+558
-65
lines changed

app/code/Magento/Backend/view/adminhtml/layout/adminhtml_system_design_grid_block.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
<block class="Magento\Backend\Block\Widget\Grid\Column" as="package">
4242
<arguments>
4343
<argument name="header" xsi:type="string" translate="true">Design</argument>
44+
<argument name="type" xsi:type="string">options</argument>
45+
<argument name="options" xsi:type="options" model="Magento\Framework\View\Design\Theme\Label\Options"/>
4446
<argument name="width" xsi:type="string">150px</argument>
4547
<argument name="index" xsi:type="string">design</argument>
4648
</arguments>

app/code/Magento/Cms/Controller/Adminhtml/Block/Save.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
namespace Magento\Cms\Controller\Adminhtml\Block;
88

9+
use Magento\Cms\Model\Block;
10+
911
class Save extends \Magento\Cms\Controller\Adminhtml\Block
1012
{
1113
/**
@@ -21,6 +23,14 @@ public function execute()
2123
$data = $this->getRequest()->getPostValue();
2224
if ($data) {
2325
$id = $this->getRequest()->getParam('block_id');
26+
27+
if (isset($data['is_active']) && $data['is_active'] === 'true') {
28+
$data['is_active'] = Block::STATUS_ENABLED;
29+
}
30+
if (empty($data['block_id'])) {
31+
$data['block_id'] = null;
32+
}
33+
2434
$model = $this->_objectManager->create('Magento\Cms\Model\Block')->load($id);
2535
if (!$model->getId() && $id) {
2636
$this->messageManager->addError(__('This block no longer exists.'));

app/code/Magento/Cms/Model/Block.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ class Block extends \Magento\Framework\Model\AbstractModel implements BlockInter
2121
*/
2222
const CACHE_TAG = 'cms_block';
2323

24+
/**#@+
25+
* Block's statuses
26+
*/
27+
const STATUS_ENABLED = 1;
28+
const STATUS_DISABLED = 0;
29+
30+
/**#@-*/
2431
/**
2532
* @var string
2633
*/
@@ -224,4 +231,14 @@ public function getStores()
224231
{
225232
return $this->hasData('stores') ? $this->getData('stores') : $this->getData('store_id');
226233
}
234+
235+
/**
236+
* Prepare block's statuses.
237+
*
238+
* @return array
239+
*/
240+
public function getAvailableStatuses()
241+
{
242+
return [self::STATUS_ENABLED => __('Enabled'), self::STATUS_DISABLED => __('Disabled')];
243+
}
227244
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Cms\Model\Block\Source;
7+
8+
use Magento\Framework\Data\OptionSourceInterface;
9+
10+
/**
11+
* Class IsActive
12+
*/
13+
class IsActive implements OptionSourceInterface
14+
{
15+
/**
16+
* @var \Magento\Cms\Model\Block
17+
*/
18+
protected $cmsBlock;
19+
20+
/**
21+
* Constructor
22+
*
23+
* @param \Magento\Cms\Model\Block $cmsBlock
24+
*/
25+
public function __construct(\Magento\Cms\Model\Block $cmsBlock)
26+
{
27+
$this->cmsBlock = $cmsBlock;
28+
}
29+
30+
/**
31+
* Get options
32+
*
33+
* @return array
34+
*/
35+
public function toOptionArray()
36+
{
37+
$availableOptions = $this->cmsBlock->getAvailableStatuses();
38+
$options = [];
39+
foreach ($availableOptions as $key => $value) {
40+
$options[] = [
41+
'label' => $value,
42+
'value' => $key,
43+
];
44+
}
45+
return $options;
46+
}
47+
}

app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/SaveTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ public function testSaveAction()
160160
'title' => '"><img src=y onerror=prompt(document.domain)>;',
161161
'identifier' => 'unique_title_123',
162162
'stores' => ['0'],
163-
'is_active' => '1',
163+
'is_active' => true,
164164
'content' => '"><script>alert("cookie: "+document.cookie)</script>'
165165
];
166166

167167
$filteredPostData = [
168168
'title' => '&quot;&gt;&lt;img src=y onerror=prompt(document.domain)&gt;;',
169169
'identifier' => 'unique_title_123',
170170
'stores' => ['0'],
171-
'is_active' => '1',
171+
'is_active' => true,
172172
'content' => '&quot;&gt;&lt;script&gt;alert(&quot;cookie: &quot;+document.cookie)&lt;/script&gt;'
173173
];
174174

@@ -228,7 +228,7 @@ public function testSaveActionWithoutData()
228228

229229
public function testSaveActionNoId()
230230
{
231-
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn(true);
231+
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn(['block_id' => 1]);
232232
$this->requestMock->expects($this->atLeastOnce())
233233
->method('getParam')
234234
->willReturnMap(
@@ -261,7 +261,7 @@ public function testSaveActionNoId()
261261

262262
public function testSaveAndContinue()
263263
{
264-
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn(true);
264+
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn(['block_id' => 1]);
265265
$this->requestMock->expects($this->atLeastOnce())
266266
->method('getParam')
267267
->willReturnMap(
@@ -308,7 +308,7 @@ public function testSaveAndContinue()
308308

309309
public function testSaveActionThrowsException()
310310
{
311-
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn(true);
311+
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn(['block_id' => 1]);
312312
$this->requestMock->expects($this->atLeastOnce())
313313
->method('getParam')
314314
->willReturnMap(
@@ -345,7 +345,7 @@ public function testSaveActionThrowsException()
345345
$this->messageManagerMock->expects($this->once())
346346
->method('addError');
347347

348-
$this->sessionMock->expects($this->atLeastOnce())->method('setFormData')->with(true);
348+
$this->sessionMock->expects($this->atLeastOnce())->method('setFormData')->with(['block_id' => 1]);
349349

350350
$this->resultRedirect->expects($this->atLeastOnce())
351351
->method('setPath')
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Cms\Test\Unit\Model\Block\Source;
7+
8+
use Magento\Cms\Model\Block;
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
10+
11+
class IsActiveTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var Block|\PHPUnit_Framework_MockObject_MockObject
15+
*/
16+
protected $cmsBlockMock;
17+
18+
/**
19+
* @var ObjectManager
20+
*/
21+
protected $objectManagerHelper;
22+
23+
/**
24+
* @var Block\Source\IsActive
25+
*/
26+
protected $object;
27+
28+
/**
29+
* {@inheritdoc}
30+
*/
31+
protected function setUp()
32+
{
33+
$this->objectManagerHelper = new ObjectManager($this);
34+
$this->cmsBlockMock = $this->getMockBuilder('Magento\Cms\Model\Block')
35+
->disableOriginalConstructor()
36+
->setMethods(['getAvailableStatuses'])
37+
->getMock();
38+
39+
$this->object = $this->objectManagerHelper->getObject($this->getSourceClassName(), [
40+
'cmsBlock' => $this->cmsBlockMock,
41+
]);
42+
}
43+
44+
/**
45+
* @return string
46+
*/
47+
protected function getSourceClassName()
48+
{
49+
return 'Magento\Cms\Model\Block\Source\IsActive';
50+
}
51+
52+
/**
53+
* @param array $availableStatuses
54+
* @param array $expected
55+
* @return void
56+
* @dataProvider getAvailableStatusesDataProvider
57+
*/
58+
public function testToOptionArray(array $availableStatuses, array $expected)
59+
{
60+
$this->cmsBlockMock->expects($this->once())
61+
->method('getAvailableStatuses')
62+
->willReturn($availableStatuses);
63+
64+
$this->assertSame($expected, $this->object->toOptionArray());
65+
}
66+
67+
/**
68+
* @return array
69+
*/
70+
public function getAvailableStatusesDataProvider()
71+
{
72+
return [
73+
[
74+
[],
75+
[],
76+
],
77+
[
78+
['testStatus' => 'testValue'],
79+
[['label' => 'testValue', 'value' => 'testStatus']],
80+
],
81+
];
82+
}
83+
}

app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,7 @@
186186
</column>
187187
<column name="is_active">
188188
<argument name="data" xsi:type="array">
189-
<item name="options" xsi:type="array">
190-
<item name="disable" xsi:type="array">
191-
<item name="value" xsi:type="string">0</item>
192-
<item name="label" xsi:type="string" translate="true">Disabled</item>
193-
</item>
194-
<item name="enable" xsi:type="array">
195-
<item name="value" xsi:type="string">1</item>
196-
<item name="label" xsi:type="string" translate="true">Enabled</item>
197-
</item>
198-
</item>
189+
<item name="options" xsi:type="object">Magento\Cms\Model\Block\Source\IsActive</item>
199190
<item name="config" xsi:type="array">
200191
<item name="filter" xsi:type="string">select</item>
201192
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>

app/code/Magento/Customer/Controller/Account/LoginPost.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ public function execute()
8484
} catch (EmailNotConfirmedException $e) {
8585
$value = $this->customerUrl->getEmailConfirmationUrl($login['username']);
8686
$message = __(
87-
'This account is not confirmed.' .
88-
' <a href="%1">Click here</a> to resend confirmation email.',
87+
'This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.',
8988
$value
9089
);
9190
$this->messageManager->addError($message);
@@ -95,7 +94,10 @@ public function execute()
9594
$this->messageManager->addError($message);
9695
$this->session->setUsername($login['username']);
9796
} catch (\Exception $e) {
98-
$this->messageManager->addError(__('Invalid login or password.'));
97+
// PA DSS violation: throwing or logging an exception here can disclose customer password
98+
$this->messageManager->addError(
99+
__('An unspecified error occurred. Please contact us for assistance.')
100+
);
99101
}
100102
} else {
101103
$this->messageManager->addError(__('A login and a password are required.'));

app/code/Magento/Customer/Setup/UpgradeData.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ private function upgradeHash($setup)
332332

333333
$customers = $setup->getConnection()->fetchAll($select);
334334
foreach ($customers as $customer) {
335+
if ($customer['password_hash'] === null) {
336+
continue;
337+
}
335338
list($hash, $salt) = explode(Encryptor::DELIMITER, $customer['password_hash']);
336339

337340
$newHash = $customer['password_hash'];

app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ protected function mockExceptions($exception, $username)
423423
case '\Exception':
424424
$this->messageManager->expects($this->once())
425425
->method('addError')
426-
->with(__('Invalid login or password.'))
426+
->with(__('An unspecified error occurred. Please contact us for assistance.'))
427427
->willReturnSelf();
428428
break;
429429
}

0 commit comments

Comments
 (0)