From 8bd97852b5c2299f882858b0d57880b94d8de12a Mon Sep 17 00:00:00 2001 From: luigifab <31816829+luigifab@users.noreply.github.com> Date: Tue, 18 Apr 2023 10:51:38 +0200 Subject: [PATCH 1/9] Set sort order and disable click-to-top for coupons grid (#3189) * Set sort order and disable click-to-top for coupons grid * Update phpdoc Co-authored-by: Ng Kiat Siong --------- Co-authored-by: Ng Kiat Siong --- .../Block/Promo/Quote/Edit/Tab/Coupons/Grid.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php index 433bedc562f..752bc22c199 100644 --- a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php @@ -27,6 +27,7 @@ public function __construct() { parent::__construct(); $this->setId('couponCodesGrid'); + $this->setDefaultSort('created_at'); $this->setUseAjax(true); } @@ -128,4 +129,12 @@ public function getGridUrl() { return $this->getUrl('*/*/couponsGrid', ['_current' => true]); } + + /** + * @inheritdoc + */ + public function getRowUrl($row) + { + return ''; + } } From 177461b101177af67c3e7d8f63c872e5b5d38619 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Tue, 18 Apr 2023 12:29:02 +0100 Subject: [PATCH 2/9] [PHP 8.2] Fixed deprecation error for creation of dynamic property (#3177) Co-authored-by: Mohamed ELIDRISSI <67818913+elidrissidev@users.noreply.github.com> --- app/code/core/Mage/Paypal/Model/Config.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/code/core/Mage/Paypal/Model/Config.php b/app/code/core/Mage/Paypal/Model/Config.php index 233aa4bf933..b08d9f941c8 100644 --- a/app/code/core/Mage/Paypal/Model/Config.php +++ b/app/code/core/Mage/Paypal/Model/Config.php @@ -621,6 +621,11 @@ class Mage_Paypal_Model_Config 'zh_XC', ]; + /** + * @var array + */ + protected $_config = []; + /** * Set method and store id, if specified * @@ -775,11 +780,19 @@ public function isMethodAvailable($methodCode = null) */ public function __get($key) { + if (array_key_exists($key, $this->_config)) { + return $this->_config[$key]; + } + $underscored = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $key)); + if (array_key_exists($underscored, $this->_config)) { + return $this->_config[$underscored]; + } + $value = Mage::getStoreConfig($this->_getSpecificConfigPath($underscored), $this->_storeId); $value = $this->_prepareValue($underscored, $value); - $this->$key = $value; - $this->$underscored = $value; + $this->_config[$key] = $value; + $this->_config[$underscored] = $value; return $value; } From 25ea459f9e2a6166bc5d6395fc245f77fb062578 Mon Sep 17 00:00:00 2001 From: luigifab <31816829+luigifab@users.noreply.github.com> Date: Tue, 18 Apr 2023 16:42:07 +0200 Subject: [PATCH 3/9] Update review_entity_summary when unapprove the latest comment (#2686) --- .../Mage/Rating/Model/Resource/Rating.php | 20 ++++++++++++++----- .../Mage/Review/Model/Resource/Review.php | 7 ++++--- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating.php b/app/code/core/Mage/Rating/Model/Resource/Rating.php index 6051c86aaf1..f90e5554d9a 100644 --- a/app/code/core/Mage/Rating/Model/Resource/Rating.php +++ b/app/code/core/Mage/Rating/Model/Resource/Rating.php @@ -277,6 +277,16 @@ public function getEntitySummary($object, $onlyForCurrentStore = true) } } + if (empty($result[0])) { + // when you unapprove the latest comment and save + // store_id = 0 is missing and not updated in review_entity_summary + $clone = clone $object; + $clone->setCount(0); + $clone->setSum(0); + $clone->setStoreId(0); + $result[0] = $clone; + } + return array_values($result); } @@ -288,10 +298,9 @@ public function getEntitySummary($object, $onlyForCurrentStore = true) */ protected function _getEntitySummaryData($object) { - $adapter = $this->_getReadAdapter(); - - $sumColumn = new Zend_Db_Expr("SUM(rating_vote.{$adapter->quoteIdentifier('percent')})"); - $countColumn = new Zend_Db_Expr("COUNT(*)"); + $adapter = $this->_getReadAdapter(); + $sumColumn = new Zend_Db_Expr("SUM(rating_vote.{$adapter->quoteIdentifier('percent')})"); + $countColumn = new Zend_Db_Expr("COUNT(*)"); $select = $adapter->select() ->from( @@ -299,7 +308,8 @@ protected function _getEntitySummaryData($object) [ 'entity_pk_value' => 'rating_vote.entity_pk_value', 'sum' => $sumColumn, - 'count' => $countColumn] + 'count' => $countColumn + ] ) ->join( ['review' => $this->getTable('review/review')], diff --git a/app/code/core/Mage/Review/Model/Resource/Review.php b/app/code/core/Mage/Review/Model/Resource/Review.php index 38d44910d1a..936f7dfe14f 100644 --- a/app/code/core/Mage/Review/Model/Resource/Review.php +++ b/app/code/core/Mage/Review/Model/Resource/Review.php @@ -307,13 +307,14 @@ public function getTotalReviews($entityPkValue, $approvedOnly = false, $storeId */ public function aggregate($object) { - $readAdapter = $this->_getReadAdapter(); - $writeAdapter = $this->_getWriteAdapter(); + $readAdapter = $this->_getReadAdapter(); + $writeAdapter = $this->_getWriteAdapter(); + $ratingModel = Mage::getModel('rating/rating'); + if (!$object->getEntityPkValue() && $object->getId()) { $object->load($object->getReviewId()); } - $ratingModel = Mage::getModel('rating/rating'); $ratingSummaries = $ratingModel->getEntitySummary($object->getEntityPkValue(), false); foreach ($ratingSummaries as $ratingSummaryObject) { From 08e11aa974ce8e1bacb1c8d6bc7c42a4376ef6d0 Mon Sep 17 00:00:00 2001 From: luigifab <31816829+luigifab@users.noreply.github.com> Date: Tue, 18 Apr 2023 17:51:15 +0200 Subject: [PATCH 4/9] Reduced number of getId() calls in Mage_Eav_Model_Entity_Type (#3194) --- app/code/core/Mage/Eav/Model/Entity/Type.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/core/Mage/Eav/Model/Entity/Type.php b/app/code/core/Mage/Eav/Model/Entity/Type.php index ebaf08eabc1..300abd1a156 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Type.php +++ b/app/code/core/Mage/Eav/Model/Entity/Type.php @@ -186,12 +186,13 @@ public function fetchNewIncrementId($storeId = null) $this->_getResource()->beginTransaction(); try { + $id = $this->getId(); $entityStoreConfig = Mage::getModel('eav/entity_store') - ->loadByEntityStore($this->getId(), $storeId); + ->loadByEntityStore($id, $storeId); if (!$entityStoreConfig->getId()) { $entityStoreConfig - ->setEntityTypeId($this->getId()) + ->setEntityTypeId($id) ->setStoreId($storeId) ->setIncrementPrefix($storeId) ->save(); From 1342703287ce96400ec654567b747b227de6e43b Mon Sep 17 00:00:00 2001 From: Scott Moore Date: Wed, 19 Apr 2023 03:41:57 -0400 Subject: [PATCH 5/9] Fix for export failing when product_id missing from cataloginventory_stock_item (#3165) --------- Co-authored-by: Ng Kiat Siong Co-authored-by: Fabrizio Balliano --- .../core/Mage/ImportExport/Model/Export/Entity/Product.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php b/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php index 12fdc5fdc3d..0fa377193c3 100644 --- a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php +++ b/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php @@ -925,7 +925,9 @@ protected function _prepareExport() $dataRow[self::COL_TYPE] = null; } else { $dataRow[self::COL_STORE] = null; - $dataRow += $stockItemRows[$productId]; + if (!empty($stockItemRows[$productId]) && is_array($stockItemRows[$productId])) { + $dataRow += $stockItemRows[$productId]; + } } $this->_updateDataWithCategoryColumns($dataRow, $rowCategories, $productId); From a9da171450049d4432af521b14d8df42ebf443fd Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Fri, 21 Apr 2023 22:13:05 +0100 Subject: [PATCH 6/9] Replaced Mage_Exception usages with Mage_Core_Exception (#3206) --- .../controllers/System/Config/System/StorageController.php | 2 +- .../Mage/Adminhtml/controllers/System/DesignController.php | 2 +- app/code/core/Mage/Checkout/controllers/CartController.php | 6 +++--- app/code/core/Mage/Weee/Helper/Data.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Config/System/StorageController.php b/app/code/core/Mage/Adminhtml/controllers/System/Config/System/StorageController.php index 09f5aa28806..32e931463e6 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/Config/System/StorageController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/Config/System/StorageController.php @@ -126,7 +126,7 @@ public function statusAction() if (is_array($flagData) && !(isset($flagData['timeout_reached']) && $flagData['timeout_reached']) ) { - Mage::logException(new Mage_Exception( + Mage::logException(new Mage_Core_Exception( Mage::helper('adminhtml')->__('Timeout limit for response from synchronize process was reached.') )); diff --git a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php index 0f52e1cb7dc..4e9d42d9632 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php @@ -125,7 +125,7 @@ public function deleteAction() Mage::getSingleton('adminhtml/session') ->addSuccess($this->__('The design change has been deleted.')); - } catch (Mage_Exception $e) { + } catch (Mage_Core_Exception $e) { Mage::getSingleton('adminhtml/session') ->addError($e->getMessage()); } catch (Exception $e) { diff --git a/app/code/core/Mage/Checkout/controllers/CartController.php b/app/code/core/Mage/Checkout/controllers/CartController.php index 23d4bd62a62..c82e4b05308 100644 --- a/app/code/core/Mage/Checkout/controllers/CartController.php +++ b/app/code/core/Mage/Checkout/controllers/CartController.php @@ -62,14 +62,14 @@ protected function _getQuote() * Set back redirect url to response * * @return $this - * @throws Mage_Exception + * @throws Mage_Core_Exception */ protected function _goBack() { $returnUrl = $this->getRequest()->getParam('return_url'); if ($returnUrl) { if (!$this->_isUrlInternal($returnUrl)) { - throw new Mage_Exception('External urls redirect to "' . $returnUrl . '" denied!'); + throw new Mage_Core_Exception('External urls redirect to "' . $returnUrl . '" denied!'); } $this->_getSession()->getMessages(true); @@ -192,7 +192,7 @@ public function indexAction() /** * Add product to shopping cart action * - * @throws Mage_Exception + * @throws Mage_Core_Exception */ public function addAction() { diff --git a/app/code/core/Mage/Weee/Helper/Data.php b/app/code/core/Mage/Weee/Helper/Data.php index 112f62ada59..a5d5494ed46 100644 --- a/app/code/core/Mage/Weee/Helper/Data.php +++ b/app/code/core/Mage/Weee/Helper/Data.php @@ -443,7 +443,7 @@ public function setStore($store) /** * Returns all summed weee taxes with all local taxes applied * - * @throws Mage_Exception + * @throws Mage_Core_Exception * @param array $attributes Array of Varien_Object, result from getProductWeeeAttributes() * @return float */ @@ -456,7 +456,7 @@ public function getAmountInclTaxes($attributes) $amount += $attribute->getAmount() + $attribute->getTaxAmount(); } } else { - throw new Mage_Exception('$attributes must be an array'); + throw new Mage_Core_Exception('$attributes must be an array'); } return (float)$amount; From 0bf974c4ca10e1029ec6f78f5c6592e3e3a2a378 Mon Sep 17 00:00:00 2001 From: Colin Mollenhour Date: Fri, 21 Apr 2023 21:45:38 -0400 Subject: [PATCH 7/9] Update dev/openmage to use the updated container images for PHP 8.2 --- dev/openmage/README.md | 24 ++++++------------------ dev/openmage/docker-compose.yml | 12 ++++++------ dev/openmage/install.sh | 4 ++-- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/dev/openmage/README.md b/dev/openmage/README.md index f94af9106e4..287e4019f5c 100644 --- a/dev/openmage/README.md +++ b/dev/openmage/README.md @@ -22,12 +22,12 @@ Visit [http://openmage-7f000001.nip.io/](http://openmage-7f000001.nip.io/) and s Tips === -See [meanbee/docker-magento](https://github.com/meanbee/docker-magento) for more information on the containers -used in this setup, but here are some quick tips: +See [colinmollenhour/docker-openmage-dev](https://github.com/colinmollenhour/docker-openmage-dev) for more information +on the containers used in this setup, but here are some quick tips: - You can start the cron task using `docker-compose up -d cron`. - The `cli` service contains many useful tools like `composer`, `magerun`, `modman`, `mageconfigsync` and more. -- XDebug is enabled using `remote_connect_back=1` with `idekey=phpstorm`. Customize this in `docker-compose.yml` if needed. +- XDebug is enabled using `remote_connect_back=1` with `idekey=phpstorm`. Customize this in `.env` if needed as described below. Here are some common commands you may wish to try: @@ -41,8 +41,10 @@ $ docker-compose exec mysql mysql Environment Variables --- -You can override some defaults using environment variables defined in a file that you must create at `dev/openmage/.env`. +You can override some defaults using environment variables defined in a file (that you must create) at `dev/openmage/.env`. +- `ENABLE_SENDMAIL=false` - Disable the sendmail MTA +- `XDEBUG_CONFIG=...` - Override the default XDebug config - `HOST_NAME=your-preferred-hostname` - `openmage-7f000001.nip.io` is used by default to resolve to `127.0.0.1`. See [nip.io](https://nip.io) for more info. - `HOST_PORT=8888` @@ -61,17 +63,3 @@ If you want to start fresh, wipe out your installation with the following comman ``` $ docker-compose down --volumes && rm -f ../../app/etc/local.xml ``` - -Building -=== - -The Docker images are built using the [meanbee/docker-magento](https://github.com/meanbee/docker-magento) source files so to build new images first -clone the source files into this directory and then run `docker-compose build`. - -``` -$ git clone https://github.com/meanbee/docker-magento.git -$ docker build -t openmage/php-dev:7.3-cli docker-magento/7.3/cli -$ docker push openmage/php-dev:7.3-cli -$ docker build -t openmage/php-dev:7.3-apache docker-magento/7.3/apache -$ docker push openmage/php-dev:7.3-apache -``` diff --git a/dev/openmage/docker-compose.yml b/dev/openmage/docker-compose.yml index ae61077a864..9839e1b5da6 100644 --- a/dev/openmage/docker-compose.yml +++ b/dev/openmage/docker-compose.yml @@ -2,21 +2,21 @@ version: "3.7" services: apache: - image: openmage/php-dev:7.3-apache + image: ghcr.io/colinmollenhour/docker-openmage-dev:8.2-apache hostname: ${HOST_NAME:-openmage-7f000001.nip.io} ports: - "${HOST_PORT:-80}:80" volumes: - ../..:/var/www/html environment: - - ENABLE_SENDMAIL=true - - XDEBUG_CONFIG=remote_connect_back=1 remote_enable=1 idekey=phpstorm - - MAGE_IS_DEVELOPER_MODE=1 + - ENABLE_SENDMAIL=${ENABLE_SENDMAIL:-true} + - XDEBUG_CONFIG=${XDEBUG_CONFIG:-remote_connect_back=1 remote_enable=1 idekey=phpstorm} + - MAGE_IS_DEVELOPER_MODE=${MAGE_IS_DEVELOPER_MODE:-1} links: - mysql cron: - image: openmage/php-dev:7.3-cli + image: ghcr.io/colinmollenhour/docker-openmage-dev:8.2-cli working_dir: /var/www/html command: /run-cron.sh volumes: @@ -27,7 +27,7 @@ services: - mysql cli: - image: openmage/php-dev:7.3-cli + image: ghcr.io/colinmollenhour/docker-openmage-dev:8.2-cli working_dir: /var/www/html command: /bin/true user: www-data diff --git a/dev/openmage/install.sh b/dev/openmage/install.sh index 6d246eb0d69..0adc45ed87a 100755 --- a/dev/openmage/install.sh +++ b/dev/openmage/install.sh @@ -35,8 +35,8 @@ if test -f ../../app/etc/local.xml; then fi echo "Preparing filesystem..." -chmod 777 ../../app/etc ../../media ../../var -chmod g+s ../../app/etc ../../media ../../var +chmod 777 ../../app/etc ../../media ../../media/* ../../var +chmod g+s ../../app/etc ../../media ../../media/* ../../var $dc run --rm --no-deps cli mkdir -p var/cache var/log var/locks var/session echo "Starting services..." From 54e9a771f2b79ce7720b2ac0de8cac3687addf5e Mon Sep 17 00:00:00 2001 From: Colin Mollenhour Date: Fri, 21 Apr 2023 22:20:33 -0400 Subject: [PATCH 8/9] Improve use of Composer with dev/openmage environment and filesystem permissions. --- dev/openmage/README.md | 1 + dev/openmage/docker-compose.yml | 8 ++------ dev/openmage/install.sh | 7 ++++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/dev/openmage/README.md b/dev/openmage/README.md index 287e4019f5c..f70db34edcf 100644 --- a/dev/openmage/README.md +++ b/dev/openmage/README.md @@ -32,6 +32,7 @@ on the containers used in this setup, but here are some quick tips: Here are some common commands you may wish to try: ``` +$ docker-compose run --rm -u $(id -u):$(id -g) cli composer require {some-module} $ docker-compose run --rm cli magerun sys:check $ docker-compose run --rm cli magerun cache:clean $ docker-compose run --rm cli magerun db:console diff --git a/dev/openmage/docker-compose.yml b/dev/openmage/docker-compose.yml index 9839e1b5da6..187f6bdfcb5 100644 --- a/dev/openmage/docker-compose.yml +++ b/dev/openmage/docker-compose.yml @@ -33,7 +33,8 @@ services: user: www-data volumes: - ../..:/var/www/html -# environment: + environment: + - COMPOSER_HOME=${COMPOSER_HOME:-/var/www/html/var/.composer} # - AWS_ACCESS_KEY_ID=00000000000000000000 # - AWS_SECRET_ACCESS_KEY=0000000000000000000000000000000000000000 # - AWS_REGION=eu-west-1 @@ -43,11 +44,6 @@ services: - mysql - "apache:${HOST_NAME:-openmage-7f000001.nip.io}" - composer: - image: composer:2.4 - volumes: - - ../..:/app - mysql: image: mysql:5.7 ports: diff --git a/dev/openmage/install.sh b/dev/openmage/install.sh index 0adc45ed87a..41fcda6bcb0 100755 --- a/dev/openmage/install.sh +++ b/dev/openmage/install.sh @@ -35,8 +35,9 @@ if test -f ../../app/etc/local.xml; then fi echo "Preparing filesystem..." -chmod 777 ../../app/etc ../../media ../../media/* ../../var -chmod g+s ../../app/etc ../../media ../../media/* ../../var +mkdir -p ../../vendor +chgrp 33 ../../app/etc ../../media ../../media/* ../../var ../../vendor +chmod g+ws ../../app/etc ../../media ../../media/* ../../var ../../vendor $dc run --rm --no-deps cli mkdir -p var/cache var/log var/locks var/session echo "Starting services..." @@ -48,7 +49,7 @@ for i in $(seq 1 20); do done echo "Installing Composer dependencies..." -$dc run --rm composer composer install --no-progress --ignore-platform-req=ext-* +$dc run --rm -u "$(id -u):$(id -g)" cli composer install --no-progress echo "Installing OpenMage LTS..." $dc run --rm cli php install.php \ From c71585ad51f9d55ffa95f1629b4b70da5600393a Mon Sep 17 00:00:00 2001 From: Colin Mollenhour Date: Fri, 21 Apr 2023 22:30:05 -0400 Subject: [PATCH 9/9] Update dev/openmage/README.md --- dev/openmage/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dev/openmage/README.md b/dev/openmage/README.md index f70db34edcf..2f98ad02c58 100644 --- a/dev/openmage/README.md +++ b/dev/openmage/README.md @@ -29,16 +29,20 @@ on the containers used in this setup, but here are some quick tips: - The `cli` service contains many useful tools like `composer`, `magerun`, `modman`, `mageconfigsync` and more. - XDebug is enabled using `remote_connect_back=1` with `idekey=phpstorm`. Customize this in `.env` if needed as described below. -Here are some common commands you may wish to try: +Here are some common commands you may wish to try (from the `dev/openmage` directory): ``` -$ docker-compose run --rm -u $(id -u):$(id -g) cli composer require {some-module} +$ docker-compose run --rm -u $(id -u):$(id -g) cli composer show +$ docker-compose run --rm -u $(id -u):$(id -g) cli bash $ docker-compose run --rm cli magerun sys:check $ docker-compose run --rm cli magerun cache:clean $ docker-compose run --rm cli magerun db:console $ docker-compose exec mysql mysql ``` +- *The cli container runs as `www-data` by default so use `-u $(id -u):$(id -g)` with composer so that the container will create/modify files with your user permissions to avoid file permission errors in your IDE.* +- *Always use `run --rm` with the cli container to avoid creating lots of orphan containers.* + Environment Variables ---