Package Manager should keep an audit log of changes it applied to the active codebase

Created on 21 April 2023, over 1 year ago
Updated 15 June 2023, over 1 year ago

Problem/Motivation

@tedbow in Slack:

I had a thought regarding one of our discussions yesterday. Maybe we should add a package manager changes longer. It would log on post apply all the Drupal projects that had changed. It could also keep a record of what was asked for in require so that it could report on what were the housework changes and what Drupal projects were updated because of dependencies. Also dependencies that were added or removed

This would also definitely help a lot with 📌 Looking for Alpha tester for future functionality Active !

Steps to reproduce

N/A

Proposed resolution

  1. A new package_manager_audit_log logger channel
  2. A new subscriber that listens to PostRequireEvent to internally store which package changes were requested
    It is important that this is PostRequireEvent and not PreRequireEvent because in PreRequireEvent another validator may still stop the operation or composer stager might throw an error before the composer operation is actually made.

    More than 1 require call to \Drupal\package_manager\StageBase::require may be made during the stage life cycle

  3. That same method should also introspect each changed package to observe which Drupal extensions (modules/themes/profiles) are added/changed/removed
  4. That same subscriber should also listen to PostApplyEvent to observe what the actual changes are on the Drupal site. The reason is because there could be several require operations taking place in a stage, with certain things changed in each one; you'd have to go back through the logs and do a lot of mental grunt work to piece together the final picture of what was actually deployed. PostApplyEvent, on the other hand, has a complete picture of what happened right off the bat.

    In PostApplyEvent the subscriber should finally log all the changes in 1 log entry.

    something like

    Requested changes
    Updated drupal/webform 8.0.1 -> 8.5.3
    New drupal/other:10.0.1

    Changes to other Drupal packages:
    Remove drupal/webform_incompatible
    Added drupal/new_dependency:1.2.3
    Updated drupal/updated_dependency 1.1.1 -> 2.0.1

  5. 100% of build tests should be updated to use it — that means 5 classes should gain a ::assertPackageManagerAuditLog() all the way at the end.

Remaining tasks

  1. → use drush watchdog:list --type 👍

User interface changes

None.

API changes

StageBase's getMetadata() and setMetadata() methods will be public, since this is a very clear case where it makes sense to attach persistent metadata to a particular stage, and it makes the code simpler.

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.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024