Rename Stage to StageBase to clarify its relationship to its subclasses, and add "Stage" suffix to the Updater classes

Created on 12 December 2022, almost 2 years ago
Updated 11 April 2023, over 1 year ago

Problem/Motivation

As discussed on the December 8 call (see #3248975-10: Use "stage directory" instead of "staging area" or "staging directory" everywhere โ†’ ), we all (Ted, Travis, Omkar, Yash, Kunal, Wim) agreed that \Drupal\package_manager\Stage is too confusing a name because:

  1. its subclasses are called Updater, BlahUpdater and Installer, which makes more sense
  2. "stage" is both a noun and a verb, but inconsistent with the above
  3. it's too closely aligned with "stage directory", "staging area", etc

Steps to reproduce

Proposed resolution

StageManager was the best we came up with so far.

Also update related names to A) match the new name, B) be more consistent than they have been so far. To be updated:

  1. \Drupal\package_manager\PathLocator::getStagingRoot() (surfaced in #3248975-17: Use "stage directory" instead of "staging area" or "staging directory" everywhere โ†’ )

Remaining tasks

Is Stage Manager really the best name?

User interface changes

None.

API changes

TBD

Data model changes

None.

๐Ÿ“Œ Task
Status

Fixed

Version

3.0

Component

Code

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

Live updates comments and jobs are added and updated live.
  • API change

    Changes an existing API or subsystem. Not backportable to earlier major versions, unless absolutely required to fix a critical bug.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tedbow Ithaca, NY, USA
  • Status changed to Active almost 2 years ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Per #7.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kunal.sachdev

    kunal.sachdev โ†’ made their first commit to this issueโ€™s fork.

  • Assigned to kunal.sachdev
  • @kunalsachdev opened merge request.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kunal.sachdev

    So, I started to rename things from Stage/stage to StageManager/stage manager but in \Drupal\package_manager\StatusCheckTrait I refactored

    * @param \Drupal\package_manager\Stage $stage
    *   The stage to run the status check for.
    

    to

    * @param \Drupal\package_manager\StageManager $stage_manager
    *   The stage manager to run the status check for.
    

    but it's sounding a little vague, there can be more such cases where stage manager wording is not suitable. So, should we think of another name?

  • Issue was unassigned.
  • Status changed to Postponed: needs info almost 2 years ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Let's discuss with @tedbow & @phenaproxima tomorrow.

  • Status changed to Needs work almost 2 years ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tedbow Ithaca, NY, USA
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    Honestly...I like StageManager as a new name for Stage. I think it's not particularly verbose, and it's a lot clearer than stage. It inherently implies certain already-existing design decisions (namely, you have only one stage at any given time).

    I'm going to open an MR to rename it.

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    WFM! But there's still some unaddressed problems then:

    1. Many comments no longer make sense โ€” see MR for details.
    2. We should rename \Drupal\package_manager\StageManager::getStagingRoot() to ::getRoot()
    3. We should rename \Drupal\package_manager\PathLocator::getStagingRoot() to ::getStageRoot()
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    Many comments no longer make sense

    Yeah, this is gonna be messy.

    Agreed on the method renames, and implemented.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Yeah, this is gonna be messy.

    Messy today, virtually impossible once it's in core! ๐Ÿ˜… So it's the right kind of mess/pain ๐Ÿ˜„

  • Assigned to wim leers
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    I think I've fixed most instances of "stage" across Package Manager and Automatic Updates.

    No doubt there are still some stragglers here and there which evaded my heuristics, but those should be easy to clean up later. I'm guessing they are all just in comments. This MR renames Stage to StageManager, and TestStage to TestStageManager.

  • Assigned to phenaproxima
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Checked it out locally and searched in PHPStorm for the stage\W regex to find remaining "stage" occurrences.

    99% of them made sense ๐Ÿ‘

    Stragglers:

    1. StageManager $stage should become StageManager $stage_manager everywhere.
    2.  * \Drupal\package_manager\Event\PreOperationStageEvent. All events have a
       * $stage property which allows access to the stage object itself.
      
      

      โ†’ this is where point 1 actually affects the public API in a perhaps unexpected way!

    3. $stage = $this->updater;
      
      $stage instanceof
      

      i.e. whenever $stage is the variable/property name, but it's not "the stage", but instead "the stage manager".

    4. // We only want to do this check if the stage belongs to Automatic Updates.
      

      โ†’ similarly: stage manager, not stage. But this is the only such remaining comment reference I could find! ๐Ÿ‘ (It occurs in three files though.)

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    ๐Ÿ“ Reviewed using git diff 4ea1985d0beeb0d401bc1adefa7af1b459c9adfc HEAD.

    It's thanks to the challenges I spotted during this review that I thought of an alternative approach:

    1. An abstract basic stage with no specializations: Stage(Manager) โ†’ abstract BasicStage or SimpleStage
    2. Non-abstract specialized stages: Updater โ†’ UpdateStage and CronUpdater โ†’ CronUpdateStage
    3. Only \Drupal\package_manager\PackageManagerUninstallValidator and \Drupal\package_manager_test_api\ApiController::create() instantiate a Stage(Manager), we could easily provide an anonymous class in both places to overcome that challenge.

    I think that'd actually be far closer to the reality we want? We would then:

    1. only ever use specialized "stages", except in one test and a very abstract/generic uninstallation validator
    2. still be able to keep all the existing docs about "The stage for which to fire an event" etc โ€” it'll just then be very clear that the PHP type declaration refers to the basic stage, but only a concrete/specalized stage can be passed in

    ๐Ÿ‘† This is exactly what we have for (Content)EntityBase!

    Because \Drupal\project_browser\ComposerInstaller\Installer can then become InstallerStage.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tedbow Ithaca, NY, USA
    1. re #23 I am not opposed to making \Drupal\package_manager\Stage an abstract call and changing Updater โ†’ UpdateStage and CronUpdater โ†’ CronUpdateStage it seems like a good thing to do.
    2. Regarding the current use of Stage directly in \Drupal\package_manager\PackageManagerUninstallValidator. I think it would be better here to make a non-abstract AvailabilityCheckerStage or something along those lines which would only allow calling isAvailable() and isApply() so that it would very clear how you can check these things if you wanted to stop other operations from happening while Package Manager was applying. I think us making a non-test anonymous class would set a bad example because someone could see that example and think "oh if I just want require a package real quick I could also just make anonymous class". So we would have to document why our use of anonymous class was ok but for other operations it is bad idea(assuming it is). I think AvailabilityCheckerStage would be clearer
    3. Just having the abstract Stage class though doesn't really solve the problems stated in the summary
      • "stage" is both a noun and a verb, but inconsistent with the above
      • it's too closely aligned with "stage directory", "staging area", etc

      I think maybe it just proves that StageManager is not that much better

    I would suggest we create another issue to

    1. Stage abstract
    2. create AvailabilityCheckerStage which would get rid of 1 non-test anonymous stage use.
    3. rename Updater โ†’ UpdateStage and CronUpdater โ†’ CronUpdateStage

    Then we just leave this issue open because I still think we have solved the naming problem of "stage" as described in the summary. Maybe as we get more fresh eyes in the this review process someone will come up with a more obvious name

  • Assigned to tedbow
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Then why not just change class Stage to abstract class StageBase?

    Thatโ€™s what I actually already proposed in my previous comment: abstract class BasicStage or abstract class SimpleStage.

    All three of these choices make it clear itโ€™s a noun and not a verb.

  • Issue was unassigned.
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tedbow Ithaca, NY, USA

    Then why not just change class Stage to abstract class StageBase?

    That sounds good to me plus a new AvailabilityCheckerStage for PackageManagerUninstallValidator

  • Assigned to kunal.sachdev
  • @kunalsachdev opened merge request.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kunal.sachdev

    Discussed with @tedbow and @phenaproxima about #24 ๐Ÿ“Œ Rename Stage to StageBase to clarify its relationship to its subclasses, and add "Stage" suffix to the Updater classes Fixed .2 and got to a conclusion that for now we can have anonymous class as suggested by @Wim Leers in #23 ๐Ÿ“Œ Rename Stage to StageBase to clarify its relationship to its subclasses, and add "Stage" suffix to the Updater classes Fixed .3

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    ๐Ÿฅณ Glad to see this happening! ๐Ÿš€

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Assigned to yash.rode
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia yash.rode pune
  • Assigned to kunal.sachdev
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia yash.rode pune
    • \Drupal\Tests\automatic_updates_extensions\Kernel\ExtensionUpdaterTest
    • \Drupal\Tests\package_manager\Unit\StageTest
    • \Drupal\Tests\package_manager\Kernel\StageTest
    • \Drupal\Tests\automatic_updates\Kernel\TestCronUpdater and \Drupal\Tests\automatic_updates\Kernel\CronUpdaterTest

    should also be renamed. Other than that I can confirm all occurrences of
    ExtensionUpdater are replaced with ExtensionUpdateStage,
    Stage are replaced with StageBase,
    Updater are replaced with UpdateStage and
    CronUpdater are replaced with CronUpdateStage.

  • Assigned to yash.rode
  • Status changed to Needs review over 1 year ago
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia yash.rode pune

    Now this looks more consistent to me.

  • Assigned to phenaproxima
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    Ooof, 74 files changed...! Self-assigning to review.

  • Assigned to kunal.sachdev
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    As I looked at this, I felt that the class renaming is so effective that, indeed, things like ExtensionUpdateStage $extensionUpdateStage are redundant! I think it would be clear to say ExtensionUpdateStage $stage, and it'd be quite clear that this is a type of stage.

    But, just to sanity check myself, I proposed this to @tedbow as well in a Zoom conversation, and he agreed that the type hints are so much clearer that we can remove verbose, redundant variable and method names. So that's what I'm going to do in my review -- point out the places where we could rename these.

    That said, this is great work and I think it's a good solution to this problem. Well done all!

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Assigned to kunal.sachdev
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    Looks great!

    One or two small things, then this is good to go from a code perspective. Apart from that, this only needs the follow-up @tedbow requested in #24 to be filed, at which point this is RTBC.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts
  • Assigned to phenaproxima
  • Status changed to Needs review over 1 year ago
  • Status changed to RTBC over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    Love it.

    RTBC once the follow-up is open.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    In discussion with @kunal.sachdev and @tedbow in Slack, we came to the conclusion that we don't need the follow-up to create AvailabilityCheckerStage, because it's probably overkill at the moment. The only place we need to generically check stage availability is in Package Manager's uninstall validator, and the anonymous class is fine for that right now.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts
  • Issue was unassigned.
  • Status changed to Fixed over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    ๐Ÿš€

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

Production build 0.71.5 2024