Skip to content

Conversation

@adam-vessey
Copy link
Contributor

@adam-vessey adam-vessey commented Oct 23, 2025

Builds on/contains #34

Summary by CodeRabbit

  • Chores

    • Updated Drupal core requirement from versions 9–10 to versions 10–11
    • Established Drush 13+ as minimum required version
  • Refactor

    • Enhanced batch processing with improved context management and tracking
    • Optimized query operations to ensure comprehensive item processing regardless of access restrictions
    • Improved logging infrastructure

Drush 13 introduced assertions, expecting the use of a "logger manager".

See: drush-ops/drush#5022
Was this command ever used? The missing `$context` seems to suggest no?
@adam-vessey adam-vessey added the patch Backwards compatible bug fixes. label Oct 23, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 23, 2025

Walkthrough

This PR updates islandora_drush_utils to support Drupal 10 and 11, enforces Drush 13+ compatibility, refactors logger registration in two Drush command classes using conditional/lazy initialization, and extends batch processing in PublishUnpublishCollectionsDrushCommands with context tracking and access-control-disabled queries.

Changes

Cohort / File(s) Change Summary
Version & Dependency Constraints
composer.json, islandora_drush_utils.info.yml
Added "conflict" section constraining drush/drush to version 13+. Updated core_version_requirement from ^9 || ^10 to ^10 || ^11, dropping Drupal 9 support and adding Drupal 11 compatibility.
Logger Initialization Refactor
src/Drush/Commands/Sec873DrushCommands.php, src/Drush/Commands/PublishUnpublishCollectionsDrushCommands.php
Replaced direct logger assignment (setLogger($logger) / $this->logger = $logger) with conditional/lazy logger handler registration using logger()?->add(...) pattern in constructors.
Batch Context & Access Control
src/Drush/Commands/PublishUnpublishCollectionsDrushCommands.php
Added array &$context parameter to updateStatusBatch() method for batch progress tracking. Appended ->accessCheck(FALSE) to node and media queries to bypass access control restrictions during batch operations.

Sequence Diagram

sequenceDiagram
    participant Batch as Batch API
    participant updateStatusBatch as updateStatusBatch()
    participant Query as Query Handler
    participant Node/Media as Node/Media<br/>Entities

    rect rgb(200, 220, 255)
    Note over Batch,Node/Media: New: Context-aware Batch Processing
    end
    
    Batch->>updateStatusBatch: Invoke with &$context
    updateStatusBatch->>updateStatusBatch: Track progress in $context<br/>(total, completed, finished)
    updateStatusBatch->>Query: Build query with accessCheck(FALSE)
    Query->>Node/Media: Fetch all items<br/>(ignoring access control)
    Node/Media-->>Query: Return entities
    Query-->>updateStatusBatch: Results
    updateStatusBatch->>updateStatusBatch: Update batch status<br/>in $context
    updateStatusBatch-->>Batch: Continue/finish
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Batch context tracking logic: Verify that $context state variables (total, completed, finished) are correctly initialized, updated, and used to control batch iteration flow.
  • Access control bypass implications: Ensure accessCheck(FALSE) is intentionally applied and doesn't inadvertently expose unauthorized content in edge cases.
  • Logger initialization pattern: Confirm the conditional logger()?->add(...) pattern works correctly across both command classes and doesn't break logging in edge conditions (e.g., when logger service is unavailable).

Possibly related PRs

  • [UI-385] rename file/class so Drush can find it #36: Directly impacts PublishUnpublishCollectionsDrushCommands.php — the retrieved PR involved class restructuring while this PR refactors logger wiring, batch context, and query access control in the same file.

Poem

🐰 A drush of change hops through the code,
Nine's farewell, ten and eleven load,
Batch by batch, context tracks the way,
Access unlocked for a brighter day!
Logger whispers now, lazy and wise,
Update complete, as drush 13 flies!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Bump core version" accurately describes a real and significant aspect of the changeset—specifically, the update to the core_version_requirement in islandora_drush_utils.info.yml from ^9 || ^10 to ^10 || ^11. The title is concise, clear, and not misleading. However, the PR contains additional substantial changes beyond the version bump, including logger initialization refactoring in multiple drush command files, batch processing context handling with access control bypasses, and a new drush version conflict declaration in composer.json. The title captures the core version update but does not encompass the full scope of the changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update/d11

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command never seems to have been used? The missing $context should've made rather a mess, and the missing accessCheck() invocations seem to suggest that this was never called in D10?

Could just drop this command/file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it was written back in 2023 and was a one time use command that the team deemed as potentially useful for the future. I'm indifferent on leaving it in

