Skip to content

Commit ff7ea7e

Browse files
committed
Merge pull request #483 from magento-tango/MAGETWO-50892
[Tango] Bug fixes
2 parents e03c5ae + baed4c6 commit ff7ea7e

File tree

14 files changed

+53
-94
lines changed

14 files changed

+53
-94
lines changed

app/code/Magento/Captcha/view/adminhtml/layout/adminhtml_auth_forgotpassword.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
1010
<referenceContainer name="form.additional.info">
11-
<block class="Magento\Captcha\Block\Captcha" name="captcha">
11+
<block class="Magento\Captcha\Block\Captcha" name="captcha" cacheable="false">
1212
<action method="setFormId">
1313
<argument name="formId" xsi:type="string">backend_forgotpassword</argument>
1414
</action>

app/code/Magento/Captcha/view/adminhtml/layout/adminhtml_auth_login.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
1010
<referenceContainer name="form.additional.info">
11-
<block class="Magento\Captcha\Block\Captcha" name="captcha">
11+
<block class="Magento\Captcha\Block\Captcha" name="captcha" cacheable="false">
1212
<action method="setFormId">
1313
<argument name="formId" xsi:type="string">backend_login</argument>
1414
</action>

app/code/Magento/Captcha/view/frontend/layout/contact_index_index.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
1010
<referenceContainer name="form.additional.info">
11-
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-">
11+
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
1212
<action method="setFormId">
1313
<argument name="formId" xsi:type="string">contact_us</argument>
1414
</action>

app/code/Magento/Captcha/view/frontend/layout/customer_account_create.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
1010
<referenceContainer name="form.additional.info">
11-
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-">
11+
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
1212
<action method="setFormId">
1313
<argument name="formId" xsi:type="string">user_create</argument>
1414
</action>

app/code/Magento/Captcha/view/frontend/layout/customer_account_edit.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
1010
<referenceContainer name="form.additional.info">
11-
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-">
11+
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
1212
<action method="setFormId">
1313
<argument name="formId" xsi:type="string">user_edit</argument>
1414
</action>

app/code/Magento/Captcha/view/frontend/layout/customer_account_forgotpassword.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
1010
<referenceContainer name="form.additional.info">
11-
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-">
11+
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
1212
<action method="setFormId">
1313
<argument name="formId" xsi:type="string">user_forgotpassword</argument>
1414
</action>

app/code/Magento/Captcha/view/frontend/layout/customer_account_login.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
1010
<referenceContainer name="form.additional.info">
11-
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-">
11+
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
1212
<action method="setFormId">
1313
<argument name="formId" xsi:type="string">user_login</argument>
1414
</action>

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ImagesTest.php

+1-43
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
*/
66
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
77

8-
use Magento\Catalog\Api\Data\ProductAttributeInterface;
98
use Magento\Catalog\Model\Product\Type;
10-
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\General;
119

