Skip to content

Commit 73382f6

Browse files
committed
Merge branch 'develop_mainline' into switcher_stable
2 parents 1b9c43a + 8fd3e8a commit 73382f6

File tree

200 files changed

+4374
-1443
lines changed

Some content is hidden

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

200 files changed

+4374
-1443
lines changed

app/code/Magento/Backend/Model/Auth/Session.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,26 +171,13 @@ public function isLoggedIn()
171171
}
172172

173173
/**
174-
* Set session UpdatedAt to current time and update cookie expiration time
174+
* Set session UpdatedAt to current time
175175
*
176176
* @return void
177177
*/
178178
public function prolong()
179179
{
180-
$lifetime = $this->_config->getValue(self::XML_PATH_SESSION_LIFETIME);
181-
$currentTime = time();
182-
183-
$this->setUpdatedAt($currentTime);
184-
$cookieValue = $this->cookieManager->getCookie($this->getName());
185-
if ($cookieValue) {
186-
$cookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata()
187-
->setDuration($lifetime)
188-
->setPath($this->sessionConfig->getCookiePath())
189-
->setDomain($this->sessionConfig->getCookieDomain())
190-
->setSecure($this->sessionConfig->getCookieSecure())
191-
->setHttpOnly($this->sessionConfig->getCookieHttpOnly());
192-
$this->cookieManager->setPublicCookie($this->getName(), $cookieValue, $cookieMetadata);
193-
}
180+
$this->setUpdatedAt(time());
194181
}
195182

196183
/**
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Backend\Model\Config\SessionLifetime;
7+
8+
use Magento\Framework\App\Config\Value;
9+
use Magento\Framework\Exception\LocalizedException;
10+
11+
/**
12+
* Backend model for the admin/security/session_lifetime configuration field. Validates session lifetime.
13+
*/
14+
class BackendModel extends Value
15+
{
16+
/** Maximum dmin session lifetime; 1 year*/
17+
const MAX_LIFETIME = 31536000;
18+
19+
/** Minimum admin session lifetime */
20+
const MIN_LIFETIME = 60;
21+
22+
public function beforeSave()
23+
{
24+
$value = (int) $this->getValue();
25+
if ($value > self::MAX_LIFETIME) {
26+
throw new LocalizedException(
27+
__('Admin session lifetime must be less than or equal to 31536000 seconds (one year)')
28+
);
29+
} else if ($value < self::MIN_LIFETIME) {
30+
throw new LocalizedException(
31+
__('Admin session lifetime must be greater than or equal to 60 seconds')
32+
);
33+
}
34+
return parent::beforeSave();
35+
}
36+
}

app/code/Magento/Backend/Model/Session/AdminConfig.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
/**
1616
* Magento Backend session configuration
17-
*
18-
* @method Config setSaveHandler()
1917
*/
2018
class AdminConfig extends Config
2119
{
@@ -107,4 +105,14 @@ private function extractAdminPath()
107105
$cookiePath = $baseUrl . $backendApp->getCookiePath();
108106
return $cookiePath;
109107
}
108+
109+
/**
110+
* Set session cookie lifetime to session duration
111+
*
112+
* @return $this
113+
*/
114+
protected function configureCookieLifetime()
115+
{
116+
return $this->setCookieLifetime(0);
117+
}
110118
}

app/code/Magento/Backend/Test/Unit/Model/Auth/SessionTest.php

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -162,67 +162,7 @@ public function testIsLoggedInPositive()
162162

163163
public function testProlong()
164164
{
165-
$name = session_name();
166-
$cookie = 'cookie';
167-
$lifetime = 900;
168-
$path = '/';
169-
$domain = 'magento2';
170-
$secure = true;
171-
$httpOnly = true;
172-
173-
$cookieMetadata = $this->getMock('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata');
174-
$cookieMetadata->expects($this->once())
175-
->method('setDuration')
176-
->with($lifetime)
177-
->will($this->returnSelf());
178-
$cookieMetadata->expects($this->once())
179-
->method('setPath')
180-
->with($path)
181-
->will($this->returnSelf());
182-
$cookieMetadata->expects($this->once())
183-
->method('setDomain')
184-
->with($domain)
185-
->will($this->returnSelf());
186-
$cookieMetadata->expects($this->once())
187-
->method('setSecure')
188-
->with($secure)
189-
->will($this->returnSelf());
190-
$cookieMetadata->expects($this->once())
191-
->method('setHttpOnly')
192-
->with($httpOnly)
193-
->will($this->returnSelf());
194-
195-
$this->cookieMetadataFactory->expects($this->once())
196-
->method('createPublicCookieMetadata')
197-
->will($this->returnValue($cookieMetadata));
198-
199-
$this->cookieManager->expects($this->once())
200-
->method('getCookie')
201-
->with($name)
202-
->will($this->returnValue($cookie));
203-
$this->cookieManager->expects($this->once())
204-
->method('setPublicCookie')
205-
->with($name, $cookie, $cookieMetadata);
206-
207-
$this->config->expects($this->once())
208-
->method('getValue')
209-
->with(\Magento\Backend\Model\Auth\Session::XML_PATH_SESSION_LIFETIME)
210-
->will($this->returnValue($lifetime));
211-
$this->sessionConfig->expects($this->once())
212-
->method('getCookiePath')
213-
->will($this->returnValue($path));
214-
$this->sessionConfig->expects($this->once())
215-
->method('getCookieDomain')
216-
->will($this->returnValue($domain));
217-
$this->sessionConfig->expects($this->once())
218-
->method('getCookieSecure')
219-
->will($this->returnValue($secure));
220-
$this->sessionConfig->expects($this->once())
221-
->method('getCookieHttpOnly')
222-
->will($this->returnValue($httpOnly));
223-
224165
$this->session->prolong();
225-
226166
$this->assertLessThanOrEqual(time(), $this->session->getUpdatedAt());
227167
}
228168

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Backend\Test\Unit\Model\Config\SessionLifetime;
7+
8+
use Magento\Backend\Model\Config\SessionLifetime\BackendModel;
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
10+
11+
class BackendModelTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @dataProvider adminSessionLifetimeDataProvider
15+
*/
16+
public function testBeforeSave($value, $errorMessage = null)
17+
{
18+
/** @var BackendModel $model */
19+
$model = (new ObjectManager($this))->getObject('Magento\Backend\Model\Config\SessionLifetime\BackendModel');
20+
if ($errorMessage !== null) {
21+
$this->setExpectedException('\Magento\Framework\Exception\LocalizedException', $errorMessage);
22+
}
23+
$model->setValue($value);
24+
$model->beforeSave();
25+
}
26+
27+
public function adminSessionLifetimeDataProvider()
28+
{
29+
return [
30+
[
31+
BackendModel::MIN_LIFETIME - 1,
32+
'Admin session lifetime must be greater than or equal to 60 seconds'
33+
],
34+
[
35+
BackendModel::MAX_LIFETIME + 1,
36+
'Admin session lifetime must be less than or equal to 31536000 seconds (one year)'
37+
],
38+
[
39+
900
40+
]
41+
];
42+
}
43+
}

