Problem/Motivation

PHP 7 will introduce a few new reserved words and we could easily support PHP 7 by renaming some of our classes.

  • ./core/modules/views/src/Plugin/views/argument/Null
  • ./core/modules/views/src/Plugin/views/argument/String
  • ./core/modules/views/src/Plugin/views/filter/String.php
  • ./core/modules/views/src/Plugin/views/argument/Numeric
  • ./core/modules/views/src/Plugin/views/argument_validator/Numeric
  • ./core/modules/views/src/Plugin/views/field/Numeric
  • ./core/modules/views/src/Plugin/views/filter/Numeric

See:

Proposed resolution

Rename the String to StringArgument, StringFilter etc

Remaining tasks

Write patch, discuss renaming.

User interface changes

n/a

API changes

All classes that currently use PHP 7 reserved words will be renamed. Any filter or argument plugins that extend these classes will need updating.

Comments

benjy’s picture

benjy’s picture

Issue summary: View changes
benjy’s picture

Title: Rename Views string classes to support PHP 7 » Rename Views plugin classes to support PHP 7
Issue summary: View changes
dawehner’s picture

Issue tags: +VDC, +Novice

Let's see who picks this up

mpdonadio’s picture

mpdonadio goes back and rereads the proposed solution, so this can be ignored.

baisong’s picture

StatusFileSize
new76.26 KB

Will someone take a look at the annotations? I'm unsure when to add underscores vs simply concatenating the new prefixes to the ids.

tim.plunkett’s picture

