Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.3-develop Minor Fixes
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - #22421: Spelling correction (by @ansari-krish)
 - #22420: Correct spelling (by @ravi-chandra3197)
 - #19993: fixed issue of Backup tool not correctly detecting .maintenance.flag (by @hiren0241)
 - #22382: Don't skip row on import if image not available. (by @Nazar65)
 - #22263: Prevented /Magento/Sales/Model/Service/InvoiceService.php incorrectly� (by @ryanpalmerweb)
 - #22233: [Fixed] Full Tax Summary missing calculation Admin create order (by @niravkrish)
 - #21711:  Purchasing a downloadable product as guest then creating an account on the onepagesuccess step doesn't link product with account (by @Jitheesh)
 - #20174: Fix issues inserting Widgets with nested WYSIWYGs (by @molovo)
 - #21816: #21779 Adminhtml textarea field doesn't accept maxlength (by @kisroman)
 - #21756: Fixes race condition when building merged css/js file during simultaneous requests (by @Ian410)
 - #21670: Fix getSize method after clearing data collection (by @sergeynezbritskiy)


Fixed GitHub Issues:
 - #19825: Magento 2.3.0: Backup tool not correctly detecting .maintenance.flag (reported by @nexrobr) has been fixed in #19993 by @hiren0241 in 2.3-develop branch
   Related commits:
     1. fd92027
     2. 6374f9d
     3. 658b5a7
     4. 5bc05b2

 - #22355: Import product quantity is empty after import (reported by @kevinvuillemin) has been fixed in #22382 by @Nazar65 in 2.3-develop branch
   Related commits:
     1. e949e85
     2. bfc82b6
     3. b6784b5

 - #22246: Programatically created invoices miss items when both simple products and bundled products are mixed in an order (reported by @ryanpalmerweb) has been fixed in #22263 by @ryanpalmerweb in 2.3-develop branch
   Related commits:
     1. ec2c6ca

 - #21702: Purchasing a downloadable product as guest then creating an account on the onepagesuccess step doesn't link product with account (reported by @crankycyclops) has been fixed in #21711 by @Jitheesh in 2.3-develop branch
   Related commits:
     1. fc1434b
     2. 8652bc8
     3. 95b1d53
     4. 0ade930

 - #13409: custom widget with wysiwyg problem on insert widget via pages or blocks (reported by @deagleka) has been fixed in #20174 by @molovo in 2.3-develop branch
   Related commits:
     1. 3bcf0d8
     2. d4e0c28

 - #19742: Widgets with a WYSIWYG parameter fail when inserting them into a WYSIWYG in a form. (reported by @molovo) has been fixed in #20174 by @molovo in 2.3-develop branch
   Related commits:
     1. 3bcf0d8
     2. d4e0c28

 - #21779: Adminhtml textarea field doesn't accept maxlength (reported by @rafaelstz) has been fixed in #21816 by @kisroman in 2.3-develop branch
   Related commits:
     1. 1dc63e8
     2. 4a0fb16
     3. 149294b

 - #21654: \Magento\Framework\Data\Collection::clear does not clear the result for \Magento\Framework\Data\Collection::getSize (reported by @sergeynezbritskiy) has been fixed in #21670 by @sergeynezbritskiy in 2.3-develop branch
   Related commits:
     1. 2038d7d
     2. 71effbe
     3. eea6126
  • Loading branch information
magento-engcom-team authored Apr 23, 2019
2 parents 1d1c2ea + 62c86e4 commit 45a6365
Show file tree
Hide file tree
Showing 20 changed files with 272 additions and 88 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4335,7 +4335,7 @@ Tests:
* Fixed order placing with virtual product using Express Checkout
* Fixed the error during order placement with Recurring profile payment
* Fixed wrong redirect after customer registration during multishipping checkout
* Fixed inability to crate shipping labels
* Fixed inability to create shipping labels
* Fixed inability to switch language, if the default language is English
* Fixed an issue with incorrect XML appearing in cache after some actions on the frontend
* Fixed product export
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public function execute()
$this->_coreRegistry->register('backup_manager', $backupManager);

