Magento2: Filtering CMS Blocks by ID and Store throws SQL error

Created on 7 Mar 2018  路  5Comments  路  Source: magento/magento2

Preconditions

Magento Community Version 2.1.10

Steps to reproduce

Go to CMS Blocks within the admin panel.
Add a filter by store and block ID

Expected result

Should show result of blocks which match the filter.

Actual result

A pop up shows on saying Attention. Something went wrong.

This results in the spinning loader staying on the screen.
You are also unable to change the filters, resulting in having to go into the Database to remove the filters which are saved.

The ajax request for results shows the following SQL error

Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'block_id' in where clause is ambiguous, query was: SELECT COUNT(DISTINCT main_table.block_id) FROM cms_block AS main_table
INNER JOIN cms_block_store AS store_table ON main_table.block_id = store_table.block_id WHERE (block_id >= '5') AND (block_id <= '5') AND (block_id >= '5') AND (block_id <= '5') AND (block_id >= '5') AND (block_id <= '5') AND (block_id >= '5') AND (block_id <= '5') AND (store_table.store_id IN('4'))
Exception #1 (PDOException): SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'block_id' in where clause is ambiguous

This is because the field block ID exists in both cms_block tbl and cms_block_store.

This does NOT happen on Enterprise version as cms_block_store field is row_id not block_id

Fixed in 2.2.x Fixed in 2.3.x Clear Description Confirmed Format is valid Reproduced on 2.1.x

All 5 comments

@teuma86, thank you for your report.
The issue is already fixed in 2.2.0, 2.3.0

@magento-engcom-team What are the commits for this issue?

Also interested in the commits for a backport. Thanks!

Any fix but upgrading to 2.2? I'm still experiencing this issue

@magento-engcom-team Please reference commits.

Was this page helpful?
0 / 5 - 0 ratings