Skip to content

Commit ea7e61e

Browse files
committed
Merge pull request #5 from magento-firedrakes/codefreeze
[Firedrakes] Bug fixes
2 parents 59f1a97 + 787755d commit ea7e61e

File tree

43 files changed

+1554
-140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1554
-140
lines changed

app/code/Magento/CatalogRule/Model/Rule/Condition/Product.php

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,106 +8,112 @@
88
*/
99
namespace Magento\CatalogRule\Model\Rule\Condition;
1010

11+
/**
12+
* Class Product
13+
*/
1114
class Product extends \Magento\Rule\Model\Condition\Product\AbstractProduct
1215
{
1316
/**
1417
* Validate product attribute value for condition
1518
*
16-
* @param \Magento\Framework\Object $object
19+
* @param \Magento\Framework\Model\AbstractModel $model
1720
* @return bool
1821
*/
19-
public function validate(\Magento\Framework\Object $object)
22+
public function validate(\Magento\Framework\Model\AbstractModel $model)
2023
{
2124
$attrCode = $this->getAttribute();
2225
if ('category_ids' == $attrCode) {
23-
return $this->validateAttribute($object->getAvailableInCategories());
26+
return $this->validateAttribute($model->getAvailableInCategories());
2427
}
2528

26-
$oldAttrValue = $object->hasData($attrCode) ? $object->getData($attrCode) : null;
27-
$this->_setAttributeValue($object);
29+
$oldAttrValue = $model->hasData($attrCode) ? $model->getData($attrCode) : null;
30+
$this->_setAttributeValue($model);
2831

29-
$result = $this->validateAttribute($object->getData($this->getAttribute()));
30-
$this->_restoreOldAttrValue($object, $oldAttrValue);
32+
$result = $this->validateAttribute($model->getData($this->getAttribute()));
33+
$this->_restoreOldAttrValue($model, $oldAttrValue);
3134

3235
return (bool)$result;
3336
}
3437

3538
/**
3639
* Restore old attribute value
3740
*
38-
* @param \Magento\Framework\Object $object
41+
* @param \Magento\Framework\Model\AbstractModel $model
3942
* @param mixed $oldAttrValue
4043
* @return void
4144
*/
42-
protected function _restoreOldAttrValue($object, $oldAttrValue)
45+
protected function _restoreOldAttrValue(\Magento\Framework\Model\AbstractModel $model, $oldAttrValue)
4346
{
4447
$attrCode = $this->getAttribute();
4548
if (is_null($oldAttrValue)) {
46-
$object->unsetData($attrCode);
49+
$model->unsetData($attrCode);
4750
} else {
48-
$object->setData($attrCode, $oldAttrValue);
51+
$model->setData($attrCode, $oldAttrValue);
4952
}
5053
}
5154

5255
/**
5356
* Set attribute value
5457
*
55-
* @param \Magento\Framework\Object $object
58+
* @param \Magento\Framework\Model\AbstractModel $model
5659
* @return $this
5760
*/
58-
protected function _setAttributeValue($object)
61+
protected function _setAttributeValue(\Magento\Framework\Model\AbstractModel $model)
5962
{
60-
$storeId = $object->getStoreId();
63+
$storeId = $model->getStoreId();
6164
$defaultStoreId = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
6265

63-
if (!isset($this->_entityAttributeValues[$object->getId()])) {
66+
if (!isset($this->_entityAttributeValues[$model->getId()])) {
6467
return $this;
6568
}
6669

67-
$productValues = $this->_entityAttributeValues[$object->getId()];
70+
$productValues = $this->_entityAttributeValues[$model->getId()];
6871

6972
if (!isset($productValues[$storeId]) && !isset($productValues[$defaultStoreId])) {
7073
return $this;
7174
}
7275

7376
$value = isset($productValues[$storeId]) ? $productValues[$storeId] : $productValues[$defaultStoreId];
7477

75-
$value = $this->_prepareDatetimeValue($value, $object);
76-
$value = $this->_prepareMultiselectValue($value, $object);
78+
$value = $this->_prepareDatetimeValue($value, $model);
79+
$value = $this->_prepareMultiselectValue($value, $model);
80+
81+
$model->setData($this->getAttribute(), $value);
7782

78-
$object->setData($this->getAttribute(), $value);
7983
return $this;
8084
}
8185

8286
/**
8387
* Prepare datetime attribute value
8488
*
8589
* @param mixed $value
86-
* @param \Magento\Framework\Object $object
90+
* @param \Magento\Framework\Model\AbstractModel $model
8791
* @return mixed
8892
*/
89-
protected function _prepareDatetimeValue($value, $object)
93+
protected function _prepareDatetimeValue($value, \Magento\Framework\Model\AbstractModel $model)
9094
{
91-
$attribute = $object->getResource()->getAttribute($this->getAttribute());
95+
$attribute = $model->getResource()->getAttribute($this->getAttribute());
9296
if ($attribute && $attribute->getBackendType() == 'datetime') {
9397
$value = strtotime($value);
9498
}
99+
95100
return $value;
96101
}
97102

98103
/**
99104
* Prepare multiselect attribute value
100105
*
101106
* @param mixed $value
102-
* @param \Magento\Framework\Object $object
107+
* @param \Magento\Framework\Model\AbstractModel $model
103108
* @return mixed
104109
*/
105-
protected function _prepareMultiselectValue($value, $object)
110+
protected function _prepareMultiselectValue($value, \Magento\Framework\Model\AbstractModel $model)
106111
{
107-
$attribute = $object->getResource()->getAttribute($this->getAttribute());
112+
$attribute = $model->getResource()->getAttribute($this->getAttribute());
108113
if ($attribute && $attribute->getFrontendInput() == 'multiselect') {
109114
$value = strlen($value) ? explode(',', $value) : [];
110115
}
116+
111117
return $value;
112118
}
113119
}

app/code/Magento/Customer/Block/Adminhtml/Group/Edit/Form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ protected function _prepareLayout()
115115
'title' => __('Tax Class'),
116116
'class' => 'required-entry',
117117
'required' => true,
118-
'values' => $this->_taxCustomer->toOptionArray(true),
118+
'values' => $this->_taxCustomer->toOptionArray(),
119119
]
120120
);
121121

