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

This is an archived bug report. If you are experiencing a similar issue, upgrade to the latest release and if that does not solve the problem, submit a new bug report

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.

  • 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'
    )));
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases