Incorrect code being generated by drupal-rector for automated upgrade bot

Created on 10 April 2024, over 1 year ago
Updated 22 August 2024, 11 months ago

Drupal version

11.x-dev SHA-1: 922c101dbbcc1785263854d8bb0747f10fb89f7d

Drupal Rector version

  • drupal/upgrade_status: 4.1.0
  • mglaman/phpstan-drupal: 1.2.10
  • palantirnet/drupal-rector: 0.20.1

Problem / Motivation

While preparing G2 glossary for D11, I got nonsensical code generated by the automated project bot apparently using rector, flagged as such on gitlab (Major: Undefined variable: $this) See https://git.drupalcode.org/project/g2/-/merge_requests/12/diffs : the bot generates $this-> references in a public static create method.

🐛 Bug report
Status

Active

Component

Code

Created by

🇫🇷France fgm Paris, France

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @fgm
  • 🇳🇱Netherlands bbrala Netherlands

    Wow interesting, wonder what broke this.

    How to reproduce:

    1. install drupal 10
    2. composer require drupal/g2:dev-11.x#922c101dbbcc1785263854d8bb0747f10fb89f7d
    3. composer require palantirnet/drupal-rector
    4. cp vendor/palantirnet/drupal-rector/rector.php .
    5. vendor/bin/rector --dry-run

    This should also print what rules were used, if not, up the verbosity of rector.

    When we know what rule broke this, we can add a test for this pattern to that rule and fix it.

  • 🇫🇷France fgm Paris, France

    I wonder: should I be expecting any news on this, or just forget about rector since the module is already compatible with D11 anyway and the ugprade bot keeps pushing nonsense on 📌 Automated Drupal 11 compatibility fixes for g2 Needs review ?

  • 🇳🇱Netherlands bbrala Netherlands

    Asked for somw extra info, but i think i also checked upstream and posted a patch.

    https://github.com/rectorphp/rector-symfony/pull/610

    Appearantly this did not fix the issue?

    Im back from vacation next week and will do some issue queue maintenace.

Production build 0.71.5 2024