app/code/Magento/Customer/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ T: {{var telephone}}
5858
{{depend fax}}F: {{var fax}}{{/depend}}
5959
{{depend vat_id}}VAT: {{var vat_id}}{{/depend}}</text>
6060
<oneline>{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}, {{var street}}, {{var city}}, {{var region}} {{var postcode}}, {{var country}}</oneline>
61-
<html><![CDATA[{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}<br/>
61+
<html><![CDATA[{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}{{depend firstname}}<br/>{{/depend}}
6262
{{depend company}}{{var company}}<br />{{/depend}}
6363
{{if street1}}{{var street1}}<br />{{/if}}
6464
{{depend street2}}{{var street2}}<br />{{/depend}}

app/code/Magento/OfflinePayments/Model/Banktransfer.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ class Banktransfer extends \Magento\Payment\Model\Method\AbstractMethod
3232
*/
3333
protected $_infoBlockType = 'Magento\Payment\Block\Info\Instructions';
3434

35+
/**
36+
* Availability option
37+
*
38+
* @var bool
39+
*/
40+
protected $_isOffline = true;
41+
3542
/**
3643
* Get instructions text from config
3744
*

app/code/Magento/OfflinePayments/Model/Cashondelivery.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ class Cashondelivery extends \Magento\Payment\Model\Method\AbstractMethod
3030
*/
3131
protected $_infoBlockType = 'Magento\Payment\Block\Info\Instructions';
3232

33+
/**
34+
* Availability option
35+
*
36+
* @var bool
37+
*/
38+
protected $_isOffline = true;
39+
3340
/**
3441
* Get instructions text from config
3542
*

app/code/Magento/OfflinePayments/Model/Checkmo.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ class Checkmo extends \Magento\Payment\Model\Method\AbstractMethod
2121
*/
2222
protected $_infoBlockType = 'Magento\OfflinePayments\Block\Info\Checkmo';
2323

24+
/**
25+
* Availability option
26+
*
27+
* @var bool
28+
*/
29+
protected $_isOffline = true;
30+
2431
/**
2532
* Assign data to info model instance
2633
*

app/code/Magento/OfflinePayments/Model/Purchaseorder.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ class Purchaseorder extends \Magento\Payment\Model\Method\AbstractMethod
2121
*/
2222
protected $_infoBlockType = 'Magento\OfflinePayments\Block\Info\Purchaseorder';
2323

24+
/**
25+
* Availability option
26+
*
27+
* @var bool
28+
*/
29+
protected $_isOffline = true;
30+
2431
/**
2532
* Assign data to info model instance
2633
*

app/code/Magento/Payment/Model/Method/AbstractMethod.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ abstract class AbstractMethod extends \Magento\Framework\Object implements Metho
7070
*/
7171
protected $_isGateway = false;
7272

73+
/**
74+
* Payment Method feature
75+
*
76+
* @var bool
77+
*/
78+
protected $_isOffline = false;
79+
7380
/**
7481
* Payment Method feature
7582
*
@@ -366,6 +373,16 @@ public function isGateway()
366373
return $this->_isGateway;
367374
}
368375

376+
/**
377+
* Retrieve payment method online/offline flag
378+
*
379+
* @return bool
380+
*/
381+
public function isOffline()
382+
{
383+
return $this->_isOffline;
384+
}
385+
369386
/**
370387
* Flag if we need to run payment initialize while order place
371388
*

app/code/Magento/Persistent/Block/Header/Additional.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function __construct(
4444
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
4545
array $data = []
4646
) {
47+
$this->isScopePrivate = true;
4748
$this->_customerViewHelper = $customerViewHelper;
4849
$this->_persistentSessionHelper = $persistentSessionHelper;
4950
$this->customerRepository = $customerRepository;
@@ -68,12 +69,16 @@ public function getHref()
6869
*/
6970
protected function _toHtml()
7071
{
71-
$persistentName = $this->_escaper->escapeHtml(
72-
$this->_customerViewHelper->getCustomerName(
73-
$this->customerRepository->getById($this->_persistentSessionHelper->getSession()->getCustomerId())
74-
)
75-
);
76-
return '<span><a ' . $this->getLinkAttributes() . ' >' . $this->escapeHtml(__('(Not %1?)', $persistentName))
77-
. '</a></span>';
72+
if ($this->_persistentSessionHelper->getSession()->getCustomerId()) {
73+
$persistentName = $this->escapeHtml(
74+
$this->_customerViewHelper->getCustomerName(
75+
$this->customerRepository->getById($this->_persistentSessionHelper->getSession()->getCustomerId())
76+
)
77+
);
78+
return '<span><a ' . $this->getLinkAttributes() . ' >' . __('(Not %1?)', $persistentName)
79+
. '</a></span>';
80+
}
81+
82+
return '';
7883
}
7984
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
4+
*/
5+
namespace Magento\Persistent\Model\Layout;
6+
7+
/**
8+
* Class DepersonalizePlugin
9+
*/
10+
class DepersonalizePlugin
11+
{
12+
/**
13+
* @var \Magento\Persistent\Model\Session
14+
*/
15+
protected $persistentSession;
16+
17+
/**
18+
* @var \Magento\Framework\App\RequestInterface
19+
*/
20+
protected $request;
21+
22+
/**
23+
* @var \Magento\Framework\Module\Manager
24+
*/
25+
protected $moduleManager;
26+
27+
/**
28+
* @var \Magento\PageCache\Model\Config
29+
*/
30+
protected $cacheConfig;
31+
32+
/**
33+
* Constructor
34+
*
35+
* @param \Magento\Persistent\Model\Session $persistentSession
36+
* @param \Magento\Framework\App\RequestInterface $request
37+
* @param \Magento\Framework\Module\Manager $moduleManager
38+
* @param \Magento\PageCache\Model\Config $cacheConfig
39+
*/
40+
public function __construct(
41+
\Magento\Persistent\Model\Session $persistentSession,
42+
\Magento\Framework\App\RequestInterface $request,
43+
\Magento\Framework\Module\Manager $moduleManager,
44+
\Magento\PageCache\Model\Config $cacheConfig
45+
) {
46+
$this->persistentSession = $persistentSession;
47+
$this->request = $request;
48+
$this->moduleManager = $moduleManager;
49+
$this->cacheConfig = $cacheConfig;
50+
}
51+
52+
/**
53+
* After generate Xml
54+
*
55+
* @param \Magento\Framework\View\LayoutInterface $subject
56+
* @param \Magento\Framework\View\LayoutInterface $result
57+
* @return \Magento\Framework\View\LayoutInterface
58+
*/
59+
public function afterGenerateXml(
60+
\Magento\Framework\View\LayoutInterface $subject,
61+
\Magento\Framework\View\LayoutInterface $result
62+
) {
63+
if ($this->moduleManager->isEnabled('Magento_PageCache')
64+
&& $this->cacheConfig->isEnabled()
65+
&& !$this->request->isAjax()
66+
&& $subject->isCacheable()
67+
) {
68+
$this->persistentSession->setCustomerId(null);
69+
}
70+
71+
return $result;
72+
}
73+
}

app/code/Magento/Persistent/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"magento/module-customer": "0.42.0-beta1",
1010
"magento/module-sales": "0.42.0-beta1",
1111
"magento/module-cron": "0.42.0-beta1",
12+
"magento/module-page-cache": "0.42.0-beta1",
1213
"magento/framework": "0.42.0-beta1",
1314
"magento/magento-composer-installer": "*"
1415
},

app/code/Magento/Persistent/etc/frontend/di.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@
1212
</argument>
1313
</arguments>
1414
</type>
15+
<type name="Magento\Framework\View\Layout">
16+
<plugin name="persistent-session-depersonalize"
17+
type="Magento\Persistent\Model\Layout\DepersonalizePlugin"
18+
sortOrder="10"
19+
/>
20+
</type>
1521
</config>

app/code/Magento/Persistent/etc/module.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<module name="Magento_Persistent" schema_version="2.0.0">
99
<sequence>
1010
<module name="Magento_Checkout"/>
11+
<module name="Magento_PageCache"/>
1112
</sequence>
1213
</module>
1314
</config>

app/code/Magento/Rule/Model/Condition/AbstractCondition.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,12 +832,17 @@ protected function _compareValues($validatedValue, $value, $strict = true)
832832
}
833833

834834
/**
835-
* @param \Magento\Framework\Object $object
835+
* @param \Magento\Framework\Model\AbstractModel $model
836836
* @return bool
837837
*/
838-
public function validate(\Magento\Framework\Object $object)
838+
public function validate(\Magento\Framework\Model\AbstractModel $model)
839839
{
840-
return $this->validateAttribute($object->getData($this->getAttribute()));
840+
if (!$model->hasData($this->getAttribute())) {
841+
$model->load($model->getId());
842+
}
843+
$attributeValue = $model->getData($this->getAttribute());
844+
845+
return $this->validateAttribute($attributeValue);
841846
}
842847

843848
/**

0 commit comments

Comments
 (0)