Attached patch is the result from a PhpStorm code inspection for undefined variables analysis only focused on the core/modules/views/src/Plugin/views tree

The patch is not ready as it needs some expert review.

Settings:

Report contains:

Undefined variable 'arg'
Variable 'options' might have not been defined
Variable 'sort_options' might have not been defined
Variable 'custom_format' might have not been defined
Variable 'custom_format' might have not been defined
Variable 'custom_format' might have not been defined
Variable 'custom_format' might have not been defined
Variable 'custom_format' might have not been defined
Variable 'custom_format' might have not been defined
Variable 'custom_format' might have not been defined
Variable 'custom_format' might have not been defined
Variable 'source' might have not been defined
Variable 'identifier' might have not been defined
Variable 'identifier' might have not been defined
Variable 'identifier' might have not been defined
Variable 'source' might have not been defined
Variable 'identifier' might have not been defined
Variable 'source' might have not been defined
Variable 'identifier' might have not been defined
Variable 'identifier' might have not been defined
Variable 'source' might have not been defined
Variable 'exposed_filters' might have not been defined
Variable 'sort_field' might have not been defined
Variable 'sort_table' might have not been defined
Variable 'value' might have not been defined
Variable 'value' might have not been defined
Variable 'group_types' might have not been defined
Variable 'id' might have not been defined
Variable 'groups' might have not been defined
Variable 'default_field' might have not been defined
Variable 'table' might have not been defined
Variable 'plugin_name' might have not been defined
Variable 'plugin_name' might have not been defined
Variable 'options_name' might have not been defined
Variable 'raw_items' might have not been defined
Variable 'offset_seconds' might have not been defined
Variable 'offset_seconds' might have not been defined
Variable 'offset_seconds' might have not been defined
Undefined variable 'matches'
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

clemens.tolboom’s picture

Issue summary: View changes
FileSize
28.01 KB

Added screenshot for settings and list of report.

clemens.tolboom’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, plugin-views-undefined-vars.patch, failed testing.

dawehner’s picture

  1. +++ b/core/modules/views/src/Plugin/views/argument_validator/None.php
    @@ -28,7 +28,7 @@ public function validateArgument($argument) {
     
    -    if (!empty($this->argument->definition['numeric']) && !isset($this->argument->options['break_phrase']) && !is_numeric($arg)) {
    +    if (!empty($this->argument->definition['numeric']) && !isset($this->argument->options['break_phrase']) && !is_numeric($argument)) {
           return FALSE;
         }
     
    

    This is indeed a bug

  2. +++ b/core/modules/views/src/Plugin/views/field/Date.php
    @@ -135,12 +135,15 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    +      // TODO: what values can this have?
    ...
    +      if (in_array($format, array('custom', 'raw time ago', 'time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span'))) {
    

    The value is a timestamp

  3. +++ b/core/modules/views/src/Plugin/views/filter/InOperator.php
    @@ -180,6 +180,13 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
    +    /** @var string $source */
    +    $source = '';
    +
    +    /** @var string $identifier */
    +    $identifier = '';
    
    +++ b/core/modules/views/src/Plugin/views/filter/Numeric.php
    @@ -148,6 +148,12 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
    +    /** @var string $source */
    +    $source = '';
    +
    +    /** @var string $identifier */
    +    $identifier = '';
    
    +++ b/core/modules/views/src/Plugin/views/filter/String.php
    @@ -190,6 +190,13 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
    +    /** @var string $source */
    +    $source = '';
    +
    +    /** @var string $identifier */
    +    $identifier = '';
    

    Sorry but I don't see a value in this inline comments, do you?

  4. +++ b/core/modules/views/src/Plugin/views/query/Sql.php
    --- a/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php
    +++ b/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php
    

    I would like to have a dedicated issue to test the groupwise max relationship properly, to be honest.

  5. +++ b/core/modules/views/src/Plugin/views/style/StylePluginBase.php
    @@ -637,7 +637,8 @@ protected function renderFields(array $result) {
    -          $this->rowTokens[$count] = $this->view->field[$id]->getRenderTokens(array());
    +          // @todo: only for wrapping up ... then use end($keys)?
    +          $this->rowTokens[$count] = $this->view->field[end($keys)]->getRenderTokens(array());
    

    Well, the idea is indeed to use the last used $id, maybe wrap this with if isset($id) ?

  6. +++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php
    @@ -793,8 +793,10 @@ protected function defaultDisplayOptions() {
    +      $default_field = 'X';
    
    @@ -870,6 +872,7 @@ protected function defaultDisplayFiltersUser(array $form, FormStateInterface $fo
    +        $table = 'X';
    

    use just NULL;

tim.plunkett’s picture

Version: 8.x-dev » 8.0.x-dev

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Lendude’s picture

Category: Bug report » Task

Not sure how to proceed here. Pretty sure we are not just going to update this without adding test coverage for the changes, but stuff like #4.1 still lives in core today, so don't just want to close this. I am going to change this to a task. Anything that is an actual bug, should probably be spun off into its own issue so we can get test coverage for that going.

clemens.tolboom’s picture

@lendude maybe best is to report #4.1 as a new issue plus a task for better static analysis xref here then close this one?

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.