Skip to content

Commit 50d6f9a

Browse files
committed
Merge pull request magento#550 from magento-south/BUGS
[South] Story + Bugs
2 parents 26165fa + 0ff6408 commit 50d6f9a

File tree

52 files changed

+767
-2270
lines changed

Some content is hidden

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

52 files changed

+767
-2270
lines changed

app/code/Magento/Catalog/Helper/Image.php

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Image extends AbstractHelper
2626
*
2727
* @var bool
2828
*/
29-
protected $_scheduleResize = false;
29+
protected $_scheduleResize = true;
3030

3131
/**
3232
* Scheduled for rotate image
@@ -146,7 +146,6 @@ public function __construct(
146146
protected function _reset()
147147
{
148148
$this->_model = null;
149-
$this->_scheduleResize = false;
150149
$this->_scheduleRotate = false;
151150
$this->_angle = null;
152151
$this->_watermark = null;
@@ -446,14 +445,9 @@ public function getPlaceholder($placeholder = null)
446445
*/
447446
protected function applyScheduledActions()
448447
{
449-
$model = $this->_getModel();
450-
if ($this->getImageFile()) {
451-
$model->setBaseFile($this->getImageFile());
452-
} else {
453-
$model->setBaseFile($this->getProduct()->getData($model->getDestinationSubdir()));
454-
}
455-
456-
if (!$model->isCached()) {
448+
$this->initBaseFile();
449+
if ($this->isScheduledActionsAllowed()) {
450+
$model = $this->_getModel();
457451
if ($this->_scheduleRotate) {
458452
$model->rotate($this->getAngle());
459453
}
@@ -468,6 +462,42 @@ protected function applyScheduledActions()
468462
return $this;
469463
}
470464

465+
/**
466+
* Initialize base image file
467+
*
468+
* @return $this
469+
*/
470+
protected function initBaseFile()
471+
{
472+
$model = $this->_getModel();
473+
$baseFile = $model->getBaseFile();
474+
if (!$baseFile) {
475+
if ($this->getImageFile()) {
476+
$model->setBaseFile($this->getImageFile());
477+
} else {
478+
$model->setBaseFile($this->getProduct()->getData($model->getDestinationSubdir()));
479+
}
480+
}
481+
return $this;
482+
}
483+
484+
/**
485+
* Check if scheduled actions is allowed
486+
*
487+
* @return bool
488+
*/
489+
protected function isScheduledActionsAllowed()
490+
{
491+
$model = $this->_getModel();
492+
if ($model->isBaseFilePlaceholder()
493+
&& $model->getNewFile() === true
494+
|| $model->isCached()
495+
) {
496+
return false;
497+
}
498+
return true;
499+
}
500+
471501
/**
472502
* Retrieve image URL
473503
*
@@ -499,13 +529,8 @@ public function save()
499529
*/
500530
public function getResizedImageInfo()
501531
{
502-
$model = $this->_getModel();
503-
if ($this->getImageFile()) {
504-
$model->setBaseFile($this->getImageFile());
505-
} else {
506-
$model->setBaseFile($this->getProduct()->getData($model->getDestinationSubdir()));
507-
}
508-
return $model->getResizedImageInfo();
532+
$this->applyScheduledActions();
533+
return $this->_getModel()->getResizedImageInfo();
509534
}
510535

511536
/**

app/code/Magento/Catalog/Model/Product/Image.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,16 @@ public function getNewFile()
546546
return $this->_newFile;
547547
}
548548

549+
/**
550+
* Retrieve 'true' if image is a base file placeholder
551+
*
552+
* @return bool
553+
*/
554+
public function isBaseFilePlaceholder()
555+
{
556+
return (bool)$this->_isBaseFilePlaceholder;
557+
}
558+
549559
/**
550560
* @param MagentoImage $processor
551561
* @return $this

app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,4 +419,155 @@ public function getLabelDataProvider()
419419
],
420420
];
421421
}
422+
423+
/**
424+
* @param string $imageId
425+
* @param string $imageFile
426+
* @param string $baseFile
427+
* @param string $newFile
428+
* @param string $destination
429+
* @param boolean $setImageFile
430+
* @param boolean $isCached
431+
* @param boolean $isBaseFilePlaceholder
432+
* @param array $resizedImageInfo
433+
* @dataProvider getResizedImageInfoDataProvider
434+
*/
435+
public function testGetResizedImageInfo(
436+
$imageId,
437+
$imageFile,
438+
$baseFile,
439+
$newFile,
440+
$destination,
441+
$setImageFile,
442+
$isCached,
443+
$isBaseFilePlaceholder,
444+
$resizedImageInfo
445+
) {
446+
$productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')
447+
->disableOriginalConstructor()
448+
->getMock();
449+
450+
$productMock->expects($this->any())
451+
->method('getData')
452+
->with($destination)
453+
->willReturn($imageFile);
454+
455+
$this->image->expects($this->any())
456+
->method('setBaseFile')
457+
->with($imageFile)
458+
->willReturnSelf();
459+
$this->image->expects($this->once())
460+
->method('getBaseFile')
461+
->willReturn($baseFile);
462+
$this->image->expects($this->any())
463+
->method('getDestinationSubdir')
464+
->willReturn($destination);
465+
$this->image->expects($this->any())
466+
->method('isCached')
467+
->willReturn($isCached);
468+
$this->image->expects($this->any())
469+
->method('resize')
470+
->willReturnSelf();
471+
$this->image->expects($this->any())
472+
->method('saveFile')
473+
->willReturnSelf();
474+
$this->image->expects($this->once())
475+
->method('getResizedImageInfo')
476+
->willReturn($resizedImageInfo);
477+
$this->image->expects($this->any())
478+
->method('isBaseFilePlaceholder')
479+
->willReturn($isBaseFilePlaceholder);
480+
$this->image->expects($this->any())
481+
->method('getNewFile')
482+
->willReturn($newFile);
483+
484+
$this->prepareAttributes([], $imageId);
485+
486+
$this->helper->init($productMock, $imageId);
487+
if ($setImageFile) {
488+
$this->helper->setImageFile($imageFile);
489+
}
490+
491+
$result = $this->helper->getResizedImageInfo();
492+
$this->assertEquals($resizedImageInfo, $result);
493+
}
494+
495+
/**
496+
* @return array
497+
*/
498+
public function getResizedImageInfoDataProvider()
499+
{
500+
return [
501+
[
502+
'image_id' => 'test_image_id',
503+
'image_file' => '/path/to/test_image_id.png',
504+
'base_file' => '/path/to/base_image.png',
505+
'new_file' => '/path/to/base_image.png',
506+
'destination' => 'small_image',
507+
'set_image_file' => true,
508+
'is_cached' => false,
509+
'is_base_file_placeholder' => false,
510+
'resized_image_info' => [
511+
'x' => 100,
512+
'y' => 100,
513+
],
514+
],
515+
[
516+
'image_id' => 'test_image_id',
517+
'image_file' => '/path/to/test_image_id.png',
518+
'base_file' => null,
519+
'new_file' => true,
520+
'destination' => 'small_image',
521+
'set_image_file' => false,
522+
'is_cached' => false,
523+
'is_base_file_placeholder' => false,
524+
'resized_image_info' => [
525+
'x' => 100,
526+
'y' => 100,
527+
],
528+
],
529+
[
530+
'image_id' => 'test_image_id',
531+
'image_file' => '/path/to/test_image_id.png',
532+
'base_file' => null,
533+
'new_file' => false,
534+
'destination' => 'small_image',
535+
'set_image_file' => true,
536+
'is_cached' => false,
537+
'is_base_file_placeholder' => false,
538+
'resized_image_info' => [
539+
'x' => 100,
540+
'y' => 100,
541+
],
542+
],
543+
[
544+
'image_id' => 'test_image_id',
545+
'image_file' => '/path/to/test_image_id.png',
546+
'base_file' => null,
547+
'new_file' => true,
548+
'destination' => 'small_image',
549+
'set_image_file' => true,
550+
'is_cached' => false,
551+
'is_base_file_placeholder' => true,
552+
'resized_image_info' => [
553+
'x' => 100,
554+
'y' => 100,
555+
],
556+
],
557+
[
558+
'image_id' => 'test_image_id',
559+
'image_file' => '/path/to/test_image_id.png',
560+
'base_file' => null,
561+
'new_file' => '/path/to/test_image_id.png',
562+
'destination' => 'small_image',
563+
'set_image_file' => true,
564+
'is_cached' => false,
565+
'is_base_file_placeholder' => false,
566+
'resized_image_info' => [
567+
'x' => 100,
568+
'y' => 100,
569+
],
570+
],
571+
];
572+
}
422573
}

app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,4 +343,9 @@ public function testGetImageProcessor()
343343
$this->factory->expects($this->once())->method('create')->will($this->returnValue($imageProcessor));
344344
$this->assertSame($imageProcessor, $this->image->getImageProcessor());
345345
}
346+
347+
public function testIsBaseFilePlaceholder()
348+
{
349+
$this->assertFalse($this->image->isBaseFilePlaceholder());
350+
}
346351
}