if ($this->getRequest()->getParam('maintenance_mode')) {
if (!$this->maintenanceMode->set(true)) {
$this->maintenanceMode->set(true);

if (!$this->maintenanceMode->isOn()) {
$response->setError(
__(
'You need more permissions to activate maintenance mode right now.'
Expand Down
10 changes: 8 additions & 2 deletions app/code/Magento/Backup/Controller/Adminhtml/Index/Rollback.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
*/
namespace Magento\Backup\Controller\Adminhtml\Index;

use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;

/**
* Backup rollback controller.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Rollback extends \Magento\Backup\Controller\Adminhtml\Index
class Rollback extends \Magento\Backup\Controller\Adminhtml\Index implements HttpPostActionInterface
{
/**
* Rollback Action
Expand Down Expand Up @@ -82,7 +85,9 @@ public function execute()
}

if ($this->getRequest()->getParam('maintenance_mode')) {
if (!$this->maintenanceMode->set(true)) {
$this->maintenanceMode->set(true);

if (!$this->maintenanceMode->isOn()) {
$response->setError(
__(
'You need more permissions to activate maintenance mode right now.'
Expand Down Expand Up @@ -122,6 +127,7 @@ public function execute()
$adminSession->destroy();

$response->setRedirectUrl($this->getUrl('*'));
// phpcs:disable Magento2.Exceptions.ThrowCatch
} catch (\Magento\Framework\Backup\Exception\CantLoadSnapshot $e) {
$errorMsg = __('We can\'t find the backup file.');
} catch (\Magento\Framework\Backup\Exception\FtpConnectionFailed $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function execute($product, $arguments = [])
}

/**
* Returns media gallery atribute instance
* Returns media gallery attribute instance
*
* @return \Magento\Catalog\Api\Data\ProductAttributeInterface
* @since 101.0.0
Expand All @@ -230,6 +230,7 @@ public function getAttribute()
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @since 101.0.0
* phpcs:disable Magento2.CodeAnalysis.EmptyBlock
*/
protected function processDeletedImages($product, array &$images)
{
Expand Down Expand Up @@ -400,6 +401,7 @@ protected function getUniqueFileName($file, $forTmp = false)
$destinationFile = $forTmp
? $this->mediaDirectory->getAbsolutePath($this->mediaConfig->getTmpMediaPath($file))
: $this->mediaDirectory->getAbsolutePath($this->mediaConfig->getMediaPath($file));
// phpcs:disable Magento2.Functions.DiscouragedFunction
$destFile = dirname($file) . '/' . FileUploader::getNewFileName($destinationFile);
}

Expand All @@ -420,6 +422,7 @@ protected function copyImage($file)
$destinationFile = $this->getUniqueFileName($file);

if (!$this->mediaDirectory->isFile($this->mediaConfig->getMediaPath($file))) {
// phpcs:ignore Magento2.Exceptions.DirectThrow
throw new \Exception();
}

Expand All @@ -437,6 +440,7 @@ protected function copyImage($file)
}

return str_replace('\\', '/', $destinationFile);
// phpcs:ignore Magento2.Exceptions.ThrowCatch
} catch (\Exception $e) {
$file = $this->mediaConfig->getMediaPath($file);
throw new \Magento\Framework\Exception\LocalizedException(
Expand Down
14 changes: 12 additions & 2 deletions app/code/Magento/CatalogImportExport/Model/Import/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,7 @@ protected function _prepareRowForDb(array $rowData)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* phpcs:disable Generic.Metrics.NestingLevel
*/
protected function _saveLinks()
{
Expand All @@ -1256,7 +1257,7 @@ protected function _saveLinks()
$nextLinkId = $this->_resourceHelper->getNextAutoincrement($mainTable);

// pre-load 'position' attributes ID for each link type once
foreach ($this->_linkNameToId as $linkName => $linkId) {
foreach ($this->_linkNameToId as $linkId) {
$select = $this->_connection->select()->from(
$resource->getTable('catalog_product_link_attribute'),
['id' => 'product_link_attribute_id']
Expand Down Expand Up @@ -1374,6 +1375,7 @@ protected function _saveLinks()
}
return $this;
}
// phpcs:enable

/**
* Save product attributes.
Expand Down Expand Up @@ -1608,6 +1610,7 @@ public function getImagesFromRow(array $rowData)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
* @throws LocalizedException
* phpcs:disable Generic.Metrics.NestingLevel
*/
protected function _saveProducts()
{
Expand Down Expand Up @@ -1798,7 +1801,13 @@ protected function _saveProducts()
$uploadedImages[$columnImage] = $uploadedFile;
} else {
unset($rowData[$column]);
$this->skipRow($rowNum, ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE);
$this->addRowError(
ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE,
$rowNum,
null,
null,
ProcessingError::ERROR_LEVEL_NOT_CRITICAL
);
}
} else {
$uploadedFile = $uploadedImages[$columnImage];
Expand Down Expand Up @@ -1974,6 +1983,7 @@ protected function _saveProducts()

return $this;
}
// phpcs:enable

/**
* Prepare array with image states (visible or hidden from product page)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Downloadable\Observer;

use Magento\Framework\Event\ObserverInterface;

/**
* Assign Downloadable links to customer created after issuing guest order.
*/
class UpdateLinkPurchasedObserver implements ObserverInterface
{
/**
* Core store config
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
private $scopeConfig;

/**
* @var \Magento\Downloadable\Model\ResourceModel\Link\Purchased\CollectionFactory
*/
private $purchasedFactory;

/**
* @var \Magento\Framework\DataObject\Copy
*/
private $objectCopyService;

/**
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Downloadable\Model\ResourceModel\Link\Purchased\CollectionFactory $purchasedFactory
* @param \Magento\Framework\DataObject\Copy $objectCopyService
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Downloadable\Model\ResourceModel\Link\Purchased\CollectionFactory $purchasedFactory,
\Magento\Framework\DataObject\Copy $objectCopyService
) {
$this->scopeConfig = $scopeConfig;
$this->purchasedFactory = $purchasedFactory;
$this->objectCopyService = $objectCopyService;
}

/**
* Re-save order data after order update.
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$order = $observer->getEvent()->getOrder();

if (!$order->getId()) {
//order not saved in the database
return $this;
}

$purchasedLinks = $this->purchasedFactory->create()->addFieldToFilter(
'order_id',
['eq' => $order->getId()]
);

foreach ($purchasedLinks as $linkPurchased) {
$this->objectCopyService->copyFieldsetToTarget(
\downloadable_sales_copy_order::class,
'to_downloadable',
$order,
$linkPurchased
);
$linkPurchased->save();
}

return $this;
}
}
1 change: 1 addition & 0 deletions app/code/Magento/Downloadable/etc/events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</event>
<event name="sales_order_save_after">
<observer name="downloadable_observer" instance="Magento\Downloadable\Observer\SetLinkStatusObserver" />
<observer name="downloadable_observer_assign_customer" instance="Magento\Downloadable\Observer\UpdateLinkPurchasedObserver" />
</event>
<event name="sales_model_service_quote_submit_success">
<observer name="checkout_type_onepage_save_order_after" instance="Magento\Downloadable\Observer\SetHasDownloadableProductsObserver" />
Expand Down
34 changes: 12 additions & 22 deletions app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/**
* Entity/Attribute/Model - collection abstract
*
* phpcs:disable Magento2.Classes.AbstractApi
* @api
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
Expand Down Expand Up @@ -188,6 +189,7 @@ public function __construct(
* Initialize collection
*
* @return void
* phpcs:disable Magento2.CodeAnalysis.EmptyBlock
*/
protected function _construct()
{
Expand Down Expand Up @@ -298,7 +300,7 @@ public function getResource()
/**
* Set template object for the collection
*
* @param \Magento\Framework\DataObject $object
* @param \Magento\Framework\DataObject $object
* @return $this
*/
public function setObject($object = null)
Expand Down Expand Up @@ -395,7 +397,7 @@ public function addAttributeToFilter($attribute, $condition = null, $joinType =

if (!empty($conditionSql)) {
$this->getSelect()->where($conditionSql, null, \Magento\Framework\DB\Select::TYPE_CONDITION);
$this->invalidateSize();
$this->_totalRecords = null;
} else {
throw new \Magento\Framework\Exception\LocalizedException(
__('Invalid attribute identifier for filter (%1)', get_class($attribute))
Expand Down Expand Up @@ -1371,8 +1373,8 @@ protected function _getAttributeFieldName($attributeCode)
/**
* Add attribute value table to the join if it wasn't added previously
*
* @param string $attributeCode
* @param string $joinType inner|left
* @param string $attributeCode
* @param string $joinType inner|left
* @return $this
* @throws LocalizedException
* @SuppressWarnings(PHPMD.NPathComplexity)
Expand Down Expand Up @@ -1466,12 +1468,12 @@ protected function getEntityPkName(\Magento\Eav\Model\Entity\AbstractEntity $ent
/**
* Adding join statement to collection select instance
*
* @param string $method
* @param object $attribute
* @param string $tableAlias
* @param array $condition
* @param string $fieldCode
* @param string $fieldAlias
* @param string $method
* @param object $attribute
* @param string $tableAlias
* @param array $condition
* @param string $fieldCode
* @param string $fieldAlias
* @return $this
*/
protected function _joinAttributeToSelect($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias)
Expand Down Expand Up @@ -1719,16 +1721,4 @@ public function removeAllFieldsFromSelect()
{
return $this->removeAttributeToSelect();
}

/**
* Invalidates "Total Records Count".
* Invalidates saved "Total Records Count" attribute with last counting,
* so a next calling of method getSize() will query new total records count.
*
* @return void
*/
private function invalidateSize(): void
{
$this->_totalRecords = null;
}
}
3 changes: 2 additions & 1 deletion app/code/Magento/Sales/Model/Service/InvoiceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public function setVoid($id)
*/
public function prepareInvoice(Order $order, array $qtys = [])
{
$isQtysEmpty = empty($qtys);
$invoice = $this->orderConverter->toInvoice($order);
$totalQty = 0;
$qtys = $this->prepareItemsQty($order, $qtys);
Expand All @@ -161,7 +162,7 @@ public function prepareInvoice(Order $order, array $qtys = [])
$qty = (double) $qtys[$orderItem->getId()];
} elseif ($orderItem->isDummy()) {
$qty = $orderItem->getQtyOrdered() ? $orderItem->getQtyOrdered() : 1;
} elseif (empty($qtys)) {
} elseif ($isQtysEmpty) {
$qty = $orderItem->getQtyToInvoice();
} else {
$qty = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ $taxAmount = $block->getTotal()->getValue();
<?php $percent = $info['percent']; ?>
<?php $amount = $info['amount']; ?>
<?php $rates = $info['rates']; ?>
<?php $isFirst = 1; ?>

<?php foreach ($rates as $rate): ?>
<tr class="summary-details-<?= /* @escapeNotVerified */ $taxIter ?> summary-details<?php if ($isTop): echo ' summary-details-first'; endif; ?>" style="display:none;">
Expand All @@ -44,13 +43,10 @@ $taxAmount = $block->getTotal()->getValue();
<?php endif; ?>
<br />
</td>
<?php if ($isFirst): ?>
<td style="<?= /* @escapeNotVerified */ $block->getTotal()->getStyle() ?>" class="admin__total-amount" rowspan="<?= count($rates) ?>">
<?= /* @escapeNotVerified */ $block->formatPrice($amount) ?>
</td>
<?php endif; ?>
<td style="<?= /* @escapeNotVerified */ $block->getTotal()->getStyle() ?>" class="admin__total-amount">
<?= /* @escapeNotVerified */ $block->formatPrice(($amount*(float)$rate['percent'])/$percent) ?>
</td>
</tr>
<?php $isFirst = 0; ?>
<?php $isTop = 0; ?>
<?php endforeach; ?>
<?php endforeach; ?>
Expand Down
Loading

0 comments on commit 45a6365

Please sign in to comment.