Notice: Undefined variable: base_tables in entity_views_plugins() (line 324 of /home/pavella/d7/sites/all/modules/entity/views/

This started happening after I created a feature that included some views, now I get this notice on any/all pages that make use of a view. I'm not sure what other information might be relevant. I was working out of a blank site for the sole purpose of creating a new feature.

Thanks for any insights.

#7 undefined-variable-base-table-fix-1630578-7.patch455 bytescpliakas
PASSED: [[SimpleTest]]: [MySQL] 354 pass(es). View


Yanivs’s picture

Had the same error message right after enabling 7.x-1.0-rc3.

Switched to 7.x-1.0-rc2 and the error message is not appearing anymore.



patrickavella’s picture

Thanks Yanivs.

The notice doesn't seem to be breaking anything, hopefully it's there's a fix in the next release.

josefg’s picture

I have the same issue.

It seems to me that the problem lies in the new function entity_views_table_definition(), which replaces the function of EntityDefaultViewsController.views_data() - (as far as I can tell the latter no longer gets called). However, in doing so, entity_views_table_definition() forgets to populate the ['base'] sub-array of its return value. Here is my suggestion for an amendment:


function entity_views_table_definition($type, $exclude = TRUE) {
  // As other modules might want to copy these tables as a base for their own
  // Views integration, we statically cache the tables to save some time.
  $tables = &drupal_static(__FUNCTION__, array());

  if (!isset($tables[$type])) {
    // Work-a-round to fix updating, see
    // Views data might be rebuilt on update.php before the registry is rebuilt,
    // thus the class cannot be auto-loaded.
    if (!class_exists('EntityFieldHandlerHelper')) {
      module_load_include('inc', 'entity', 'views/handlers/entity_views_field_handler_helper');

    $info = entity_get_info($type);
    $tables[$type]['table'] = array(
      'group' => $info['label'],
      'entity type' => $type,
    $tables[$type]['table']['base'] = array(
      'field' => $info['entity keys']['id'],
      'title' => drupal_ucfirst($info['label']),
      // @todo: Support an entity info description key or such?
      'help' => '',
    foreach (entity_get_all_property_info($type) as $key => $property) {
      if (!$exclude || empty($property['entity views field'])) {
        entity_views_field_definition($key, $property, $tables[$type]);

  return $tables[$type];
splig’s picture

There's another issue whereby the base_tables array is not being set before it is used.
Another suggested patch:


function entity_views_plugins() {
  // Have views cache the table list for us so it gets
  // cleared at the appropriate times.
  $data = views_cache_get('entity_base_tables', TRUE);
  if (!empty($data->data)) {
    $base_tables = $data->data;
  else {
	$base_tables = array();		// set to empty array before use 
    foreach (views_fetch_data() as $table => $data) {
      if (!empty($data['table']['entity type']) && !empty($data['table']['base'])) {
        $base_tables[] = $table;
    views_cache_set('entity_base_tables', $base_tables, TRUE);
fubhy’s picture

Status: Needs review » Active

Thanks guys!

However, please provide an actual .patch file before setting an issue to "needs review".

Needs Review ["CNR"]
A patch has been created and needs review and testing. The Testing Bot uses this status to trigger an automated review of the patch, and reports the results. Patch Reviewers also use this status to find patches that need to be reviewed and evaluated. With sufficient positive feedback, the patch may be promoted to the status "Reviewed & Tested by the Community" [see next definition]. If a reviewer, either human or Bot, finds a problem with the patch, it will then be marked as "Needs Work". Note that if a patch is not required in order to complete the idea described in the issue, then it is the idea itself that needs review.

Other than that (without actually looking into this): The suggested solution from #4 seems to be the right approach. I understand that the loop might not yield any results in some cases which would cause this error message.

You can learn how to create a patch right here:

fubhy’s picture

Version: 7.x-1.0-rc3 » 7.x-1.x-dev

Oh and by looking at the current dev tree the code is still the same there so the bug report should be filed against the dev branch instead of the release candidate.

cpliakas’s picture

Status: Active » Needs review
455 bytes
PASSED: [[SimpleTest]]: [MySQL] 354 pass(es). View

Converted #1630578-4: Notice: Undefined variable: base_tables in entity_views_plugins() (line 324 to a patch because I need this fix immediately. Sorry for commandeering someone else's work, but if this does get into the module please give splig credit for the patch.


fubhy’s picture

Status: Needs review » Reviewed & tested by the community
fago’s picture

Status: Reviewed & tested by the community » Fixed

thanks, committed.

rexgonzaga23’s picture

Thanks its fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.