app/code/Magento/Backend/etc/adminhtml/system.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@
388388
</field>
389389
<field id="session_lifetime" translate="label comment" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
390390
<label>Admin Session Lifetime (seconds)</label>
391-
<comment>Values less than 60 are ignored.</comment>
391+
<comment>Please enter at least 60 and at most 31536000 (one year).</comment>
392+
<backend_model>Magento\Backend\Model\Config\SessionLifetime\BackendModel</backend_model>
392393
<validate>validate-digits</validate>
393394
</field>
394395
</group>

app/code/Magento/Backend/i18n/en_US.csv

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,9 @@ Security,Security
556556
"Add Secret Key to URLs","Add Secret Key to URLs"
557557
"Login is Case Sensitive","Login is Case Sensitive"
558558
"Admin Session Lifetime (seconds)","Admin Session Lifetime (seconds)"
559-
"Values less than 60 are ignored.","Values less than 60 are ignored."
559+
"Please enter at least 60 and at most 31536000 (one year).","Please enter at least 60 and at most 31536000 (one year)."
560+
"Admin session lifetime must be less than or equal to 31536000 seconds (one year)","Admin session lifetime must be less than or equal to 31536000 seconds (one year)"
561+
"Admin session lifetime must be greater than or equal to 60 seconds","Admin session lifetime must be greater than or equal to 60 seconds"
560562
Web,Web
561563
"Url Options","Url Options"
562564
"Add Store Code to Urls","Add Store Code to Urls"

app/code/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Bundle.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ protected function processBundleOptionsData(\Magento\Catalog\Model\Product $prod
130130
if ((bool)$optionData['delete']) {
131131
continue;
132132
}
133+
133134
$option = $this->optionFactory->create(['data' => $optionData]);
134135
$option->setSku($product->getSku());
135136
$option->setOptionId(null);

app/code/Magento/Bundle/Model/ResourceModel/Indexer/Stock.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,7 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f
158158
);
159159
$this->_addAttributeToSelect($select, 'status', "e.$linkField", 'cs.store_id', $condition);
160160

161-
if ($this->_isManageStock()) {
162-
$statusExpr = $connection->getCheckSql(
163-
'cisi.use_config_manage_stock = 0 AND cisi.manage_stock = 0',
164-
'1',
165-
'cisi.is_in_stock'
166-
);
167-
} else {
168-
$statusExpr = $connection->getCheckSql(
169-
'cisi.use_config_manage_stock = 0 AND cisi.manage_stock = 1',
170-
'cisi.is_in_stock',
171-
'1'
172-
);
173-
}
174-
161+
$statusExpr = $this->getStatusExpression($connection);
175162
$select->columns(
176163
[
177164
'status' => $connection->getLeastSql(

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Inventory.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class Inventory extends \Magento\Backend\Block\Widget implements \Magento\Backen
2020
*/
2121
protected $stockConfiguration;
2222

23+
/**
24+
* @var array
25+
*/
26+
protected $disabledFields = [];
27+
2328
/**
2429
* @param \Magento\Backend\Block\Template\Context $context
2530
* @param \Magento\CatalogInventory\Model\Source\Backorders $backorders
@@ -112,4 +117,14 @@ public function isHidden()
112117
{
113118
return false;
114119
}
120+
121+
/**
122+
* @param string $fieldName
123+
* @return bool
124+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
125+
*/
126+
public function isAvailable($fieldName)
127+
{
128+
return true;
129+
}
115130
}

0 commit comments

Comments
 (0)