Problem/Motivation

While reviewing #3355628: Package Manager should keep an audit log of changes it applied to the active codebase, I realized that our validators today assume that all phases of the stage life cycle occur within the same PHP process. For most, that’s fine, because they don’t store state. They don't, but the new one being written at #3355628 does!

But for any validator that stores state during an earlier event to use that during a later event, that’s going to be a problem as soon as #3357969: For web server dependent unattended updates run the entire life cycle in a separate process that will not be affected by hosting time limits lands. And in fact … it’s already a problem when installing updates by hand, because \Drupal\automatic_updates_extensions\Form\UpdateReady::submitForm() already puts different phases of the stage life cycle in different (batch operation) requests!

I see that LockFileValidator and StagedDatabaseUpdateValidator specifically take care of that. And they're the only ones that store state between operations 👍

But this is something we should document in package_manager.api.php as a gotcha.

Steps to reproduce

N/A

Proposed resolution

Documentation!

Remaining tasks

None.

User interface changes

None.

API changes

Data model changes

Command icon 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:

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Active » Needs review
Issue tags: +sprint
phenaproxima’s picture

I wonder if we should make StageBase::setMetadata() and getMetadata() public, and use them for this purpose.

These two methods are specifically meant to store arbitrary metadata associated with a particular (claimed) stage. They store it safely in key-value; it's automatically cleaned up at the end of the stage's life.

tedbow’s picture

Issue tags: +core-post-mvp
wim leers’s picture

#4: I wondered the same! 😊 Perhaps we can prefix key-value pairs set by this public function setMetadata() with "external-" and add a new private function setInternalMetadata() with "internal-"?

tedbow’s picture

Status: Needs review » Closed (outdated)

We now have \Drupal\package_manager\StageBase::setMetadata see #3371212: LockFileValidator should store the lock file hash in the stage's metadata, rather than directly in state. So I think we can close this