app/code/Magento/Checkout/Model/DefaultConfigProvider.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,23 @@ public function getConfig()
302302
$output['activeCarriers'] = $this->getActiveCarriers();
303303
$output['originCountryCode'] = $this->getOriginCountryCode();
304304
$output['paymentMethods'] = $this->getPaymentMethods();
305+
$output['autocomplete'] = $this->isAutocompleteEnabled();
305306
return $output;
306307
}
307308

309+
/**
310+
* Is autocomplete enabled for storefront
311+
*
312+
* @return string
313+
*/
314+
private function isAutocompleteEnabled()
315+
{
316+
return $this->scopeConfig->getValue(
317+
\Magento\Customer\Model\Form::XML_PATH_ENABLE_AUTOCOMPLETE,
318+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
319+
) ? 'on' : 'off';
320+
}
321+
308322
/**
309323
* Retrieve customer data
310324
*

app/code/Magento/Checkout/view/frontend/web/js/view/authentication.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ define(
2121
isCustomerLoginRequired: checkoutConfig.isCustomerLoginRequired,
2222
registerUrl: checkoutConfig.registerUrl,
2323
forgotPasswordUrl: checkoutConfig.forgotPasswordUrl,
24+
autocomplete: checkoutConfig.autocomplete,
2425
defaults: {
2526
template: 'Magento_Checkout/authentication'
2627
},

app/code/Magento/Checkout/view/frontend/web/template/authentication.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
class="input-text"
5050
id="login-email"
5151
name="username"
52+
data-bind="attr: {autocomplete: autocomplete}"
5253
data-validate="{required:true, 'validate-email':true}" />
5354
</div>
5455
</div>
@@ -59,7 +60,8 @@
5960
class="input-text"
6061
id="login-password"
6162
name="password"
62-
data-validate="{required:true, 'validate-password':true}" autocomplete="off"/>
63+
data-bind="attr: {autocomplete: autocomplete}"
64+
data-validate="{required:true, 'validate-password':true}"/>
6365
</div>
6466
</div>
6567
<!-- ko foreach: getRegion('additional-login-form-fields') -->

app/code/Magento/Checkout/view/frontend/web/template/registration.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
</form>
1414
<!-- /ko -->
1515
<!-- ko if: accountCreated -->
16-
<p data-bind="i18n: 'Your password will be sent to your email'"></p>
16+
<p data-bind="i18n: $t('A letter with further instructions will be sent to your email.')"></p>
1717
<!-- /ko -->
1818
</div>

app/code/Magento/Customer/Block/Account/Resetpassword.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,16 @@
1010
*/
1111
class Resetpassword extends \Magento\Framework\View\Element\Template
1212
{
13+
/**
14+
* Check if autocomplete is disabled on storefront
15+
*
16+
* @return bool
17+
*/
18+
public function isAutocompleteDisabled()
19+
{
20+
return (bool)!$this->_scopeConfig->getValue(
21+
\Magento\Customer\Model\Form::XML_PATH_ENABLE_AUTOCOMPLETE,
22+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
23+
);
24+
}
1325
}

0 commit comments

Comments
 (0)