Skip to content

Commit

Permalink
Merge pull request #1 from keyuremipro/2.2-develop-PR-port-20027
Browse files Browse the repository at this point in the history
[Backport] hardcoded table name
  • Loading branch information
keyurk-emipro authored Feb 14, 2019
2 parents eb6946b + ad9a893 commit a03f2f3
Show file tree
Hide file tree
Showing 290 changed files with 6,644 additions and 969 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*/
namespace Magento\Backend\Controller\Adminhtml\System\Design;

/**
* Save design action.
*/
class Save extends \Magento\Backend\Controller\Adminhtml\System\Design
{
/**
Expand All @@ -26,6 +29,8 @@ protected function _filterPostData($data)
}

/**
* Save design action.
*
* @return \Magento\Backend\Model\View\Result\Redirect
*/
public function execute()
Expand Down Expand Up @@ -54,10 +59,10 @@ public function execute()
} catch (\Exception $e) {
$this->messageManager->addErrorMessage($e->getMessage());
$this->_objectManager->get(\Magento\Backend\Model\Session::class)->setDesignData($data);
return $resultRedirect->setPath('adminhtml/*/', ['id' => $design->getId()]);
return $resultRedirect->setPath('*/*/edit', ['id' => $design->getId()]);
}
}

return $resultRedirect->setPath('adminhtml/*/');
return $resultRedirect->setPath('*/*/');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<pages xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<page name="AdminConfigurationGeneralSectionPage" url="admin/system_config/edit/section/general/{{group_anchor}}" parameterized="true" area="admin" module="Magento_Config">
<section name="AdminConfigurationGeneralSectionCountryOptionsGroupSection"/>
<section name="LocaleOptionsSection"/>
</page>
</pages>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-->

<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd">
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
<page name="ConfigurationStoresPage" url="admin/system_config/edit/section/cms/" area="admin" module="Catalog">
<section name="WYSIWYGOptionsSection"/>
</page>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminMainActionsSection">
<element name="save" type="button" selector="#save" timeout="30"/>
<element name="delete" type="button" selector="#delete"/>
<element name="delete" type="button" selector="#delete" timeout="30"/>
<element name="add" type="button" selector="#add" timeout="30"/>
<element name="back" type="button" selector="#back" timeout="30"/>
<element name="saveAndContinue" type="button" selector="button[id*=save_and_]" timeout="30"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminPopupModalSection">
<element name="message" type="text" selector="aside.modal-popup .modal-content .popup-window-content"/>
<element name="ok" type="button" selector="//span[contains(text(),'Ok')]/ancestor::button"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="LocaleOptionsSection">
<element name="timezone" type="select" selector="#general_locale_timezone"/>
<element name="useDefault" type="checkbox" selector="#general_locale_timezone_inherit"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@
<actionGroup name="CreateBundleProductForTwoSimpleProductsWithRadioTypeOptions" extends="CreateBundleProductForTwoSimpleProducts">
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="Radio Buttons" after="fillOptionTitle" stepKey="selectInputType"/>
</actionGroup>

<actionGroup name="CreateBundleProductForOneSimpleProductsWithRadioTypeOption" extends="CreateBundleProductForTwoSimpleProducts">
<remove keyForRemoval="clickOnFiltersButton2"/>
<remove keyForRemoval="clearFilters2"/>
<remove keyForRemoval="fillNameFilter2"/>
<remove keyForRemoval="applyFilters2"/>
<remove keyForRemoval="selectSecondSimple"/>
<remove keyForRemoval="fillDefaultQuantityForSecondProduct"/>
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="Radio Buttons" after="fillOptionTitle" stepKey="selectInputType"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
<element name="addProductsToOption" type="button" selector="[data-index='modal_set']" timeout="30"/>
<element name="bundleOptionXProductYQuantity" type="input" selector="[name='bundle_options[bundle_options][{{x}}][bundle_selections][{{y}}][selection_qty]']" parameterized="true"/>
<element name="bundledItems" type="block" selector="[data-index=bundle-items]"/>
<element name="priceTypeSwitcher" type="button" selector="div[data-index='price_type'] div[data-role='switcher']" timeout="30"/>
<element name="bundleSelectionPriceType" type="select" selector="bundle_options[bundle_options][0][bundle_selections][0][selection_price_type]"/>
<element name="bundleSelectionPriceValue" type="input" selector="bundle_options[bundle_options][0][bundle_selections][0][selection_price_value]"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Magento\Bundle\Test\Unit\Pricing\Price;

use \Magento\Bundle\Pricing\Price\SpecialPrice;
use Magento\Store\Api\Data\WebsiteInterface;

