Problem/Motivation
Follow-up to #3346707: Add Alpha level Experimental Package Manager module.
Package manager currently uses the word 'stage' to mean several things.
1. A 'staging environment' as in composer stager. @phenaproxima mentioned changing this to sandbox in https://git.drupalcode.org/project/drupal/-/merge_requests/3608#note_376550
2. As a verb, i.e. to 'stage' the stage/sandbox environment.
3. As a synonym of 'phase' or 'step', or the object which manages the lifecycle of a staging directory.
For example:
StageEvent
"The stage event during which this exception is thrown."
"Stage operations"
I personally found this quite confusing when reviewing the code, it's hard to scan something and see what it's referring to at any one time.
Steps to reproduce
Proposed resolution
See #5 and #9. The gist is that, generally, we will refer to "sandboxes" instead of stages, and the classes we now call stages will be referred to as sandbox managers. "Phase" specifically refers to creating, applying, and destroying a sandbox, whereas "operations" are Composer things you do to an existing sandbox (Package Manager only implements one, which is require, but there's no hypothetical reason we couldn't have more in contrib.)
Remaining tasks
Opening this as a beta blocker because it is very likely to involve some class renames, even if the only consumers of the API are automatic updates and project browser - but that could get complicated with the contrib versions.
This will actually be fixed in two issues:
- This issue will rename the various classes and runtime code to use better terminology as part of finalizing the API.
- In #3519799: Update all comments and documentation in Package Manager to refer to "sandboxes" and related terminology, which is a stable-blocking issue, we'll alter all commentary and documentation to use the updated wording. That issue won't touch any runtime code.
API changes
Many of Package Manager's classes will be renamed.
Release notes snippet
Issue fork drupal-3474876
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3474876-clarifyreplace-stage-terminology
changes, plain diff MR !11872
Comments
Comment #2
catchComment #3
larowlanComment #4
benjifisherWe discussed this issue at #3517306: Drupal Usability Meeting 2025-04-11. That issue will have a link to a recording of the meeting.
For the record, the attendees at the usability meeting were benjifisher, rkoller, and simohell.
We are not familiar with the code base and the various ways that "stage" is used, but we tried to suggest some guidelines for naming things.
First, we agree with the first suggestion in the Proposed Resolution. If adding "directory" is too long, then use "staging" or "staged", not "stage" in the context of the staging directory. For example: use
StagingBaseorStagingDirectoryBaseinstead ofStageBase.Second, use "phase" or "step" instead of "stage" when you can. Use "step" if it is possible to move back, or "phase" if only one direction is possible.
I hope those suggestions are helpful!
Comment #5
phenaproximaA few proposals:
StageBaseshould becomeSandboxManagerBase, to more accurately describe what it does. Hopefully, this will completely disambiguate the concept of an object that manages the existence and lifecycle of a sandbox. Generically these will be referred to as "sandbox managers"Comment #6
tedbow#5 sounds good to me
Comment #7
phenaproximaThis is a huge scope of work. I'd like to propose that we split up the work here into two issues.
Comment #9
phenaproximaI think this is ready for an initial review. It doesn't change any commentary, only runtime code.
StageBaseis nowSandboxManagerBase.$stageproperty now have a$sandboxManagerproperty.getStageDirectory()andstageDirectoryExists()are nowgetSandboxDirectory()andsandboxDirectoryExists().$stageare now$sandbox_manager.StageExceptionis nowSandboxException).StageFailureMarkerExceptionnow has the less ambiguous name ofFailureMarkerExistsException.PreOperationStageEventwas named years ago, before we understood that the "pre" events are central to validation. But, since the ability to log show-stopping errors is their only real superpower, I have renamedPreOperationStageEventtoSandboxValidationEventto clarify its purpose.Comment #10
phenaproximaRe-titling for clarity. @catch endorsed the two-issues idea in Slack.
Comment #11
phenaproximaOpened #3519799: Update all comments and documentation in Package Manager to refer to "sandboxes" and related terminology to do the documentation and comment changes.
Comment #12
phenaproximaComment #13
catch#5 looks really good to me, it's immediately obvious what the new terms are likely to refer to, even when I'm not sure what the old terms refer to - so that's an instant improvement in terms of both self-documenting naming as well as disambiguation.
Given the module is still alpha, and this is a blocker for beta, splitting this into code-naming + docs references seems fine to keep things reviewable. We can probably get both issues done quicker than trying to do it in one go.
edit: wrote that before reviewing the MR, but that also looks great.
Comment #14
phenaproximaWhile discussing this with @catch in Slack, I realized that
RequireEventTraitcould be better-named. There is nothing about it that specifically has anything to do with acomposer requireoperation -- if, say, we implemented acomposer removecapability in the future, and wanted to dispatch a pre- and post-event for that, then we'd want to also use something likeRequireEventTrait, but it would be confusingly named for that scenario.I've renamed it to the clearer and more accurate
EventWithPackageListTrait. This could have been done in its own issue, but while we're getting everything ready to go with better permanent names in this one beta-blocking issue, I figured now was the easiest time to do it.Comment #15
catchWent through the MR twice, there are no logic changes, just the renames. All the renames make sense to me. In some places you can see the mis-match with the docs that will be updated in the follow-up, but even with the mismatch it's clearer because it's more obvious what's being referred to.
We won't completely remove the stage/stager concept because that's also in composer stager, but I think it's fine if we're 'staging sandboxes' using a Drupal adjacent third party library - composer stager has less concepts to balance than package manager / automatic updates / project browser.
If we find other small naming issues we can always address those during beta or future minor releases after stable with deprecations, but the large number of changes here shows why this needs to happen during alpha.
Automatic updates ships its own version of package_manager still, so should be able to handle any compatibility issues smoothly by the release that removes the package_manager module also ensuring full compatibility with core package manager.
For sites that include both automatic updates + project browser, the transition from contrib package manager to core package manager will also be handled by automatic updates, but project browser itself will likely need versions for before/after 11.2 - that will have to happen for an 11.2-compatible Drupal CMS release, and the quicker we do all of this the better so we don't have to do it when things are even further along.
Moving this to RTBC which means I can't commit it, but if it's still in the RTBC queue without objections in a week or so, additional RTBCs would let me commit it in that case.
Comment #16
phenaproximaAdjusting credit.
Comment #17
tedbow@phenaproxima thanks for this. I think it is great improvement!
@catch thanks for the detailed review.
I still see a lot of variables that start with `$stage*` or are just `$stage` . and function names like `\Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase::createStage`
Since this issue just deals with class names and the follow-up #3519799: Update all comments and documentation in Package Manager to refer to "sandboxes" and related terminology do we want to expand this issue update variable and function names or create a follow-up for that too?
Comment #18
phenaproximaI think renaming local variables and test methods can be done in a follow-up. I'm pretty sure Package Manager's tests aren't part of its API, and therefore we have some latitude to change them later. But I'll try get them done before 11.2 beta1 anyway.
Comment #19
phenaproximaOpened #3520506: Remove minor usages of "stage" from Package Manager's runtime code to do more clean-up.
Comment #20
larowlanI checked this out locally and searched for
Stagein the package manager code base. There's still a lot of references. A lot are to the ComposerStager classes from the PHPTuf namespace and can be ignored. But there's still some class names and methods in runtime (non test) code that useStageand notSandbox. I think we should address at least the class names, constants and methods here. There are also some local variables. Not super fussed on those, that could be a low priority follow-up for a Novice - a lot of these are only in tests.\Drupal\package_manager\Validator\StagedDBUpdateValidatorhas a methodcheckForStagedDatabaseUpdatesbut it appears to be checking the sandbox for database updates. Should it also be renamed?\Drupal\package_manager\Validator\StageNotInActiveValidatoris checking if a sandbox is part of the project root - should it be renamed too? It adds an error with textStage directory is a subdirectory of the active directory.- that is neither a runtime class or a code comment so I'm not sure which phase that should be changed in - are we missing a third stage to this issue to update user facing strings or should we do that here?\Drupal\package_manager\ComposerInspector::validateExecutablehas a variable$stage_dirshould that now be$sandbox_dir\Drupal\package_manager\SandboxManagerBase::TEMPSTORE_DESTROYED_STAGES_INFO_PREFIX?\Drupal\package_manager\SandboxManagerBase::rethrowAsStageExceptionthrows aSandboxException- should we rename that method too?\Drupal\package_manager\SandboxManagerBase::createhas a variable$stage_dirthat refers to a sandbox. So do\Drupal\package_manager\SandboxManagerBase::applyand\Drupal\package_manager\PathExcluder\SiteConfigurationExcluder::syncDefaultSiteDirectoryPermissions- rename?\Drupal\package_manager\SandboxManagerBase::requirehas a local function in variable with name$do_stageshould that be renamed? Inside that function it has a variable$stage_dirthat refers to a sandbox, rename?\Drupal\package_manager\Validator\ComposerPatchesValidator::validatehas a number of local variables withstagein the name but that refer to sandboxes - rename? Same for\Drupal\package_manager\Validator\DuplicateInfoFileValidator::validate,\Drupal\package_manager\Validator\EnabledExtensionsValidator::validateand\Drupal\package_manager\Validator\LockFileValidator::validateabout another half-dozen validator classes in that namespace.\Drupal\package_manager_test_api\ApiController::createhas a local variable$stagethat refers to a sandbox manager.\Drupal\package_manager_test_api\ApiController::__construct(stage)should this property be renamed? It contains a SandboxManager now$stagein test code that refer to sandboxes.Comment #21
phenaproximaRenamed to
SandboxDatabaseUpdatesValidator, and its test-only version toTestSandboxDatabaseUpdatesValidator.Renamed to
SandboxDirectoryValidator, and changed the user-facing string.The rest of your comments seem to be about local variables and test code, which will be handled in
#3520506: Remove minor usages of "stage" from Package Manager's runtime code. Same goes for anything with private visibility, since none of those things are part of our API.
Comment #22
catchI had to double check these two:
Both of those are private, so could indeed be handled in #3520506: Remove minor usages of "stage" from Package Manager's runtime code. The rest are more obviously in scope for that issue.
The two new renames look good to me, so moving this back to RTBC.
Comment #23
larowlanCommitted to 11.x - thanks!
Comment #25
larowlanUsed some cli commands to knock up a rough change record https://www.drupal.org/node/3521441
Comment #28
xjm