1210
/**
1311
* @method \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images getModel
@@ -26,47 +24,7 @@ protected function createModel()
2624

2725
public function testModifyData()
2826
{
29-
$productId = 1;
30-
$modelId = 1;
31-
32-
$data = [
33-
$modelId => [
34-
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\General::DATA_SOURCE_DEFAULT => [
35-
ProductAttributeInterface::CODE_SKU => 'product_42',
36-
ProductAttributeInterface::CODE_PRICE => '42.00',
37-
ProductAttributeInterface::CODE_STATUS => '1',
38-
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images::CODE_MEDIA_GALLERY => [
39-
'images' => [
40-
[
41-
'value_id' => '1',
42-
'file' => 'filename.jpg',
43-
'media_type' => 'image',
44-
]
45-
]
46-
],
47-
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images::CODE_IMAGE => 'filename.jpg',
48-
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images::CODE_SMALL_IMAGE => 'filename.jpg',
49-
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images::CODE_THUMBNAIL => 'filename.jpg',
50-
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images::CODE_SWATCH_IMAGE => 'filename.jpg',
51-
]
52-
]
53-
];
54-
55-
$expectedData = [
56-
$modelId => [
57-
General::DATA_SOURCE_DEFAULT => [
58-
ProductAttributeInterface::CODE_SKU => 'product_42',
59-
ProductAttributeInterface::CODE_PRICE => '42.00',
60-
ProductAttributeInterface::CODE_STATUS => '1',
61-
]
62-
]
63-
];
64-
65-
$this->productMock->expects($this->once())
66-
->method('getId')
67-
->willReturn($productId);
68-
69-
$this->assertSame($expectedData, $this->getModel()->modifyData($data));
27+
$this->assertSame($this->getSampleData(), $this->getModel()->modifyData($this->getSampleData()));
7028
}
7129

7230
public function testModifyMeta()

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Images.php

+3-38
Original file line numberDiff line numberDiff line change
@@ -41,51 +41,16 @@ public function __construct(LocatorInterface $locator)
4141
*/
4242
public function modifyMeta(array $meta)
4343
{
44-
return $this->customizeImagesTab($meta);
44+
unset($meta[self::CODE_IMAGE_MANAGEMENT_GROUP]);
45+
46+
return $meta;
4547
}
4648

4749
/**
4850
* {@inheritdoc}
4951
*/
5052
public function modifyData(array $data)
5153
{
52-
$modelId = $this->locator->getProduct()->getId();
53-
54-
if ($modelId != null) {
55-
if (isset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_MEDIA_GALLERY])) {
56-
unset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_MEDIA_GALLERY]);
57-
}
58-
if (isset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_IMAGE])) {
59-
unset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_IMAGE]);
60-
}
61-
if (isset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_SMALL_IMAGE])) {
62-
unset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_SMALL_IMAGE]);
63-
}
64-
if (isset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_THUMBNAIL])) {
65-
unset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_THUMBNAIL]);
66-
}
67-
if (isset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_SWATCH_IMAGE])) {
68-
unset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_SWATCH_IMAGE]);
69-
}
70-
}
71-
7254
return $data;
7355
}
74-
75-
/**
76-
* Remove Images tab from meta because it's block is rendered in layout
77-
*
78-
* @param array $meta
79-
* @return array
80-
*/
81-
protected function customizeImagesTab(array $meta)
82-
{
83-
foreach (array_keys($meta) as $groupName) {
84-
if ($groupName === self::CODE_IMAGE_MANAGEMENT_GROUP) {
85-
unset($meta[self::CODE_IMAGE_MANAGEMENT_GROUP]);
86-
}
87-
}
88-
89-
return $meta;
90-
}
9156
}

lib/internal/Magento/Framework/View/Page/Config/Reader/Head.php

+19-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function interpret(
9090
break;
9191

9292
case self::HEAD_META:
93-
$pageConfigStructure->setMetaData($node->getAttribute('name'), $node->getAttribute('content'));
93+
$this->setMetadata($pageConfigStructure, $node);
9494
break;
9595

9696
case self::HEAD_ATTRIBUTE:
@@ -122,4 +122,22 @@ protected function getAttributes($element)
122122
}
123123
return $attributes;
124124
}
125+
126+
/**
127+
* Set metadata
128+
*
129+
* @param \Magento\Framework\View\Page\Config\Structure $pageConfigStructure
130+
* @param \Magento\Framework\View\Layout\Element $node
131+
* @return void
132+
*/
133+
private function setMetadata($pageConfigStructure, $node)
134+
{
135+
if (!$node->getAttribute('name') && $node->getAttribute('property')) {
136+
$metadataName = $node->getAttribute('property');
137+
} else {
138+
$metadataName = $node->getAttribute('name');
139+
}
140+
141+
$pageConfigStructure->setMetaData($metadataName, $node->getAttribute('content'));
142+
}
125143
}

lib/internal/Magento/Framework/View/Page/Config/Renderer.php