class SpecialPriceTest extends \PHPUnit\Framework\TestCase
{
Expand Down Expand Up @@ -77,12 +78,6 @@ public function testGetValue($regularPrice, $specialPrice, $isScopeDateInInterva
->method('getSpecialPrice')
->will($this->returnValue($specialPrice));

$store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
->disableOriginalConstructor()
->getMock();
$this->saleable->expects($this->once())
->method('getStore')
->will($this->returnValue($store));
$this->saleable->expects($this->once())
->method('getSpecialFromDate')
->will($this->returnValue($specialFromDate));
Expand All @@ -92,7 +87,7 @@ public function testGetValue($regularPrice, $specialPrice, $isScopeDateInInterva

$this->localeDate->expects($this->once())
->method('isScopeDateInInterval')
->with($store, $specialFromDate, $specialToDate)
->with(WebsiteInterface::ADMIN_CODE, $specialFromDate, $specialToDate)
->will($this->returnValue($isScopeDateInInterval));

$this->priceCurrencyMock->expects($this->never())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Magento\Framework\UrlInterface;
use Magento\Ui\Component\Container;
use Magento\Ui\Component\Form;
use Magento\Ui\Component\Form\Fieldset;
use Magento\Ui\Component\Modal;

/**
Expand Down Expand Up @@ -69,13 +70,26 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function modifyMeta(array $meta)
{
$meta = $this->removeFixedTierPrice($meta);
$path = $this->arrayManager->findPath(static::CODE_BUNDLE_DATA, $meta, null, 'children');

$groupCode = static::CODE_BUNDLE_DATA;
$path = $this->arrayManager->findPath($groupCode, $meta, null, 'children');
if (empty($path)) {
$meta[$groupCode]['children'] = [];
$meta[$groupCode]['arguments']['data']['config'] = [
'componentType' => Fieldset::NAME,
'label' => __('Bundle Items'),
'collapsible' => true,
];

$path = $this->arrayManager->findPath($groupCode, $meta, null, 'children');
}

$meta = $this->arrayManager->merge(
$path,
Expand Down Expand Up @@ -220,7 +234,7 @@ private function removeFixedTierPrice(array $meta)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function modifyData(array $data)
{
Expand Down
76 changes: 71 additions & 5 deletions app/code/Magento/CacheInvalidate/Model/PurgeCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

use Magento\Framework\Cache\InvalidateLogger;

/**
* Purge cache action.
*/
class PurgeCache
{
const HEADER_X_MAGENTO_TAGS_PATTERN = 'X-Magento-Tags-Pattern';
Expand All @@ -26,6 +29,18 @@ class PurgeCache
*/
private $logger;

/**
* Batch size of the purge request.
*
* Based on default Varnish 4 http_req_hdr_len size minus a 512 bytes margin for method,
* header name, line feeds etc.
*
* @see https://varnish-cache.org/docs/4.1/reference/varnishd.html
*
* @var int
*/
private $requestSize = 7680;

/**
* Constructor
*
Expand All @@ -44,18 +59,68 @@ public function __construct(
}

/**
* Send curl purge request
* to invalidate cache by tags pattern
* Send curl purge request to invalidate cache by tags pattern.
*
* @param string $tagsPattern
* @return bool Return true if successful; otherwise return false
*/
public function sendPurgeRequest($tagsPattern)
{
$successful = true;
$socketAdapter = $this->socketAdapterFactory->create();
$servers = $this->cacheServer->getUris();
$headers = [self::HEADER_X_MAGENTO_TAGS_PATTERN => $tagsPattern];
$socketAdapter->setOptions(['timeout' => 10]);

$formattedTagsChunks = $this->splitTags($tagsPattern);
foreach ($formattedTagsChunks as $formattedTagsChunk) {
if (!$this->sendPurgeRequestToServers($socketAdapter, $servers, $formattedTagsChunk)) {
$successful = false;
}
}

return $successful;
}

/**
* Split tags by batches
*
* @param string $tagsPattern
* @return \Generator
*/
private function splitTags(string $tagsPattern) : \Generator
{
$tagsBatchSize = 0;
$formattedTagsChunk = [];
$formattedTags = explode('|', $tagsPattern);
foreach ($formattedTags as $formattedTag) {
if ($tagsBatchSize + strlen($formattedTag) > $this->requestSize - count($formattedTagsChunk) - 1) {
yield implode('|', $formattedTagsChunk);
$formattedTagsChunk = [];
$tagsBatchSize = 0;
}

$tagsBatchSize += strlen($formattedTag);
$formattedTagsChunk[] = $formattedTag;
}
if (!empty($formattedTagsChunk)) {
yield implode('|', $formattedTagsChunk);
}
}

/**
* Send curl purge request to servers to invalidate cache by tags pattern.
*
* @param \Zend\Http\Client\Adapter\Socket $socketAdapter
* @param \Zend\Uri\Uri[] $servers
* @param string $formattedTagsChunk
* @return bool Return true if successful; otherwise return false
*/
private function sendPurgeRequestToServers(
\Zend\Http\Client\Adapter\Socket $socketAdapter,
array $servers,
string $formattedTagsChunk
): bool {
$headers = [self::HEADER_X_MAGENTO_TAGS_PATTERN => $formattedTagsChunk];
foreach ($servers as $server) {
$headers['Host'] = $server->getHost();
try {
Expand All @@ -69,12 +134,13 @@ public function sendPurgeRequest($tagsPattern)
$socketAdapter->read();
$socketAdapter->close();
} catch (\Exception $e) {
$this->logger->critical($e->getMessage(), compact('server', 'tagsPattern'));
$this->logger->critical($e->getMessage(), compact('server', 'formattedTagsChunk'));

return false;
}
}
$this->logger->execute(compact('servers', 'formattedTagsChunk'));

$this->logger->execute(compact('servers', 'tagsPattern'));
return true;
}
}
Loading

0 comments on commit a03f2f3

Please sign in to comment.