backdrop-contrib / backdrop_upgrade_status

Checks to see if the installed modules on a Drupal 7 site are ready for upgrade to Backdrop CMS.
1 stars 5 forks source link

Potential query against non-existant table #34

Closed jimmynash closed 5 months ago

jimmynash commented 1 year ago

In includes/backdrop_upgrade_status.field.inc there is a count of the field data run against the fielddata table for a field.

I ran into a situation where the node_display_fields module was in use. That module doesn't create a fielddata table for it's fields so running the backdrop upgrade overview report throws a fatal error that the table doesn't exist.

We could wrap it in a check for the table maybe like so?

        // Add the item count.
        $table = 'field_data_' . $field_name;
        if (db_table_exists($table)) {
          $count = db_query("SELECT count(entity_id) FROM {$table}")->fetchField();
          $rows[$field_name]['data']['count'] = $count;
          $rows[$field_name]['data']['recommendation'] = '';
          if ($count == 0) {
            $rows[$field_name]['class'] = array('warning');
            $rows[$field_name]['data']['recommendation'] = t('Delete this field?');
          }
        }
jenlampton commented 1 year ago

I love this recommendation, thank you!

jenlampton commented 5 months ago

Committed :)