Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294883

Variable is not set in some cases and leads to log a php notice.

$
0
0

Drupal 8.0.4
Server version: Apache/2.4.16 (Unix)
PHP 5.5.30 (cli)
mysql Ver 14.14 Distrib 5.7.10, for osx10.9

Repeatable: Render a view block for the first time
Steps to repeat:
1. Create a new theme.
2. Create a custom content type
3. Create a custom view block to display this custom content type
4. Place block
5. Create new content (custom type)
6. Visit page

This notice is raised on line 296 of Drupal\views\Plugin\views\PluginBase, where try to access $this->definition['theme'] that is not set.

To track this notice I changed themeFunctions() function in Drupal\views\Plugin\views\PluginBase to:

  public function themeFunctions() {
    if (isset($this->definition['theme'])) {
      return $this->view->buildThemeFunctions($this->definition['theme']);
    } else {
      \Drupal::logger('theme')->warning("themeFunctions() :: definition['theme'] is not set in %class.", array('%class' => get_called_class()));
    }
  }

In this function:
- If returns a empty array raise a php notice and a Drupal warning on ThemeManager->render(), because $hook is empty and $candidate will be not set (Screenshot attached);
- If returns nothing (like above), runs fine. (?)


Viewing all articles
Browse latest Browse all 294883

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>