apostrophe 4.4.0 → 4.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.4.2 (2024-06-14)
4
+
5
+ ### Fixes
6
+
7
+ * Hotfix: the new `_parent` property of pieces, which refers to the same piece page as `_parentUrl`, is now a carefully pruned
8
+ subset to avoid the risk of infinite recursion when the piece page has a relationship to a piece. Those who want `_parent`
9
+ to be more complete can extend the new `pruneParent` method of the relevant piece page module. This regression was
10
+ introduced in version 4.4.0.
11
+
12
+ ## 4.4.1 (2024-06-12)
13
+
14
+ ### Fixes
15
+
16
+ * Depend on `stylelint-config-apostrophe` properly via npm, not github.
17
+
3
18
  ## 4.4.0 (2024-06-12)
4
19
 
5
20
  ### Adds
@@ -250,13 +250,36 @@ module.exports = {
250
250
  const parentPage = self.chooseParentPage(req.aposParentPageCache[pieceName], piece);
251
251
  if (parentPage) {
252
252
  piece._url = self.buildUrl(req, parentPage, piece);
253
- piece._parent = parentPage;
253
+ piece._parent = self.pruneParent(parentPage);
254
254
  piece._parentUrl = parentPage._url;
255
255
  piece._parentSlug = parentPage.slug;
256
256
  }
257
257
  });
258
258
  },
259
259
 
260
+ // The _parent property of a piece is useful for
261
+ // breadcrumb navigation but we don't want it to lead
262
+ // to runaway recursion etc., so make a shallow clone
263
+ // of relevant properties only. Use extendMethods
264
+ // if you want to return more (or less)
265
+ pruneParent(parent) {
266
+ return {
267
+ _id: parent._id,
268
+ aposDocId: parent.aposDocId,
269
+ aposLocale: parent.aposLocale,
270
+ aposMode: parent.aposMode,
271
+ path: parent.path,
272
+ level: parent.level,
273
+ type: parent.type,
274
+ title: parent.title,
275
+ slug: parent.slug,
276
+ // These are already pruned projections and
277
+ // necessary for various types of navigation
278
+ _ancestors: parent._ancestors,
279
+ _children: parent._children
280
+ };
281
+ },
282
+
260
283
  // Returns a query suitable for finding pieces-page-type for the
261
284
  // purposes of assigning URLs to pieces based on the best match.
262
285
  //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apostrophe",
3
- "version": "4.4.0",
3
+ "version": "4.4.2",
4
4
  "description": "The Apostrophe Content Management System.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -140,7 +140,7 @@
140
140
  "nyc": "^15.1.0",
141
141
  "replace-in-file": "^6.1.0",
142
142
  "stylelint": "^16.5.0",
143
- "stylelint-config-apostrophe": "github:apostrophecms/stylelint-config-apostrophe",
143
+ "stylelint-config-apostrophe": "4.1.0",
144
144
  "vue-eslint-parser": "^7.1.1",
145
145
  "vue-template-compiler": "^2.7.14"
146
146
  },
package/test/search.js CHANGED
@@ -75,6 +75,8 @@ describe('Search', function() {
75
75
  it('should carry the _ancestors property', async function() {
76
76
  const response1 = await apos.http.get('/search?q=event');
77
77
  const [ piece ] = JSON.parse(response1);
78
+ assert(piece._parent.title === 'Events');
79
+ assert(piece._parent.type === 'event-page');
78
80
  assert(piece._parent.slug === '/events');
79
81
  assert(piece._parent._ancestors[0].slug === '/');
80
82
  assert(piece._parent._ancestors[0]._ancestors.length === 0);