@adam-vessey adam-vessey marked this pull request as ready for review October 28, 2025 15:18
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/Drush/Commands/PublishUnpublishCollectionsDrushCommands.php (1)

184-188: Use PSR-3 logging for exceptions at line 185

LoggerInterface has no exception() method. Change to error():

-        $this->logger->exception('Encountered an exception: {exception}', [
-          'exception' => $e,
-        ]);
+        $this->logger->error('Encountered an exception during batch processing', [
+          'exception' => $e,
+          'message' => $e->getMessage(),
+        ]);
🧹 Nitpick comments (3)
src/Drush/Commands/Sec873DrushCommands.php (1)

67-67: Logger wiring: add a safe fallback to keep $this->logger usable

Guard aggregator usage and fall back to setLogger to ensure property logging continues to work.

-    $this->logger()?->add('islandora_drush_utils.sec_873', $logger);
+    if (method_exists($this, 'logger') && ($agg = $this->logger())) {
+      $agg->add('islandora_drush_utils.sec_873', $logger);
+    }
+    else {
+      // Ensure PSR-3 logger remains available on $this->logger.
+      $this->setLogger($logger);
+    }

Please confirm WrappedCommandVerbosityTrait provides logger()->add(...) and that $this->logger is a PSR-3 logger throughout this class.

src/Drush/Commands/PublishUnpublishCollectionsDrushCommands.php (2)

51-51: Logger wiring: apply the same safe fallback pattern

Mirror the guarded fallback to preserve $this->logger if aggregator/helper is unavailable.

-    $this->logger()?->add('islandora_drush_utils', $logger);
+    if (method_exists($this, 'logger') && ($agg = $this->logger())) {
+      $agg->add('islandora_drush_utils', $logger);
+    }
+    else {
+      $this->setLogger($logger);
+    }

105-105: Bypassing access checks: confirm intent and run context

Using ->accessCheck(FALSE) ensures full coverage in CLI; confirm this is intended and only used by privileged operators. Consider a brief code comment to document intent.

Also applies to: 158-158

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 19ed506 and 5e96ba6.

📒 Files selected for processing (4)
  • composer.json (1 hunks)
  • islandora_drush_utils.info.yml (1 hunks)
  • src/Drush/Commands/PublishUnpublishCollectionsDrushCommands.php (3 hunks)
  • src/Drush/Commands/Sec873DrushCommands.php (1 hunks)
🔇 Additional comments (4)
islandora_drush_utils.info.yml (1)

5-5: Core requirement bump looks good

Compatibility updated to Drupal ^10 || ^11. No issues.

src/Drush/Commands/PublishUnpublishCollectionsDrushCommands.php (2)

100-104: Batch API: adding &$context is correct

Signature and doc update fix prior batch breakage. Good change.


374-375: Review comment references incorrect file and suggests invalid fix

The review cites PublishUnpublishCollectionsDrushCommands.php at lines 374-375, but the env var ISLANDORA_DRUSH_UTILS_SEC_783__DRY_RUN is actually in Sec873DrushCommands.php:374. More critically, the suggested fix to change SEC_783 to SEC_873 is unfounded—SEC_873 does not exist anywhere in the codebase. The current code consistently uses SEC_783 in both the setter (Sec873DrushCommands.php:374) and getter (Sec873.php:66), indicating this is intentional, not a typo.

Likely an incorrect or invalid review comment.

composer.json (1)

18-20: Review comment is based on incorrect constraint analysis

The verification reveals the review comment's core findings are incorrect:

  1. "drush.10.services.yml is unreachable" — False. The constraint ^10 || ^11 makes it reachable for Drush 10.x and 11.0–11.5. It's only unreachable for Drush 12.x+.

  2. ">=11.6 also matches 13, so Drush 13 may load" — False. The conflict directive prevents Drush 13 from installing at all; no version resolution occurs for 13.x.

  3. Actual issue: For Drush 11.6–11.x, both drush.11.6-12.5.yml and drush.10.services.yml load simultaneously, creating a genuine overlap. The problem is not an unreachable file, but overlapping service definitions at a specific version range.

The recommendation to add <13 to the >=11.6 constraint is redundant (the top-level conflict already enforces this). If overlap at 11.6–11.x is a concern, the real fix is to constrain drush.10.services.yml to exclude 11.6+, not to remove it entirely.

Likely an incorrect or invalid review comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it was written back in 2023 and was a one time use command that the team deemed as potentially useful for the future. I'm indifferent on leaving it in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Backwards compatible bug fixes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants