Skip to content

Commit

Permalink
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop
Browse files Browse the repository at this point in the history
Accepted Community Pull Requests:
 - #30405: 26133: Fixed - Coupon code text field not display in proper width in … (by @solwininfotech)
 - #30454: Remove incorrect use important in swatches option text (by @mrtuvn)
 - #30458: [Fixed-30452] - Design issue in minicart item remove confirmation modal (by @niravkrish)
 - #30355: Fix #30296 - Wrong ip value in sendfriend_log table (by @Bartlomiejsz)


Fixed GitHub Issues:
 - #26133: Coupon code text field not display in proper width in  Internet Explorer/EDGE browser (reported by @hasim32) has been fixed in #30405 by @solwininfotech in 2.4-develop branch
   Related commits:
     1. a535faa
     2. a37cf33
     3. e8ad9ae

 - #30496: [Issue] Remove incorrect use important in swatches option text (reported by @m2-assistant[bot]) has been fixed in #30454 by @mrtuvn in 2.4-develop branch
   Related commits:
     1. df5ae12

 - #30452: Design issue in minicart item remove confirmation modal. (reported by @saumya1998) has been fixed in #30458 by @niravkrish in 2.4-develop branch
   Related commits:
     1. daf0dc6

 - #30296: Wrong ip value in send friend_log table (reported by @magento-engcom-team) has been fixed in #30355 by @Bartlomiejsz in 2.4-develop branch
   Related commits:
     1. ccc83b2
     2. bc53649
  • Loading branch information
magento-engcom-team authored Oct 16, 2020
2 parents afd7ecc + 488506f commit c0f3dfb
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 49 deletions.
12 changes: 6 additions & 6 deletions app/code/Magento/SendFriend/Model/ResourceModel/SendFriend.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
namespace Magento\SendFriend\Model\ResourceModel;

/**
* SendFriend Log Resource Model
*
* @author Magento Core Team <[email protected]>
*
* @api
* @since 100.0.2
*/
Expand All @@ -32,6 +28,7 @@ protected function _construct()
* @param int $ip
* @param int $startTime
* @param int $websiteId
*
* @return int
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
Expand All @@ -46,7 +43,7 @@ public function getSendCount($object, $ip, $startTime, $websiteId = null)
AND time>=:time
AND website_id=:website_id'
);
$bind = ['ip' => ip2long($ip), 'time' => $startTime, 'website_id' => (int)$websiteId];
$bind = ['ip' => $ip, 'time' => $startTime, 'website_id' => (int)$websiteId];

$row = $connection->fetchRow($select, $bind);
return $row['count'];
Expand All @@ -58,21 +55,24 @@ public function getSendCount($object, $ip, $startTime, $websiteId = null)
* @param int $ip
* @param int $startTime
* @param int $websiteId
*
* @return $this
*/
public function addSendItem($ip, $startTime, $websiteId)
{
$this->getConnection()->insert(
$this->getMainTable(),
['ip' => ip2long($ip), 'time' => $startTime, 'website_id' => $websiteId]
['ip' => $ip, 'time' => $startTime, 'website_id' => $websiteId]
);

return $this;
}

/**
* Delete Old logs
*
* @param int $time
*
* @return $this
*/
public function deleteLogsBefore($time)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
// _____________________________________________