+++ b/core/modules/views/src/Plugin/views/argument/NumericArgument.php
@@ -0,0 +1,132 @@
+ * Definition of Drupal\views\Plugin\views\argument\Numeric.
...
+class NumericArgument extends ArgumentPluginBase {

All of the @file lines need to be updated too

dawehner’s picture

Status: Active » Needs review

@baisong
Note: you can make the patch much smaller by using a better git configuration, see "Optimize diffs for renamed and copied files"
on https://www.drupal.org/documentation/git/configure

What does the bot say?

catch’s picture

Priority: Normal » Critical

Bumping to critical, this needs to happen before 8.0.0

rteijeiro’s picture

StatusFileSize
new20.74 KB
new5.73 KB

Fixed.

Status: Needs review » Needs work

The last submitted patch, 10: 2455415-rename-views-plugins-php10.patch, failed testing.

dawehner’s picture

+++ b/core/modules/views/src/Plugin/views/argument/ListString.php
@@ -34,7 +34,7 @@ class ListString extends StringArgument {
   /**
-   * Overrides \Drupal\views\Plugin\views\argument\String::init().
+   * Overrides \Drupal\views\Plugin\views\argument\StringArgument::init().
    */
   public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {

+++ b/core/modules/views/src/Plugin/views/argument/NumericArgument.php
@@ -2,7 +2,7 @@
  * @file
- * Definition of Drupal\views\Plugin\views\argument\Numeric.
+ * Definition of Drupal\views\Plugin\views\argument\NumericArgument.

+++ b/core/modules/views/src/Plugin/views/argument/StringArgument.php
@@ -2,7 +2,7 @@
 /**
  * @file
- * Definition of Drupal\views\Plugin\views\argument\String.
+ * Definition of Drupal\views\Plugin\views\argument\StringArgument.
  */
 

+++ b/core/modules/views/src/Plugin/views/argument_validator/NumericArgumentValidator.php
@@ -2,7 +2,7 @@
 /**
  * @file
- * Definition of Drupal\views\Plugin\views\argument_validator\Numeric.
+ * Definition of Drupal\views\Plugin\views\argument_validator\NumericArgumentValidator.
  */

+++ b/core/modules/views/src/Plugin/views/field/NumericField.php
@@ -2,7 +2,7 @@
 /**
  * @file
- * Definition of Drupal\views\Plugin\views\field\Numeric.
+ * Definition of Drupal\views\Plugin\views\field\NumericField.

+++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
@@ -2,7 +2,7 @@
 /**
  * @file
- * Definition of Drupal\views\Plugin\views\filter\Numeric.
+ * Definition of Drupal\views\Plugin\views\filter\NumericFilter.
  */

+++ b/core/modules/views/src/Plugin/views/filter/StringFilter.php
@@ -2,7 +2,7 @@
  * @file
- * Definition of Drupal\views\Plugin\views\filter\String.
+ * Definition of Drupal\views\Plugin\views\filter\StringFilter.

I think we could fix things properly while we are here.

rteijeiro’s picture

Status: Needs work » Needs review
StatusFileSize
new373.72 KB
new1.12 KB

Sorry for being such stupid for you @dawehner, but that's not the way to treat people when you want to attract people to contribute to Drupal. I'll omit also your comment in IRC because I know you personally but this can be misunderstood by people that don't know you or me.

Let's see I now my patch seems less stupid for you than the other one ;)

dawehner’s picture

Sorry for being such stupid for you @dawehner, but that's not the way to treat people when you want to attract people to contribute to Drupal. I'll omit also your comment in IRC because I know you personally but this can be misunderstood by people that don't know you or me.

I'm sorry but it was really not meant like that. I'll be serious from now on.

tim.plunkett’s picture

The last patch was not rolled against updated HEAD. It has a bunch of recent commits in there too.

mpdonadio’s picture

Status: Needs review » Needs work

Setting back to needs work b/c the diff included way too much, as Tim also mentioned. Maybe you pulled and didn't rebase?

--- a/core/modules/views/src/Plugin/views/argument/Numeric.php
+++ b/core/modules/views/src/Plugin/views/argument/NumericArgument.php
@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Definition of Drupal\views\Plugin\views\argument\Numeric.
+ * Definition of Drupal\views\Plugin\views\argument\NumericArgument.
  */

If these files are being touched, that per https://www.drupal.org/node/1354#file, this should be changed to

/**
 * @file
 * Contains \Drupal\views\Plugin\views\argument\NumericArgument.
 */

and so on for each class that got renamed. I got dinged on this today...

rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new449 bytes
new21.18 KB

Let me try :)

Status: Needs review » Needs work

The last submitted patch, 17: 2455415-17.patch, failed testing.

Status: Needs work » Needs review

rpayanm queued 17: 2455415-17.patch for re-testing.

dawehner’s picture

@rpayanm You seemed to have missed these changes.

+++ b/core/modules/views/src/Plugin/views/argument_validator/NumericArgumentValidator.php
@@ -2,7 +2,7 @@
- * Definition of Drupal\views\Plugin\views\argument_validator\Numeric.
+ * Definition of Drupal\views\Plugin\views\argument_validator\NumericArgumentValidator.
  */

+++ b/core/modules/views/src/Plugin/views/field/NumericField.php
@@ -2,7 +2,7 @@
  * @file
- * Definition of Drupal\views\Plugin\views\field\Numeric.
+ * Definition of Drupal\views\Plugin\views\field\NumericField.
  */

+++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
@@ -2,7 +2,7 @@
- * Definition of Drupal\views\Plugin\views\filter\Numeric.
+ * Definition of Drupal\views\Plugin\views\filter\NumericFilter.

Sorry for the nitpicks ...

rteijeiro’s picture

StatusFileSize
new21.15 KB
new3.18 KB

Sorry for the crappy patch in #13. I hope this one is better.

@dawehner thanks for the reviews ;)

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Sorry for the crappy patch in #13. I hope this one is better.

I hope things are alright again ... it was not intended to be cruel or something like that.

It looks great now!

rteijeiro’s picture

I hope things are alright again ... it was not intended to be cruel or something like that.

No problem, buddy! We'll have a beer at #drupaldevdays ;)

hussainweb’s picture

Status: Reviewed & tested by the community » Needs work

I think we missed out null from here: https://wiki.php.net/rfc/reserve_more_types_in_php_7. Working on a patch now.

hussainweb’s picture

Status: Needs work » Needs review
StatusFileSize
new1.36 KB
new22.52 KB

Renaming Null to NullArgument.

hussainweb’s picture

Issue summary: View changes

Updating IS for the new class.

dawehner’s picture

Good catch!

+++ b/core/modules/views/src/Plugin/views/argument/NullArgument.php
@@ -2,7 +2,7 @@
- * Definition of Drupal\views\Plugin\views\argument\Null.
+ * Definition of Drupal\views\Plugin\views\argument\NullArgument.

It would be great if we could update the docs here, similar to the other examples.

hussainweb’s picture

StatusFileSize
new522 bytes
new22.51 KB

Done

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Awesome, thank you

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue addresses a critical bug and is allowed per https://www.drupal.org/core/beta-changes. Committed e5d6c14 and pushed to 8.0.x. Thanks!

  • alexpott committed e5d6c14 on 8.0.x
    Issue #2455415 by rteijeiro, hussainweb, rpayanm, baisong: Rename Views...
tr’s picture

Doesn't this at least deserve a change notice? This broke a lot of my code over the weekend...

mpdonadio’s picture

Anybody can make CR. I just published one for this issue: #2458383: Views plugin classes renamed to support PHP 7

tr’s picture

Thank you. I know anyone can do it, but it should be done as part of the process, in conjunction with the commit, otherwise we are left with hundreds of changes with no documentation of the change. It's very frustrating porting D7 to D8, or even D8 from two months ago to D8 today, when everything breaks and there is no mention of the change anywhere. This is especially bad with anything Views related, because it's poorly documented to begin with.

dawehner’s picture

This is especially bad with anything Views related, because it's poorly documented to begin with.

So please help and don't just complain!

tr’s picture

I was explaining, not complaining. And I have been helping for years, in case you haven't been paying attention ...

dawehner’s picture

@TR
Yeah no offence to you, I was more referring to the general complaining in the Drupal community,
which pisses me off a lot. Believe me, but I won't work on core at 1am at the night.

Status: Fixed » Closed (fixed)

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