You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 946eaf0
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ Every change that reaches `main` adds a line under **Unreleased**. When a versio
5
5
## Unreleased
6
6
7
7
### Breaking
8
+
- `GET {component}/usage` is `ROLE_ADMIN` only: anonymous callers get 401 and other users 403, where anyone who could read the component used to get the counts ([#539](https://github.com/components-web-app/api-components-bundle/pull/539))
8
9
- A `route_security` `route` pattern matches the whole path, with `*` as its only wildcard, in `RouteVoter` and the route list alike: a pattern without a leading `*` no longer matches mid-path (add one to keep the old behaviour, e.g. `*/user-area*`), `%` and `_` are literal in the list too, and ASCII letters match regardless of case ([#538](https://github.com/components-web-app/api-components-bundle/pull/538))
Copy file name to clipboardExpand all lines: CLAUDE.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -319,7 +319,7 @@ Resources are fetched and cached **individually**. Never embed related data outs
319
319
- `ComponentPosition.component` is `ON DELETE SET NULL`, deliberately, so dynamic positions survive their fallback. Static positions are removed by `ComponentPositionRemovalStateProcessor` on an API delete only.
320
320
- **Nothing stores a reference to a draft that has a published version; a never-published draft is stored as it is** (#520). Publishing a draft of a published component deletes its row, so a reference to it would be emptied by `ON DELETE SET NULL` (or lose its join rows); a never-published draft's first publish keeps the row, so a reference to it becomes live in place. `EventListener\Doctrine\DraftComponentReferenceListener` is the one place this is enforced, on `onFlush` (priority 100, before `PropagateUpdatesListener`), so the API in both modes, fixtures, CLI and direct Doctrine writes all agree, and validation (which judges the class, the cycle detector counting the pair as one) sees the draft unchanged. **Single-join-column associations:** on every inserted entity of any class, and every updated one whose association changed, an owning single-join-column association to an `AbstractComponent` (a position's `component`, a page data component property, a component field such as `related`, an application entity's) holding a draft of a published component is re-pointed at the published component and the change set recomputed. A publishable class's own `associationName` is never re-pointed. **Group owners:** for every scheduled update of a component's `componentGroups`, each group in the insert diff of a draft of a published component that the published component does not already own is moved to the published component (removed from the draft, added to the published component, `computeChangeSet()` on it, the group's `components` updated only when that collection is already dirty, so a clean one is never scheduled). A group the published component owns stays co-owned by the draft: `createDraft()` clones the collection, and that co-ownership is what the admin's draft view reads. So a group is never owned only by a draft of a published component, and naming a draft as the owner resolves exactly as naming its published component. **Watch:** an admin's IRI for a published component that has a draft can resolve to the draft on denormalization, so the module's own published IRI reaches the bundle as the draft; that is the case this listener exists for. The inverse `componentPositions` collections are not maintained.
321
321
- **Publishing a draft gives the published component the union of both components' groups** (#520). `PublishableDraftMerger::mergeDraftIntoPublished()` copies properties by reflection on the published class, which never sees a parent's private property, so `AbstractComponent::$componentGroups` is not copied; it is merged explicitly with `addComponentGroup()` for each of the draft's groups. Never replace the published collection with the draft's: a group the published component gained after the draft was made would lose its only owner when the draft row is deleted.
322
-
- **`GET {component}/usage` lists `locations` only for `ROLE_ADMIN`** (#531, `ComponentUsageMetadataFactory::createWithLocations()`); everyone who may read the component still gets the counts from `create()`, and the key is absent for them. The operation is `private, no-store` for every caller (`cacheHeaders` on the operation), because nothing purges it when a placement changes. **The counts are the definition of a use**: one location per counted position (a dynamic position whose fallback is the component included, flagged by `pageDataProperty`) and per page data property, from the same `findByComponent()` rows and `findPageDataComponentMetadata()` matches the counts come from, so the two can never disagree. Never compute the list from a second lookup.
322
+
- **`GET {component}/usage` is `ROLE_ADMIN` only** (#531, the operation's `security`, like the orphan report and purge endpoints): anonymous is the firewall's 401, any other user 403, a draft included, before any lookup. It always returns the counts with `locations` (`ComponentUsageMetadataFactory::createWithLocations()`); `create()`, counts only, is for the delete cascade (`OrphanedResourceHelper`). The operation is `private, no-store` (`cacheHeaders` on the operation), because nothing purges it when a placement changes. **The counts are the definition of a use**: one location per counted position (a dynamic position whose fallback is the component included, flagged by `pageDataProperty`) and per page data property, from the same `findByComponent()` rows and `findPageDataComponentMetadata()` matches the counts come from, so the two can never disagree. Never compute the list from a second lookup.
323
323
- **`Helper\ComponentUsage\ComponentUsageLocator` answers `renderedOn` in a fixed number of queries, whatever the depth**: it loads the component-owned subgraph as ids (group owners with each draft's published id, positions holding a group owner or a group-owning draft's published component), walks it in PHP with `ComponentUsageGraph` (visited set, a draft owner climbing through its published component), then fetches page owners, layout owners, template page data and page data holding a reached component with one `IN` list each, sized by the answer. Add a step to the walk as data in the graph, never as a query per level. `ComponentUsageLocations` is the one place for order and caps (layouts first by reference, then routed by path, then unrouted by title, untitled last; 50 locations, 20 `renderedOn`, counts exact).
324
324
- **A list inside a DTO that is not an API resource is normalized as a Hydra `Collection`** unless its property carries `#[Context(normalizationContext: ['api_sub_level' => true])]`, as `ComponentUsageMetadata::$locations` does.
325
325
- **A component matches a page data property by class hierarchy, never by short name** (#345). `PageDataMetadata::findPropertiesByComponentClass()` uses `is_a()` against the property's Doctrine target, so a property typed `AbstractComponent` or a parent component class holds any subclass. `PageDataProvider::findPageDataComponentMetadata()` is the one lookup behind usage counts (`/usage` and the cascade on delete), `ComponentVoter`'s page data reachability and `PropagateUpdatesListener`'s purge and Mercure fan-out, so a component held only by such a property is used, public only when the page data is on a live route, and propagates to the page data on edit.
0 commit comments