Skip to content

Scope bug in Catalog URL resource (_getCategories) #38393

Open
@pmzandbergen

Description

@pmzandbergen

Bug
The following condition is obviously invalid:

$isActiveExpr = $connection->getCheckSql('c.value_id > 0', 'c.value', 'c.value');

Explanation
The resulting query is:

SELECT
`main*table\`.`entity*id`,
`main*table\`.`parent*id`,
`main_table\`.`level`,
IF(c.value*id > 0, c.value, c.value) AS `is*active`,
`main_table\`.`path`
FROM
`catalog*category_entity\` AS `main*table`
LEFT JOIN `catalog*category_entity_int\` AS `d` ON d.attribute_id = 46 AND d.store_id = 0 AND d.entity_id = main_table.entity*id
LEFT JOIN `catalog*category_entity_int\` AS `c` ON c.attribute_id = 46 AND c.store_id = 3 AND c.entity_id = main_table.entity*id
WHERE (main*table.entity*id IN(...))

Attribute is_active\ is joined twice on both the store (c\) and default scope (d\). If there is no value available on the store scope (c.value\) the default scope (d.value) should be used instead.

Solution
The condition from line 415:

$isActiveExpr = $connection->getCheckSql('c.value_id > 0', 'c.value', 'c.value');

Should be changed to:

$isActiveExpr = $connection->getCheckSql('c.value_id IS NOT NULL', 'c.value', 'd.value');

 

Note: This bug might not be affecting any Magento code (depends if the is_active flag is actually being used somewhere).

Metadata

Metadata

Assignees

Labels

Area: CatalogComponent: CatalogIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: PR in progressReported on 2.4.xIndicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions