Skip to content

Chore: Check for DS / PS already set #4484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .phpstan.dist.baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5206,7 +5206,7 @@ parameters:
message: '#^Comparison operation "\!\=" between array\|int and 0 results in an error\.$#'
identifier: notEqual.invalid
count: 1
path: app/code/core/Mage/Reports/Model/Resource/Report/Product/Viewed/Collection.php
path: app/code/core/Mage/Reports/Model/Resource/Report/Collection/Abstract.php

-
message: '#^Parameter \#1 \$select of method Mage_Core_Model_Resource_Helper_Mysql4\:\:getQueryUsingAnalyticFunction\(\) expects Varien_Db_Select, Zend_Db_Select given\.$#'
Expand Down Expand Up @@ -5814,12 +5814,6 @@ parameters:
count: 1
path: app/code/core/Mage/Sales/Model/Resource/Order/Tax/Collection.php

-
message: '#^Comparison operation "\!\=" between array\|int and 0 results in an error\.$#'
identifier: notEqual.invalid
count: 1
path: app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers/Collection.php

-
message: '#^Parameter \#1 \$select of method Mage_Core_Model_Resource_Helper_Mysql4\:\:getQueryUsingAnalyticFunction\(\) expects Varien_Db_Select, Zend_Db_Select given\.$#'
identifier: argument.type
Expand Down
9 changes: 5 additions & 4 deletions app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

define('DS', DIRECTORY_SEPARATOR);
define('PS', PATH_SEPARATOR);
defined('DS') || define('DS', DIRECTORY_SEPARATOR);
defined('PS') || define('PS', PATH_SEPARATOR);

define('BP', dirname(__DIR__));

Mage::register('original_include_path', get_include_path());
Expand Down Expand Up @@ -278,7 +279,7 @@ public static function register($key, $value, $graceful = false)
if ($graceful) {
return;
}
self::throwException('Mage registry key "' . $key . '" already exists');
self::throwException("Mage registry key $key already exists");
}
self::$_registry[$key] = $value;
}
Expand Down Expand Up @@ -331,7 +332,7 @@ public static function setRoot($appRoot = '')
if (is_dir($appRoot) && is_readable($appRoot)) {
self::$_appRoot = $appRoot;
} else {
self::throwException($appRoot . ' is not a directory or not readable by this user');
self::throwException("$appRoot is not a directory or not readable by this user");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,48 @@ public function load($printQuery = false, $logQuery = false)
}
return parent::load($printQuery, $logQuery);
}


/**
* Get SQL for get record count
*
* @return Varien_Db_Select
* @see Mage_Reports_Model_Resource_Report_Product_Viewed_Collection
* @see Mage_Sales_Model_Resource_Report_Bestsellers_Collection
*/
public function getSelectCountSql()
{
$this->_renderFilters();
$select = clone $this->getSelect();
$select->reset(Zend_Db_Select::ORDER);
return $this->getConnection()->select()->from($select, 'COUNT(*)');
}

/**
* Set ids for store restrictions
*
* @param array $storeIds
* @return $this
* @see Mage_Reports_Model_Resource_Report_Product_Viewed_Collection
* @see Mage_Sales_Model_Resource_Report_Bestsellers_Collection
*/
public function addStoreRestrictions($storeIds)
{
if (!is_array($storeIds)) {
$storeIds = [$storeIds];
}
$currentStoreIds = $this->_storesIds;
if (isset($currentStoreIds) && $currentStoreIds != Mage_Core_Model_App::ADMIN_STORE_ID
&& $currentStoreIds != [Mage_Core_Model_App::ADMIN_STORE_ID]
) {
if (!is_array($currentStoreIds)) {
$currentStoreIds = [$currentStoreIds];
}
$this->_storesIds = array_intersect($currentStoreIds, $storeIds);
} else {
$this->_storesIds = $storeIds;
}

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,45 +157,6 @@ protected function _initSelect()
return $this;
}

/**
* Get SQL for get record count
*
* @return Varien_Db_Select
*/
public function getSelectCountSql()
{
$this->_renderFilters();
$select = clone $this->getSelect();
$select->reset(Zend_Db_Select::ORDER);
return $this->getConnection()->select()->from($select, 'COUNT(*)');
}

/**
* Set ids for store restrictions
*
* @param array $storeIds
* @return $this
*/
public function addStoreRestrictions($storeIds)
{
if (!is_array($storeIds)) {
$storeIds = [$storeIds];
}
$currentStoreIds = $this->_storesIds;
if (isset($currentStoreIds) && $currentStoreIds != Mage_Core_Model_App::ADMIN_STORE_ID
&& $currentStoreIds != [Mage_Core_Model_App::ADMIN_STORE_ID]
) {
if (!is_array($currentStoreIds)) {
$currentStoreIds = [$currentStoreIds];
}
$this->_storesIds = array_intersect($currentStoreIds, $storeIds);
} else {
$this->_storesIds = $storeIds;
}

return $this;
}

/**
* Redeclare parent method for applying filters after parent method
* but before adding unions and calculating totals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,45 +158,6 @@ protected function _initSelect()
return $this;
}

/**
* Get SQL for get record count
*
* @return Varien_Db_Select
*/
public function getSelectCountSql()
{
$this->_renderFilters();
$select = clone $this->getSelect();
$select->reset(Zend_Db_Select::ORDER);
return $this->getConnection()->select()->from($select, 'COUNT(*)');
}

/**
* Set ids for store restrictions
*
* @param array $storeIds
* @return $this
*/
public function addStoreRestrictions($storeIds)
{
if (!is_array($storeIds)) {
$storeIds = [$storeIds];
}
$currentStoreIds = $this->_storesIds;
if (isset($currentStoreIds) && $currentStoreIds != Mage_Core_Model_App::ADMIN_STORE_ID
&& $currentStoreIds != [Mage_Core_Model_App::ADMIN_STORE_ID]
) {
if (!is_array($currentStoreIds)) {
$currentStoreIds = [$currentStoreIds];
}
$this->_storesIds = array_intersect($currentStoreIds, $storeIds);
} else {
$this->_storesIds = $storeIds;
}

return $this;
}

/**
* Redeclare parent method for applying filters after parent method
* but before adding unions and calculating totals
Expand Down
Loading