#6545 closed change (fixed)

[CMS] get_pages_metadata should not ignore pages with no explicit metadata

Reported by: kvas Assignee: jsonesen
Priority: P3 Milestone:
Module: Sitescripts Keywords:
Cc: juliandoucette, jsonesen, sebastian Blocked By: #6605
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

https://codereview.adblockplus.org/29753617/

Description

Environment

CMS in static or dynamic mode.

How to reproduce

  1. Create a page A that doesn't declare any metadata.
  2. Create page B that uses get_pages_metadata global function to get the list of all pages and then outputs the list.

Observed behaviour

Page A is not in the list on page B.

Expected behaviour

Page A should be in the list.

References

Change History (13)

comment:1 Changed 21 months ago by kvas

@julian: in the original review, I understand your comment as that pages with no metadata should be present in the output of get_pages_metadata if no filters are given. Could you please confirm that this is still your preferences and that this change will not cause unintended side-effects in our existing websites that use get_pages_metadata? Thank you.

comment:2 Changed 21 months ago by juliandoucette

@kvas I don't know what comment you are referring to. And I can't imagine wanting to use get_pages_metadata to retrieve a page with no meta data. e.g. In order to link to a page, I probably want a title or something for the link text.

I guess an intelligent default title could be the page name un-slugified and without the file extension. But I didn't request that.

Last edited 21 months ago by juliandoucette (previous) (diff)

comment:3 Changed 21 months ago by kvas

  • Resolution set to rejected
  • Status changed from new to closed

@julian: It's your reply to my comment asking whether pages with no user-defined metadata should be filtered out or not. I understood it as you saying that the pages with no user-defined metadata should still be in the output, but I guess this is wrong.

This issue is rejected then.

comment:4 Changed 21 months ago by kvas

  • Component changed from Unknown to Sitescripts
  • Priority changed from Unknown to P3
  • Ready set
  • Resolution rejected deleted
  • Status changed from closed to reopened

I had a chat with @julian today and we've concluded that this ticket should be implemented even though the original request didn't go into these details:

6:38 PM <vasily> sorry to bug you about this again, but I think it would be useful to know how strong you feel about the choice in https://issues.adblockplus.org/ticket/6545. As I understand, the intention behind your initial request was that only pages with some user-defined metadata would be in the output of get_pages_metadata but how would you feel about all pages being there (you can filter them with explicit filters of course)?
6:38 PM <vasily> I'm asking because to me it seems that the a page appearing in the output after, for example, changing its template seems rather counterintuitive and potentially error-prone, so my preference would be to always include all pages that match filters (if any). But if you prefer it to stay the way it is, I would view it as a strong argument against changing things.
6:45 PM <julian> I agree with your preference.

Based on this I'm reopening this ticket.

comment:5 Changed 21 months ago by kvas

  • Type changed from defect to change

Since the original request didn't specify the behavior that we want to achieve here, this ticket is not a defect but a change. I will keep the main text unchanged for simplicity.

comment:6 Changed 20 months ago by jsonesen

  • Owner set to jsonesen

comment:7 Changed 20 months ago by sebastian

How wabout removing the filter functionality all together from get_pages_metadata()? There is much more powerful filter functionality already built into jinja.

Pages that have a given metadata key with a particular value:

get_pages_metadata()|selectattr('category', 'equalto', 'popular')

Pages that have a given metadata key with any of some values:

get_pages_metadata()|selectattr('category', 'in', ['popular', 'misc'])

Pages that have a given metadata key with any non-empty value (this isn't even supported by the current filter functionality get_pages_metadata() provides):

get_pages_metadata()|selectattr('title')

I prepared a patch to demonstrate how that would look like for help.eyeo.com. Its somewhat more verbose, but also more flexible, and it would make a bunch of code in the CMS obsolete.

What do you think, Julian?

Last edited 20 months ago by sebastian (previous) (diff)

comment:8 Changed 20 months ago by sebastian

  • Cc sebastian added

comment:9 Changed 20 months ago by jsonesen

  • Review URL(s) modified (diff)

comment:10 Changed 20 months ago by jsonesen

  • Status changed from reopened to reviewing

comment:11 Changed 20 months ago by kvas

  • Blocked By 6605 added

comment:12 Changed 19 months ago by abpbot

A commit referencing this issue has landed:
Issue 6545 - Changes get_pages_metadata to return all pages

comment:13 Changed 19 months ago by jsonesen

  • Resolution set to fixed
  • Status changed from reviewing to closed
Note: See TracTickets for help on using tickets.