Bug #13131

IO and actor browse pages are broken when markdown support is disabled and more that one filter is applied

Added by José Raddaoui Marín 3 months ago. Updated 2 months ago.

Status:VerifiedStart date:08/01/2019
Priority:MediumDue date:
Assignee:-% Done:

0%

Category:Formatting
Target version:Release 2.5.2
Google Code Legacy ID: Tested version:2.5, 2.6
Sponsored:No Requires documentation:

Description

To reproduce:

- Disable Markdown support.
- Go to archival descriptions (IO) browse page.
- Check that the "Only top-level descriptions" filter is applied.
- Click on "Show results with digital objects" or a facet option.

To fix:

When Markdown is disabled, the escaping strategy from Symfony changes how the data should be accessed in some cases in the templates. An explanation provided to the AtoM team a while ago:

First, about Symfony escaping strategy and Parsedown:

The escaping strategy is enabled by default but escaped data is a problem when it's pared by Parsedown, which has a safe mode that takes care of it while parsing the Markdown. The Markdown support can be enabled/disabled via setting so, when it's disabled, we still need the escaping strategy from Symfony.

Therefore, we may find the data escaped or not in the templates. This means that objects can be an instance of what you're expecting or an instance of `sfOutputEscaperObjectDecorator` and arrays can be instances of `sfOutputEscaperArrayDecorator` instead of real arrays.

For `sfOutputEscaperArrayDecorator` and arrays, use allways the `[]` annotation to access the data, as it works in both types unlike `->get()`, which only works in `sfOutputEscaperArrayDecorator`.

For `sfOutputEscaperObjectDecorator` and objects, never use the `->getRaw()` or `->getRawValue()` methods as it will only work in the decorator, if you need the raw value of `$object` in a template, use `$sf_data->getRaw('object')` instead, which doesn't cause an error when executed over not escaped objects/arrays.

Also, `sfOutputEscaper::unescape()` can be used in the same maner to unescape and object/array but, please notice that the escape happens while the view is built so, to do this kind of operations it's better if you do it in the controller (as always).

In this commit you can see some of the fixes I had to do after this changes.

https://github.com/artefactual/atom/pull/698/commits/0c5efc6391423b263b58549f6c9e9a039146f387

Second, the importance of using the render methods:

The Markdown parsing process is made in QubitMarkdown, an instantiable class that uses ParsedownExtra to process the data. This class > is used in the following render methods from QubitHelper:

- render_value: uses Parsedown text method in safe mode (adds paragraphs).
- render_value_inline: uses Parsedown line method in safe mode.
- render_value_html: uses Parsedown text method in unsafe mode (for HTML).
- render_title: returns 'Untitled' if render_value_inline returns and empty string.
- strip_markdown: removes Markdown and HTML tags.

History

#1 Updated by José Raddaoui Marín 2 months ago

  • Status changed from New to Code Review
  • Assignee changed from José Raddaoui Marín to Mike Cantelon

#2 Updated by Mike Cantelon 2 months ago

  • Status changed from Code Review to Feedback
  • Assignee changed from Mike Cantelon to José Raddaoui Marín

Hi Radda... PR looks good to me!

#3 Updated by José Raddaoui Marín 2 months ago

  • Status changed from Feedback to QA/Review
  • Assignee changed from José Raddaoui Marín to Dan Gillean

Thanks Mike! Merged in qa/2.6.x.

#4 Updated by Dan Gillean 2 months ago

  • Status changed from QA/Review to Feedback
  • Assignee changed from Dan Gillean to José Raddaoui Marín

Seems to be working as expected in qa/2.6.x - let's backport!

#5 Updated by José Raddaoui Marín 2 months ago

  • Status changed from Feedback to QA/Review
  • Assignee changed from José Raddaoui Marín to Dan Gillean

Cherry-picked to stable/2.5.x.

#6 Updated by Dan Gillean 2 months ago

  • Status changed from QA/Review to Verified
  • Assignee deleted (Dan Gillean)

Also available in: Atom PDF