+4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ protected function processMetadataContent($name, $content)
148148
*/
149149
protected function getMetadataTemplate($name)
150150
{
151+
if (strpos($name, 'og:') === 0) {
152+
return '<meta property="' . $name . '" content="%content"/>' . "\n";
153+
}
154+
151155
switch ($name) {
152156
case 'charset':
153157
$metadataTemplate = '<meta charset="%content"/>' . "\n";

lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Reader/HeadTest.php

+14-4
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,36 @@ public function testInterpret()
4848
->willReturnSelf();
4949

5050
$structureMock->expects($this->at(2))
51+
->method('setMetaData')
52+
->with('og:video:secure_url', 'https://secure.example.com/movie.swf')
53+
->willReturnSelf();
54+
55+
$structureMock->expects($this->at(3))
56+
->method('setMetaData')
57+
->with('og:locale:alternate', 'uk_UA')
58+
->willReturnSelf();
59+
60+
$structureMock->expects($this->at(4))
5161
->method('addAssets')
5262
->with('path/file.css', ['src' => 'path/file.css', 'media' => 'all', 'content_type' => 'css'])
5363
->willReturnSelf();
5464

55-
$structureMock->expects($this->at(3))
65+
$structureMock->expects($this->at(5))
5666
->method('addAssets')
5767
->with('path/file.js', ['src' => 'path/file.js', 'defer' => 'defer', 'content_type' => 'js'])
5868
->willReturnSelf();
5969

60-
$structureMock->expects($this->at(4))
70+
$structureMock->expects($this->at(6))
6171
->method('addAssets')
6272
->with('http://url.com', ['src' => 'http://url.com', 'src_type' => 'url'])
6373
->willReturnSelf();
6474

65-
$structureMock->expects($this->at(5))
75+
$structureMock->expects($this->at(7))
6676
->method('removeAssets')
6777
->with('path/remove/file.css')
6878
->willReturnSelf();
6979

70-
$structureMock->expects($this->at(6))
80+
$structureMock->expects($this->at(8))
7181
->method('setElementAttribute')
7282
->with(Config::ELEMENT_TYPE_HEAD, 'head_attribute_name', 'head_attribute_value')
7383
->willReturnSelf();

lib/internal/Magento/Framework/View/Test/Unit/Page/Config/RendererTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,15 @@ public function testRenderMetadata()
147147
'content_type' => 'content_type_value',
148148
'x_ua_compatible' => 'x_ua_compatible_value',
149149
'media_type' => 'media_type_value',
150+
'og:video:secure_url' => 'secure_url'
150151
];
151152
$metadataValueCharset = 'newCharsetValue';
152153

153154
$expected = '<meta charset="newCharsetValue"/>' . "\n"
154155
. '<meta name="metadataName" content="metadataValue"/>' . "\n"
155156
. '<meta http-equiv="Content-Type" content="content_type_value"/>' . "\n"
156-
. '<meta http-equiv="X-UA-Compatible" content="x_ua_compatible_value"/>' . "\n";
157+
. '<meta http-equiv="X-UA-Compatible" content="x_ua_compatible_value"/>' . "\n"
158+
. '<meta property="og:video:secure_url" content="secure_url"/>' . "\n";
157159

158160
$this->stringMock->expects($this->at(0))
159161
->method('upperCaseWords')

lib/internal/Magento/Framework/View/Test/Unit/Page/Config/_files/template_head.xml

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<head>
1010
<title>Test title</title>
1111
<meta name="meta_name" content="meta_content"/>
12+
<meta property="og:video:secure_url" content="https://secure.example.com/movie.swf" />
13+
<meta property="og:locale:alternate" content="uk_UA" />
1214
<css src="path/file.css" media="all" />
1315
<script src="path/file.js" defer="defer"/>
1416
<link src="http://url.com" src_type="url"/>

0 commit comments

Comments
 (0)