Convert to OOP Hooks

Created on 16 November 2024, 2 months ago

Problem/Motivation

Core support OOP hooks
I am testing my conversion script on webform

Steps to reproduce

N/A

Proposed resolution

Run rector
Check tests

Remaining tasks

User interface changes

N/A

API changes

N/A

Data model changes

N/A

πŸ“Œ Task
Status

Active

Version

6.3

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States nicxvan

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

Merge Requests

Comments & Activities

  • Issue created by @nicxvan
  • Merge request !548convert no deletions β†’ (Open) created by nicxvan
  • Pipeline finished with Failed
    2 months ago
    Total: 381s
    #340814
  • Merge request !549convert β†’ (Open) created by nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    nicxvan β†’ changed the visibility of the branch 3487957-convert-to-oop to hidden.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • Pipeline finished with Failed
    2 months ago
    Total: 1210s
    #340820
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    For some reason some use statements are being duplicated.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • Merge request !550convert β†’ (Open) created by nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    nicxvan β†’ changed the visibility of the branch 3487957-convert2.0 to hidden.

  • Pipeline finished with Failed
    2 months ago
    Total: 1990s
    #344915
  • Pipeline finished with Failed
    2 months ago
    Total: 2284s
    #347185
  • Pipeline finished with Success
    about 1 month ago
    Total: 194s
    #372227
  • Pipeline finished with Success
    about 1 month ago
    Total: 210s
    #372320
  • Pipeline finished with Success
    about 1 month ago
    Total: 184s
    #372378
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Set to needs review for discussing the process with the maintainers.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    I think we need an MR to 6.3.x that sees what tests are failing. Depending on the number of tests failing we could commit this to 6.3.x or wait until 6.4.x.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I can work on this again, the main thing is I wanted to confirm if you were willing to help track down the issues and do a single merge.

    It might be a couple of days though.

  • Pipeline finished with Failed
    7 days ago
    Total: 795s
    #396887
  • Pipeline finished with Failed
    7 days ago
    Total: 835s
    #397009
  • Status changed to Needs review 7 days ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    Let's see what the issues are before we manually fix them. I am assuming you are using Drupal Rector.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Yes, more specifically the script here: https://gitlab.com/-/snippets/4769802

  • Merge request !582Draft: Resolve #3487957 "Rectoronly" β†’ (Open) created by nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I've done no code sniffing or manual changes, here is just running rector.
    https://git.drupalcode.org/project/webform/-/merge_requests/582/diffs

  • Pipeline finished with Failed
    7 days ago
    Total: 561s
    #397027
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I think I have a fix for the comments being deleted thanks to @chx

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    nicxvan β†’ changed the visibility of the branch 3487957-print to hidden.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    nicxvan β†’ changed the visibility of the branch 3487957-rectorOnly to hidden.

  • Merge request !583Rector β†’ (Open) created by nicxvan
  • Pipeline finished with Failed
    7 days ago
    Total: 541s
    #397049
  • Pipeline finished with Failed
    7 days ago
    Total: 256s
    #397060
  • Merge request !584Resolve #3487957 "Rectorv3" β†’ (Open) created by nicxvan
  • Pipeline finished with Failed
    6 days ago
    Total: 498s
    #397144
  • Pipeline finished with Failed
    6 days ago
    Total: 490s
    #397155
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Steps I took for rectorv3

    Checkout that branch in an 11.x version of drupal in ddev
    Add this script https://gitlab.com/-/snippets/4769802 to ddev and run it
    yes to both questions
    Commit rector changes

    Find and replace // phpcs:ignore with something easily found (since it breaks codefix) I used // elephant
    Run codefix in ddev

    ./vendor/bin/phpcbf \
      --standard="Drupal,DrupalPractice" -n \
      --extensions="php,module,inc,install,test,profile,theme" \
      web/modules/contrib/webform
    

    Find and replace // elephant for // phpcs:ignore to swap it back
    Commit and push

    3 known codesniff issues
    1. unused use statements, rector expands arguments - not sure why codefix isn't fixing these
    2. t() in classes
    3. \Drupal in classes, rector doesn't do injection

  • Pipeline finished with Failed
    6 days ago
    Total: 1645s
    #397225
  • Pipeline finished with Failed
    6 days ago
    Total: 996s
    #397728
  • Pipeline finished with Skipped
    6 days ago
    #397760
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    nicxvan β†’ changed the visibility of the branch 3487957-rectorv2 to hidden.

  • Pipeline finished with Failed
    6 days ago
    Total: 520s
    #397936
  • Pipeline finished with Canceled
    5 days ago
    Total: 112s
    #398180
  • Pipeline finished with Success
    5 days ago
    Total: 1004s
    #398175
  • Pipeline finished with Success
    5 days ago
    Total: 7811s
    #398181
  • Pipeline finished with Skipped
    5 days ago
    #398761
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    nicxvan β†’ changed the visibility of the branch 6.3.x to hidden.

  • Merge request !589Resolve #3487957 "Rectorv4" β†’ (Open) created by nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    rectorv4 is the MR to review just waiting on tests. I updated the script to handle the unused use statements too.

  • Pipeline finished with Failed
    5 days ago
    Total: 449s
    #399006
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    nicxvan β†’ changed the visibility of the branch 3487957-rectorv3 to hidden.

  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    This looks very promising. If you are able to get an MR that has all the tests passing and phpcs is okay(ish). We should make the commit.

    Things like dependency injection can be fixed later (or never).

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Sounds great! The only failures I see other than code sniffing are deprecations that are on HEAD so I assume those can be ignored.

    I can look at all of the code sniff failures besides t() and dependency injection.

    I can create a manual patch for those I think this week.

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    The phpcs checks were passing two days ago on 6.3.x, so they ought to keep passing.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    The issue is twofold.

    t() in .module doesn't throw phpcs errors but it does in classes.

    Drupal service calls are the same.

    Rector doesn't address these so they have to be manually addressed.

    I need to still review the other cs failures.

    Would you be willing to having a temporary skip rule for those two?

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I spent a couple of hours going through, still got a lot to go.

    I'd like confirmation on whether we can skip the t() and injections.

  • Pipeline finished with Failed
    2 days ago
    Total: 516s
    #400440
  • Merge request !590Rector4b β†’ (Open) created by nicxvan
  • Pipeline finished with Failed
    2 days ago
    Total: 429s
    #400476
  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    I'm inclined that we should not go backwards on our coding standards compliance.

    Why the new merge request? What is different?

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I am testing a different tool for addressing the arrays.

    As I mentioned it's not going backwards.

    These are patterns that exist in the procedural code but get flagged in classes.

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    What I mean by going backwards is not that the code is getting worse (it's not). I just mean that currently phpcs passes and with this merge request it doesn't.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    nicxvan β†’ changed the visibility of the branch rector4b to hidden.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I just noticed we already have an ignore rule for \Drupal calls, it's just not taking effect, let me look at that. If that were in place this would be far more manageable.

  • Pipeline finished with Failed
    1 day ago
    Total: 513s
    #400977
  • Pipeline finished with Failed
    1 day ago
    Total: 510s
    #400985
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Just to add some context here, this is a bulk rector pass, conflicts for auto generated commits like this need to be just scrapped and redone, they are not like normal conflicts where you can resolve them since it's bulk copying functions to methods. The more manual work on top of that the more fragile it becomes.

    I'm willing to commit to resolving these codesniff rules in follow ups, they are generally not complex to fix and once this is in those issues could be rebased with a normal workflow.

    The risk of conflict is much lower.

    CS is passing now with rules addressing t() \Drupal and one DateFormat calls.

  • Pipeline finished with Success
    1 day ago
    Total: 393s
    #400996
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    I completely understand that we must skip fixing the dependency injections.

    If you are saying in a later commit, we can automatically fix the t() calls since all that is required is the trait and then a search and replace, this is good enough to be committed.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Neither of those will be fixed automatically, but I am committing to working on both of those follow ups if this gets committed here.

    The thing is I can manage and rebase those two fixes in a follow up (or more likely separate followups) in a more standard manner once this is in.

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    This is a very big patch and I am feeling some pressure to have full release for 6.3.0. Perhaps we should put this onto a 6.4.x branch.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    While it is a big patch, this is the same process used for core to convert, and we can spot check that the conversions are accurate. Since this is rector it's really just copying the hooks to a hook class an method.

    Webform also has more tests than most modules so we can have more confidence than most modules would have that this won't introduce systemic issues.

Production build 0.71.5 2024