Bug #22873 Bug Fixed

MySQL error when using Grid with 2 content types on the same page and a modifier conditional

Version: 3.4.4 Reporter: Low

Consider this code:

{exp:low_variables:pair var="lv_grid"}
    {lv_grid:col1} : {lv_grid:col2}

{/exp:low_variables:pair}

{exp:channel:entries channel="services" limit="10"}
    {title}
    {if service_grid:total_rows > 0}
        Has rows
    {/if}
{/exp:channel:entries}

This will trigger an error similar to this:

> SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘ee3-4.exp_low_variables_grid_field_40’ doesn’t exist: > SELECT * FROM (exp_low_variables_grid_field_40) WHERE entry_id IN (29598) ORDER BY row_order asc

…where the field_40 is the field ID for the LV grid field and 29598 is the Channel entry for the Services channel. As you can see, the EE parser is getting the two content types mixed up.

Changing the conditional to {if '{service_grid:total_rows}' > 0} solves the issue, but since the other syntax for conditionals is preferred, this should be considered a bug.

  • Thanks, Low. Looks like this should be a fairly simple fix. I’ve put a solution on the Solution tab above if you want to give it a try.

    Kevin Cupp
    11th January, 2017 at 1:56pm
  • Yeah, that fixes it. Thanks!

    Low
    11th January, 2017 at 2:16pm
  • We encountered this issue with the most recent EE 2 build while updating from EE 2.10.

    We had to rewrite some tags to match the solution above.

    Is there an official fix planned and is this issue also present in EE3 ?

    Brad Parscale
    27th March, 2017 at 10:13am
  • Yes this bug was in EE3 but it has since been fixed and released. We didn’t backport the fix to EE2 however, but the code on the Solution tab should apply to EE2 just fine, except the file is located at system/expressionengine/libraries/channel_entries_parser/Parser.php.

    Kevin Cupp
    27th March, 2017 at 10:24am

You must be signed in to comment on a bug report.

  • Open system/ee/legacy/libraries/channel_entries_parser/Parser.php and find this code on line 531:

    ee()->api_channel_fields->apply('_init', array(array(
        'row' => $row,
        'content_id' => $row['entry_id']
    )));

    And REPLACE it with:

    ee()->api_channel_fields->apply('_init', array(array(
        'row' => $row,
        'content_id' => $row['entry_id'],
        'content_type' => 'channel'
    )));

ExpressionEngine News

#eecms, #events, #releases