Skip to content
Open
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
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Model/Product/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Mage_Catalog_Model_Product_Type
public static function factory($product, $singleton = false)
{
$types = self::getTypes();
$typeId = $product->getTypeId();
$typeId = (string) $product->getTypeId();

if (!empty($types[$typeId]['model'])) {
$typeModelName = $types[$typeId]['model'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ public function reindexProductIds($ids)
*/
protected function _getIndexer($productTypeId)
{
if ($productTypeId === null) {
$productTypeId = '';
}
Comment on lines +312 to +314
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not like this?

$productTypeId ??= '';


$types = $this->getTypeIndexers();
if (!isset($types[$productTypeId])) {
Mage::throwException(Mage::helper('catalog')->__('Unsupported product type "%s".', $productTypeId));
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/CatalogInventory/Model/Stock/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function assignProduct(Mage_Catalog_Model_Product $product, $stockId = 1,
if (is_null($stockStatus)) {
$websiteId = $product->getStore()->getWebsiteId();
$status = $this->getProductStatus($product->getId(), $websiteId, $stockId);
$stockStatus = $status[$product->getId()] ?? null;
$stockStatus = $status[(string) $product->getId()] ?? null;
}

$product->setIsSalable($stockStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public function getModuleByName($moduleName, $modules)
*/
public function getFrontNameByRoute($routeName)
{
return $this->_routes[$routeName] ?? false;
return $this->_routes[(string) $routeName] ?? false;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions app/code/core/Mage/Index/Model/Indexer/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public function matchEvent(Mage_Index_Model_Event $event)
*/
public function matchEntityAndType($entity, $type)
{
if ($entity === null) {
$entity = '';
Comment on lines 110 to +114
Copy link

Copilot AI Oct 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting null entity to an empty string could hide incorrect method calls. Consider adding type hints (e.g., ?string $entity) and either returning early with a default value or throwing an exception when null is passed, as null likely indicates invalid usage rather than a valid empty entity name.

Suggested change
*/
public function matchEntityAndType($entity, $type)
{
if ($entity === null) {
$entity = '';
* @throws InvalidArgumentException if $entity is null
*/
public function matchEntityAndType(?string $entity, string $type)
{
if ($entity === null) {
throw new InvalidArgumentException('Entity name must not be null.');

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

if (isset($this->_matchedEntities[$entity])) {
if (in_array($type, $this->_matchedEntities[$entity])) {
return true;
Expand Down
5 changes: 5 additions & 0 deletions lib/Varien/Data/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,11 @@ protected function _toOptionHash($valueField = 'id', $labelField = 'name')
public function getItemById($idValue)
{
$this->load();

if ($idValue === null) {
$idValue = '';
Copy link

Copilot AI Oct 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting null to an empty string could mask logic errors where null IDs are passed unintentionally. Consider adding validation to throw an exception or log a warning when null is passed, or return null immediately instead of treating it as a valid key. This would make debugging easier and prevent unexpected behavior where null and empty string IDs are treated as equivalent.

Suggested change
$idValue = '';
return null;

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

return $this->_items[$idValue] ?? null;
}

Expand Down
1 change: 0 additions & 1 deletion lib/Varien/Http/Adapter/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ public function read()
*/
public function close()
{
curl_close($this->_getResource());
$this->_resource = null;
return $this;
}
Expand Down
Loading