Files
Umbraco-CMS/thoughts/shared/handoffs/general/2025-12-20_06-05-38_contentservice-phase0-critical-review.md
yv01p 9962df50ee feat(core): register IContentCrudService in DI container
Adds IContentCrudService registration to UmbracoBuilder alongside
IContentService. Both services are now resolvable from DI.

Includes integration test verifying successful resolution.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-21 03:31:23 +00:00

115 lines
6.1 KiB
Markdown

---
date: 2025-12-20T06:05:38+00:00
researcher: Claude
git_commit: bf054e9d6268b0ea26dda4fab3e32e3bb59c958b
branch: refactor/ContentService
repository: Umbraco-CMS
topic: "ContentService Phase 0 Implementation Plan Critical Review"
tags: [implementation, critical-review, contentservice, refactoring, testing]
status: in_progress
last_updated: 2025-12-20
last_updated_by: Claude
type: implementation_strategy
---
# Handoff: ContentService Phase 0 Implementation Plan Critical Review
## Task(s)
| Task | Status |
|------|--------|
| Critical implementation review of Phase 0 plan | Completed |
| Verify API signatures (Publish, GetContentSchedulesByIds) | Completed |
| Verify DeleteOfType descendant handling behavior | Completed |
| Verify IScopeProvider rollback semantics | Completed |
| Identify duplicate tests in existing test files | Completed |
| Apply fixes 1,2,4,5,6,7,8,9 to the plan | In Progress (interrupted) |
| Answer user question about CI/Phase Gate Enforcement | Completed |
**Working from:** `docs/plans/2025-12-20-contentservice-refactor-phase0-implementation.md`
## Critical References
1. `docs/plans/2025-12-20-contentservice-refactor-phase0-implementation.md` - The Phase 0 implementation plan being reviewed
2. `docs/plans/2025-12-19-contentservice-refactor-design.md` - The parent design document
3. `build/azure-pipelines.yml` - CI pipeline configuration
## Recent changes
No code changes were made - this was a review session preparing to apply fixes.
## Learnings
### API Signatures Verified
- `Publish(IContent content, string[] cultures, int userId)` - Plan uses `new[] { "*" }` correctly
- `GetContentSchedulesByIds(Guid[] keys)` - Plan uses `keys.ToArray()` correctly (Guid[], not int[])
- `EntityPermissionCollection(IEnumerable<EntityPermission> collection)` - Constructor exists as expected
### DeleteOfType Behavior (src/Umbraco.Core/Services/ContentService.cs:3498-3584)
- Queries all content of specified type(s)
- Orders by ParentId descending (deepest first)
- For each item: moves ALL children to recycle bin (regardless of type), then deletes the item
- Test 6 in plan is **correct** - descendants of different types go to bin, same type deleted
### IScopeProvider Rollback Semantics (src/Umbraco.Infrastructure/Scoping/IScopeProvider.cs)
- `CreateScope()` returns `IScope` with `autoComplete = false` by default
- If `scope.Complete()` is NOT called, transaction rolls back on dispose
- Base test class exposes `ScopeProvider` property - no extra using needed for `Umbraco.Cms.Infrastructure.Scoping`
### CI Pipeline Configuration
- **Platform:** Azure Pipelines
- **Test filters for non-release builds:** `--filter TestCategory!=LongRunning&TestCategory!=NonCritical`
- **LongRunning tests (benchmarks) are SKIPPED on normal PRs** - only run on release builds
- Integration tests split into 3 shards by namespace:
- Part 1: `Umbraco.Infrastructure` (excluding Service)
- Part 2: `Umbraco.Infrastructure.Service` (where new tests will live)
- Part 3: Everything else
### Duplicate Test Analysis
No true duplicates found. Existing tests focus on different aspects:
- `ContentEventsTests.cs:802-868` - Sort tests focus on cache refresh events, not notification order
- `ContentServiceTests.cs:1862` - MoveToRecycleBin tests basic functionality, not notification sequence
- `ContentServiceTests.cs:1832` - DeleteOfType exists but doesn't test descendant type handling
## Artifacts
- `docs/plans/2025-12-20-contentservice-refactor-phase0-implementation.md` - Plan to be updated
- `tests/Umbraco.Tests.Integration/Testing/ContentServiceBenchmarkBase.cs` - Already exists (referenced in plan)
## Action Items & Next Steps
### Fixes to Apply to the Plan (User requested 1,2,4,5,6,7,8,9)
1. **[1] API Signatures** - Verified correct, add confirmation note to plan
2. **[2] Remove incorrect using directive** - Task 6 instructs adding `using Umbraco.Cms.Infrastructure.Scoping;` but this is wrong. `ScopeProvider` is already available via base class. Remove this instruction.
3. **[4] Add [NonParallelizable]** - Add `[NonParallelizable]` attribute to `ContentServiceRefactoringTests` class (Task 1 skeleton, line 43-48)
4. **[5] DeleteOfType verified** - Add note confirming behavior is correct
5. **[6] Add benchmark warmup** - Update `MeasureAndRecord` in `ContentServiceBenchmarkBase.cs` to include warmup iteration
6. **[7] Explicit scope creation** - Add note about rollback semantics (verified working as expected)
7. **[8] Add null-checks for template** - Change `FileService.GetTemplate("defaultTemplate")!` to include explicit assertion
8. **[9] Portable JSON extraction** - Replace grep -oP with portable Python script or simpler extraction in Task 10
### Additional Items to Add
- Add note about duplicate test analysis (none found)
- Add note about CI behavior - benchmarks skip on PR builds due to `[LongRunning]` category
- Consider if Phase Gate should run locally before PR or if CI coverage is sufficient
## Other Notes
### Key File Locations
- **ContentService implementation:** `src/Umbraco.Core/Services/ContentService.cs` (~3800 lines)
- **IContentService interface:** `src/Umbraco.Core/Services/IContentService.cs`
- **IScopeProvider:** `src/Umbraco.Infrastructure/Scoping/IScopeProvider.cs`
- **Existing ContentService tests:** `tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ContentServiceTests.cs`
- **ContentEventsTests (sort tests):** `tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentEventsTests.cs`
- **ScopeTests:** `tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Scoping/ScopeTests.cs`
- **LongRunning attribute:** `tests/Umbraco.Tests.Common/Attributes/LongRunning.cs`
### CI Phase Gate Question (User Asked)
The CI runs ALL integration tests, not just ContentService tests. Tests are split by namespace for parallelization. The new tests will run in "Part 2 of 3" (Umbraco.Infrastructure.Service namespace).
**Important:** Benchmarks marked `[LongRunning]` will be **skipped on PR builds** and only run on release builds. This means:
- The 15 integration tests WILL run on every PR
- The 33 benchmarks will NOT run on PRs (only on releases)
- For local Phase Gate verification, run: `dotnet test --filter "FullyQualifiedName~ContentServiceRefactoring"`