Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano committed Apr 22, 2023
2 parents 62c3715 + c71585a commit 13926d8
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function __construct()
{
parent::__construct();
$this->setId('couponCodesGrid');
$this->setDefaultSort('created_at');
$this->setUseAjax(true);
}

Expand Down Expand Up @@ -128,4 +129,12 @@ public function getGridUrl()
{
return $this->getUrl('*/*/couponsGrid', ['_current' => true]);
}

/**
* @inheritdoc
*/
public function getRowUrl($row)
{
return '';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Checkout/controllers/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -192,7 +192,7 @@ public function indexAction()
/**
* Add product to shopping cart action
*
* @throws Mage_Exception
* @throws Mage_Core_Exception
*/
public function addAction()
{
Expand Down
5 changes: 3 additions & 2 deletions app/code/core/Mage/Eav/Model/Entity/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 15 additions & 2 deletions app/code/core/Mage/Paypal/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,11 @@ class Mage_Paypal_Model_Config
'zh_XC',
];

/**
* @var array
*/
protected $_config = [];

/**
* Set method and store id, if specified
*
Expand Down Expand Up @@ -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;
}
Expand Down
20 changes: 15 additions & 5 deletions app/code/core/Mage/Rating/Model/Resource/Rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -288,18 +298,18 @@ 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(
['rating_vote' => $this->getTable('rating/rating_option_vote')],
[
'entity_pk_value' => 'rating_vote.entity_pk_value',
'sum' => $sumColumn,
'count' => $countColumn]
'count' => $countColumn
]
)
->join(
['review' => $this->getTable('review/review')],
Expand Down
7 changes: 4 additions & 3 deletions app/code/core/Mage/Review/Model/Resource/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Weee/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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;
Expand Down
31 changes: 12 additions & 19 deletions dev/openmage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,34 @@ 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:
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 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
---

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`
Expand All @@ -61,17 +68,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
```
20 changes: 8 additions & 12 deletions dev/openmage/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -27,13 +27,14 @@ 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
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
Expand All @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions dev/openmage/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ 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
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..."
Expand All @@ -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 \
Expand Down

0 comments on commit 13926d8

Please sign in to comment.