& when (@media-common = true) {

.swatch {
&-attribute {
&-label {
Expand Down Expand Up @@ -155,7 +154,7 @@
padding: 4px 8px;

&.selected {
.lib-css(background-color, @swatch-option-text__selected__background-color) !important;
.lib-css(background-color, @swatch-option-text__selected__background-color);
}
}

Expand Down Expand Up @@ -201,21 +200,22 @@
top: 0;
}
}

&-disabled {
border: 0;
cursor: default;
outline: none !important;

&:after {
.lib-rotate(-30deg);
.lib-css(background, @swatch-option__disabled__background);
content: '';
height: 2px;
left: -4px;
position: absolute;
top: 10px;
width: 42px;
z-index: 995;
.lib-css(background, @swatch-option__disabled__background);
}
}

Expand All @@ -226,6 +226,7 @@
&-tooltip {
.lib-css(border, @swatch-option-tooltip__border);
.lib-css(color, @swatch-option-tooltip__color);
.lib-css(background, @swatch-option-tooltip__background);
display: none;
max-height: 100%;
min-height: 20px;
Expand All @@ -234,7 +235,6 @@
position: absolute;
text-align: center;
z-index: 999;
.lib-css(background, @swatch-option-tooltip__background);

&,
&-layered {
Expand Down Expand Up @@ -278,9 +278,9 @@
}

&-layered {
.lib-css(background, @swatch-option-tooltip-layered__background);
.lib-css(border, @swatch-option-tooltip-layered__border);
.lib-css(color, @swatch-option-tooltip-layered__color);
.lib-css(background, @swatch-option-tooltip-layered__background);
display: none;
left: -47px;
position: absolute;
Expand Down Expand Up @@ -326,7 +326,6 @@
margin: 2px 0;
padding: 2px;
position: static;
z-index: 1;
}

&-visual-tooltip-layered {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
.lib-icon-font-symbol(
@_icon-font-content: @icon-trash
);

&:hover {
.lib-css(text-decoration, @link__text-decoration);
}
Expand Down Expand Up @@ -574,7 +574,7 @@

.widget {
float: left;

&.block {
margin-bottom: @indent__base;
}
Expand Down Expand Up @@ -727,9 +727,14 @@
position: static;
}
}

&.discount {
width: auto;
}

.actions-toolbar {
width: auto;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Magento\SendFriend\Helper\Data as SendFriendHelper;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
use Zend\Stdlib\Parameters;
use Laminas\Stdlib\Parameters;

/**
* Class checks send friend model behavior
Expand All @@ -28,6 +28,9 @@ class SendFriendTest extends TestCase
/** @var SendFriend */
private $sendFriend;

/** @var ResourceModel\SendFriend */
private $sendFriendResource;

/** @var CookieManagerInterface */
private $cookieManager;

Expand All @@ -43,6 +46,7 @@ protected function setUp(): void

$this->objectManager = Bootstrap::getObjectManager();
$this->sendFriend = $this->objectManager->get(SendFriendFactory::class)->create();
$this->sendFriendResource = $this->objectManager->get(ResourceModel\SendFriend::class);
$this->cookieManager = $this->objectManager->get(CookieManagerInterface::class);
$this->request = $this->objectManager->get(RequestInterface::class);
}
Expand All @@ -55,6 +59,7 @@ protected function setUp(): void
* @param array $sender
* @param array $recipients
* @param string|bool $expectedResult
*
* @return void
*/
public function testValidate(array $sender, array $recipients, $expectedResult): void
Expand Down Expand Up @@ -185,22 +190,34 @@ public function testisExceedLimitByCookies(): void
* @magentoDataFixture Magento/SendFriend/_files/sendfriend_log_record_half_hour_before.php
*
* @magentoDbIsolation disabled
*
* @return void
*/
public function testisExceedLimitByIp(): void
{
$this->markTestSkipped('Blocked by MC-31968');
$remoteAddr = '127.0.0.1';
$parameters = $this->objectManager->create(Parameters::class);
$parameters->set('REMOTE_ADDR', '127.0.0.1');
$parameters->set('REMOTE_ADDR', $remoteAddr);
$this->request->setServer($parameters);
$this->assertTrue($this->sendFriend->isExceedLimit());
// Verify that ip is saved correctly as integer value
$this->assertEquals(
1,
(int)$this->sendFriendResource->getSendCount(
null,
ip2long($remoteAddr),
time() - (60 * 60 * 24 * 365),
1
)
);
}

/**
* Check result
* Check test result
*
* @param array|bool $expectedResult
* @param array|bool $result
*
* @return void
*/
private function checkResult($expectedResult, $result): void
Expand All @@ -217,6 +234,7 @@ private function checkResult($expectedResult, $result): void
*
* @param array $sender
* @param array $recipients
*
* @return void
*/
private function prepareData(array $sender, array $recipients): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function (string $ip) {
public function getRemoteAddress(bool $ipToLong = false)
{
if ($this->remoteAddress !== null) {
return $this->remoteAddress;
return $ipToLong ? ip2long($this->remoteAddress) : $this->remoteAddress;
}

$remoteAddress = $this->readAddress();
Expand All @@ -135,11 +135,11 @@ public function getRemoteAddress(bool $ipToLong = false)
$this->remoteAddress = false;

return false;
} else {
$this->remoteAddress = $remoteAddress;

return $ipToLong ? ip2long($this->remoteAddress) : $this->remoteAddress;
}

$this->remoteAddress = $remoteAddress;

return $ipToLong ? ip2long($this->remoteAddress) : $this->remoteAddress;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,28 @@

use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\HTTP\PhpEnvironment\RemoteAddress;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* Test for
*
* @see RemoteAddress
*/
class RemoteAddressTest extends TestCase
{
/**
* @var MockObject|HttpRequest
*/
protected $_request;

/**
* @var ObjectManager
*/
protected $_objectManager;
private $requestMock;

/**
* @inheritdoc
*/
protected function setUp(): void
{
$this->_request = $this->getMockBuilder(HttpRequest::class)
$this->requestMock = $this->getMockBuilder(HttpRequest::class)
->disableOriginalConstructor()
->setMethods(['getServer'])
->onlyMethods(['getServer'])
->getMock();

$this->_objectManager = new ObjectManager($this);
}

/**
Expand All @@ -49,6 +39,7 @@ protected function setUp(): void
* @param string|bool $expected
* @param bool $ipToLong
* @param string[]|null $trustedProxies
*
* @return void
* @dataProvider getRemoteAddressProvider
*/
Expand All @@ -59,18 +50,16 @@ public function testGetRemoteAddress(
bool $ipToLong,
array $trustedProxies = null
): void {
$remoteAddress = $this->_objectManager->getObject(
RemoteAddress::class,
[
'httpRequest' => $this->_request,
'alternativeHeaders' => $alternativeHeaders,
'trustedProxies' => $trustedProxies,
]
$remoteAddress = new RemoteAddress(
$this->requestMock,
$alternativeHeaders,
$trustedProxies
);
$this->_request->expects($this->any())
->method('getServer')
$this->requestMock->method('getServer')
->willReturnMap($serverValueMap);

// Check twice to verify if internal variable is cached correctly
$this->assertEquals($expected, $remoteAddress->getRemoteAddress($ipToLong));
$this->assertEquals($expected, $remoteAddress->getRemoteAddress($ipToLong));
}

Expand Down
4 changes: 0 additions & 4 deletions lib/web/css/source/components/_modals.less
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@
&.confirm {
.modal-inner-wrap {
.lib-css(max-width, @modal-popup-confirm__width);

.modal-content {
padding-right: 7rem;
}
}
}

Expand Down

0 comments on commit c0f3dfb

Please sign in to comment.