diff --git a/.ddev/commands/web/openmage-install b/.ddev/commands/web/openmage-install new file mode 100755 index 00000000000..d4b86fb0e92 --- /dev/null +++ b/.ddev/commands/web/openmage-install @@ -0,0 +1,154 @@ +#!/bin/bash + +## ProjectTypes: magento +## Description: Install OpenMage +## Usage: openmage-install [-d|--default] [-s|--sampledata] [-k|--keep] [-q|--quiet] +## Example: ddev openmage-install -d -s -k +## Flags: [{"Name":"default","Shorthand":"d","Usage":"use default values"},{"Name":"sampledata","Shorthand":"s","Usage":"install sample data"},{"Name":"keep","Shorthand":"k","Usage":"keep sample data package"},{"Name":"quiet","Shorthand":"q","Usage":"silent install with sample data"}] + +ROOT="${PWD}" + +QUIET_INSTALL_FLAG='' +SAMPLE_DATA_FLAG='' +SAMPLE_DATA_KEEP_FLAG='' +USE_DEFAULT_FLAG='' + +while :; do + case ${1:-} in + -d|--default) + USE_DEFAULT_FLAG='true' ;; + -s|--sampledata) + SAMPLE_DATA_FLAG='true' ;; + -k|--keep) + SAMPLE_DATA_KEEP_FLAG='true' ;; + -q|--quiet) + QUIET_INSTALL_FLAG='true' + USE_DEFAULT_FLAG='true' + SAMPLE_DATA_FLAG='true' + ;; + --) # End of all options. + shift + break + ;; + -?*) + printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2 + ;; + *) # Default case: No more options, so break out of the loop. + break + esac + + shift + done + +LOCALXML="${ROOT}/app/etc/local.xml" +if [ -f "${LOCALXML}" ]; then + if [[ "${QUIET_INSTALL_FLAG}" ]]; then + DELETE='y' + else + read -r -p "OpenMage is already installed. Delete local.xml and drop the database? [y/N] " DELETE + DELETE=${DELETE,,} # to lower + fi + + if [[ "${DELETE}" =~ ^(yes|y) ]]; then + mysql -u db -h db -e "DROP SCHEMA IF EXISTS db; CREATE SCHEMA db;"; + rm "${LOCALXML}" + else + exit 1 + fi +fi + +# install sample data +if [[ "${SAMPLE_DATA_FLAG}" ]]; then + INSTALL_SAMPLE_DATA='y' +else + read -r -p "Install Sample Data? [y/N] " INSTALL_SAMPLE_DATA + INSTALL_SAMPLE_DATA=${INSTALL_SAMPLE_DATA,,} # to lower +fi + +if [[ $INSTALL_SAMPLE_DATA =~ ^(yes|y) ]]; then + SAMPLE_DATA_URL=https://github.com/Vinai/compressed-magento-sample-data/raw/master/compressed-magento-sample-data-1.9.2.4.tgz + SAMPLE_DATA_DIRECTORY="${ROOT}/.sampleData" + SAMPLE_DATA_FILE=sample_data.tgz + + if [[ ! -d "${SAMPLE_DATA_DIRECTORY}" ]]; then + echo "Creating Sample Data directory..." + mkdir -p "${SAMPLE_DATA_DIRECTORY}" + fi + + cd "${SAMPLE_DATA_DIRECTORY}" || exit + if [[ ! -f "${SAMPLE_DATA_DIRECTORY}/${SAMPLE_DATA_FILE}" ]]; then + echo "Downloading Sample Data..." + wget "${SAMPLE_DATA_URL}" -O "${SAMPLE_DATA_FILE}" + fi + + echo "Uncompressing Sample Data..." + tar xf "${SAMPLE_DATA_FILE}" + + echo "Copying Sample Data into the OpenMage directory..." + cp -r magento-sample-data-1.9.2.4/* "${ROOT}/" + + echo "Importing Sample Data into the database..." + mysql -u db -h db db < "${SAMPLE_DATA_DIRECTORY}/magento-sample-data-1.9.2.4/magento_sample_data_for_1.9.2.4.sql" + + # remove sample data + if [[ "${SAMPLE_DATA_KEEP_FLAG}" ]]; then + rm -rf $( + find . -maxdepth 1 -type f -name "*" ! -name "${SAMPLE_DATA_FILE}") + else + cd "${ROOT}" || exit + rm -rf "${SAMPLE_DATA_DIRECTORY}" + fi +fi + +cd "${ROOT}" || exit + +if [[ "${USE_DEFAULT_FLAG}" ]]; then + ADMIN_USER='admin' + ADMIN_FIRSTNAME='OpenMage' + ADMIN_LASTNAME='Administrator' + ADMIN_EMAIL='admin@example.com' + ADMIN_PASSWORD='veryl0ngpassw0rd' + TABLE_PREFIX='om_' +else + read -r -p "Admin User [admin]: " ADMIN_USER + ADMIN_USER=${ADMIN_USER:-admin} + read -r -p "Admin Firstname [OpenMage]: " ADMIN_FIRSTNAME + ADMIN_FIRSTNAME=${ADMIN_FIRSTNAME:-OpenMage} + read -r -p "Admin Lastname [Administrator]: " ADMIN_LASTNAME + ADMIN_LASTNAME=${ADMIN_LASTNAME:-Administrator} + read -r -p "Admin Email [admin@example.com]: " ADMIN_EMAIL + ADMIN_EMAIL=${ADMIN_EMAIL:-admin@example.com} + read -r -p "Admin Password [veryl0ngpassw0rd]: " ADMIN_PASSWORD + ADMIN_PASSWORD=${ADMIN_PASSWORD:-veryl0ngpassw0rd} + if [[ $INSTALL_SAMPLE_DATA =~ ^(yes|y) ]]; then + TABLE_PREFIX='' + else + read -r -e -i 'om_' -p "Table Prefix [om_]: " TABLE_PREFIX + fi +fi + +php -f install.php -- \ + --license_agreement_accepted 'yes' \ + --locale 'en_US' \ + --timezone 'America/New_York' \ + --db_host 'db' \ + --db_name 'db' \ + --db_user 'db' \ + --db_pass 'db' \ + --db_prefix "${TABLE_PREFIX}" \ + --url "${DDEV_PRIMARY_URL}" \ + --use_rewrites 'yes' \ + --use_secure 'yes' \ + --secure_base_url "${DDEV_PRIMARY_URL}" \ + --use_secure_admin 'yes' \ + --admin_username "${ADMIN_USER}" \ + --admin_lastname "${ADMIN_LASTNAME}" \ + --admin_firstname "${ADMIN_FIRSTNAME}" \ + --admin_email "${ADMIN_EMAIL}" \ + --admin_password "${ADMIN_PASSWORD}" \ + --session_save 'files' \ + --admin_frontname 'admin' \ + --backend_frontname 'admin' \ + --default_currency 'USD' \ + --enable_charts 'yes' \ + --skip_url_validation 'yes' diff --git a/app/code/core/Mage/GoogleAnalytics/Block/Ga.php b/app/code/core/Mage/GoogleAnalytics/Block/Ga.php index e589dd44dee..7a70924599f 100644 --- a/app/code/core/Mage/GoogleAnalytics/Block/Ga.php +++ b/app/code/core/Mage/GoogleAnalytics/Block/Ga.php @@ -21,6 +21,9 @@ */ class Mage_GoogleAnalytics_Block_Ga extends Mage_Core_Block_Template { + protected const CHECKOUT_MODULE_NAME = "checkout"; + protected const CHECKOUT_CONTROLLER_NAME = "onepage"; + /** * Render regular page tracking javascript code * The custom "page name" may be set from layout or somewhere else. It must start from slash. @@ -304,7 +307,7 @@ protected function _getEnhancedEcommerceDataForAnalytics4() * * @link https://developers.google.com/tag-platform/gtagjs/reference/events#begin_checkout */ - elseif ($moduleName == 'checkout' && $controllerName == 'onepage') { + elseif ($moduleName == static::CHECKOUT_MODULE_NAME && $controllerName == static::CHECKOUT_CONTROLLER_NAME) { $productCollection = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems(); if ($productCollection) { $eventData = []; @@ -342,7 +345,7 @@ protected function _getEnhancedEcommerceDataForAnalytics4() $orderIds = $this->getOrderIds(); if (!empty($orderIds) && is_array($orderIds)) { $collection = Mage::getResourceModel('sales/order_collection') - ->addFieldToFilter('entity_id', ['in' => $orderIds]); + ->addFieldToFilter('entity_id', ['in' => $orderIds]); /** @var Mage_Sales_Model_Order $order */ foreach ($collection as $order) { $orderData = [ diff --git a/app/code/core/Mage/Paypal/Model/Ipn.php b/app/code/core/Mage/Paypal/Model/Ipn.php index 2e5a1ea2550..aaddaa7ce89 100644 --- a/app/code/core/Mage/Paypal/Model/Ipn.php +++ b/app/code/core/Mage/Paypal/Model/Ipn.php @@ -559,7 +559,7 @@ protected function _registerPaymentRefund() ->setTransactionId($this->getRequestData('txn_id')) ->setParentTransactionId($this->getRequestData('parent_txn_id')) ->setIsTransactionClosed($isRefundFinal) - ->registerRefundNotification(-1 * $this->getRequestData('mc_gross')); + ->registerRefundNotification(-1 * (float)$this->getRequestData('mc_gross')); $this->_order->addStatusHistoryComment($comment, false); $this->_order->save(); diff --git a/app/code/core/Mage/Rule/Model/Abstract.php b/app/code/core/Mage/Rule/Model/Abstract.php index 220ec819388..d3919683542 100644 --- a/app/code/core/Mage/Rule/Model/Abstract.php +++ b/app/code/core/Mage/Rule/Model/Abstract.php @@ -319,10 +319,7 @@ protected function _convertFlatToRecursive(array $data) $path = explode('--', $id); $node =& $arr; for ($i = 0, $l = count($path); $i < $l; $i++) { - if (!isset($node[$key][$path[$i]])) { - $node[$key][$path[$i]] = []; - } - $node =& $node[$key][$path[$i]]; + $node =& $node[$key][$path[$i]] ?? []; } foreach ($data as $k => $v) { $node[$k] = $v; diff --git a/composer.lock b/composer.lock index 2589be8f993..6d1c9c62064 100644 --- a/composer.lock +++ b/composer.lock @@ -3372,16 +3372,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.21", + "version": "1.10.22", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5" + "reference": "97d694dfd4ceb57bcce4e3b38548f13ea62e4287" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5", - "reference": "b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/97d694dfd4ceb57bcce4e3b38548f13ea62e4287", + "reference": "97d694dfd4ceb57bcce4e3b38548f13ea62e4287", "shasum": "" }, "require": { @@ -3430,7 +3430,7 @@ "type": "tidelift" } ], - "time": "2023-06-21T20:07:58+00:00" + "time": "2023-06-30T20:04:11+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon index a0328f8888d..9d9ec9e001b 100644 --- a/phpstan.dist.baseline.neon +++ b/phpstan.dist.baseline.neon @@ -3670,11 +3670,6 @@ parameters: count: 1 path: app/code/core/Mage/Rss/Helper/Data.php - - - message: "#^Offset 'actions'\\|'conditions' on array\\{\\} in isset\\(\\) does not exist\\.$#" - count: 1 - path: app/code/core/Mage/Rule/Model/Abstract.php - - message: "#^Property Mage_Rule_Model_Abstract\\:\\:\\$_conditions \\(Mage_Rule_Model_Condition_Combine\\) in empty\\(\\) is not falsy\\.$#" count: 1