Problem/Motivation

@alexpott:

We shouldn't update masterminds/html5 or jcalderonzumba/* - the PhantomJS stuff because it is very fickle with versions and basically unsupported at this point. The html5 library has proved tricky because of the amp project and it's library. See #3040037: Update masterminds/html5 to 2.7.5 for more.

@alexpott:

I’ve just realised something about masterminds/html5 and Drupal 9 - that I think we want to fix prior to RC

  1. It’s a dev only dependency but it is listed in the main deps
  2. Our d9 composer updates have updated it to a version that require a new PHP extension - ctype
  3. Funnily enough we have a polyfill for the extension so nothing is broken if you don’t have the ctype extension - there’s symfony/polyfill-ctype

Proposed resolution

@alexpott:

I think we should move it to a dev dependency and then I’d argue this does not matter

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

The masterminds/html5 is no longer a runtime dependency of Drupal and will not be included in tagged releases. Contributed or custom modules using this package need to add the dependency to their composer.json.

Comments

jungle created an issue. See original summary.

alexpott’s picture

I think minimising Drupal 9's production dependencies at the start of the life cycle is important. It'll make dependency management throughout the cycle simpler because there are less important dependencies.

jungle’s picture

Status: Active » Needs review
StatusFileSize
new5.09 KB
new8.84 KB
new8.84 KB

Moved it to require-dev

+--------------------+-------+---------+---------+
| Production Changes | From  | To      | Compare |
+--------------------+-------+---------+---------+
| masterminds/html5  | 2.7.0 | REMOVED |         |
+--------------------+-------+---------+---------+

+-------------------+------+-------+---------+
| Dev Changes       | From | To    | Compare |
+-------------------+------+-------+---------+
| masterminds/html5 | NEW  | 2.7.0 |         |
+-------------------+------+-------+---------+
$ diff ~/3133749-9.0.x-2.patch ~/3133749-9.1.x-2.patch
14c14
< index e5500f9215..84a545c0bc 100644
---
> index cb85615174..362a23c624 100644
202c202
< index b7d960d8bb..a2ce19fb82 100644
---
> index 2559d5b36d..cc3b44293c 100644
226c226
< index 9cc92cc743..3c5d39703a 100644
---
> index 5e3f29555b..3aa52fd6ed 100644

From the diff, one patch is enough.

jungle’s picture

A redundant patch unloaded, sorry.

3133749-9.1.x-2.patch or 3133749-9.0.x-2.patch is for review. Ignore 3133749-2.patch please.

alexpott’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: +9.0.0 release notes
+++ b/composer.lock
@@ -4021,9 +3953,6 @@
-            "bin": [
-                "bin/composer"
-            ],

:D

This looks great.

alexpott’s picture

I guess we need to consider contrib at this point - http://codcontrib.hank.vps-private.net/search?text=Masterminds&filename=

What's really really interesting is that cases where Masterminds\HTML5\Exception all appear to be errors!!! I guess this might be the first thing some IDEs suggest for the Exception class :(

alexpott’s picture

I created the change record and added the release note.

jungle’s picture

Re #5, see it next time 👋 😄

catch’s picture

With backporting this I'm a bit concerned about all those uses of Masterminds\HTML5\Exception

Won't they get class not found?

But also now presumably that exception is not being caught at all because it's the wrong one.

catch’s picture

Title: masterminds/html5 and Drupal 9 » Deprecate masterminds/html5 as a production dependency for Drupal 10
Status: Reviewed & tested by the community » Needs work

So if there were no usages, I would say definitely get this into 9.0.x, but since there are it's a bit weird. I think what will happen is instead of getting an uncaught exception (because code is trying to catch the wrong one), it would change to a fatal class not found. Discussed with @xjm and we both think it's too close to RC to change this now, also with a lot of modules theoretically ported already.

However I do think we should immediately deprecate this as a production dependency in 9.1.x, to be moved to dev dependency in 10.0.x, and also open an issue (probably for drupal-check?) to detect the specific case of importing the wrong exception class since that is a pre-existing bug in apparently a lot of modules.

I'll add this to the 10.0.x beta blockers list too.

alexpott’s picture

@catch yeah I was super surprised by the amount of Masterminds\HTML5\Exception in contrib BUT all those instances are misguided and adding an unneeded dependency in their code.

This will break the inline_ad_entity (not D9 compat), entity_print (not D9 compat but active issue), external_data_source (not d9 compat), crossword (not d9 compat), and onomasticon (d9 compat), modules - we can open issues to add a composer.json

xjm’s picture

Issue tags: -9.0.0 release notes
danflanagan8’s picture

Regarding #11, I have updated the Crossword module to require mastermind/html5 itself. Thanks for calling this out, @alexpott.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

gábor hojtsy’s picture

Issue tags: +Drupal 10

Tagging for Drupal 10.

How do we deprecate a production dependency? Is there even a process for that?

catch’s picture

I think the only thing we can do is add a change record and a release note, telling people to add an explicit dependency if they have one.

andypost’s picture

Issue tags: +Needs release note, +Needs change record
StatusFileSize
new1.76 KB

re-roll for 9.3

alexpott’s picture

@andypost dev dependencies go in the root composer.json not core/composer.json

longwave’s picture

We could issue a deprecation from the class loader, but unsure how to determine (efficiently!) whether the dependency is explicitly installed elsewhere.

alexpott’s picture

In an ideal world we wouldn't have to tell

people to add an explicit dependency if they have one.

Each Drupal extension should list its direct dependencies.

longwave’s picture

Status: Needs work » Needs review
StatusFileSize
new6.41 KB

Can we just drop this dependency entirely? We only use it in two tests, and they don't seem to strictly need it anyway.

Status: Needs review » Needs work

The last submitted patch, 22: 3133749-22.patch, failed testing. View results

longwave’s picture

Failed asserting that 'Topic bad_help_topics.bad_html3 fails HTML validation: Tag nav invalid\n
' contains "Opening and ending tag mismatch".

So this does feel like an HTML5 issue, but how was this triggered? masterminds/html5 doesn't appear to do any kind of polyfilling, it is only used when you instantiate the classes directly?

longwave’s picture

Answering #24: symfony/dom-crawler optionally uses masterminds/html5 if it's available, and the exception is thrown from there, so I think it's OK to adjust this test for the different message, as the end result is the same.

andypost’s picture

Used to try apply related but it does not help to parse html5 markup

Wondering why <p>{% trans %}<a href="/foo">Text here{% endtrans %}</a></p> is not fail with twig renderer

alexpott’s picture

There is another stream of work that is going in the other direction from this issue - #1333730: [Meta] PHP DOM (libxml2) misinterprets HTML5 and people are now working on issues adding more usage of masterminds/html5! See #2441373: Upgrade tests to HTML5 for example.

andypost’s picture

Meantime there's PHP 8.1 compatibility release 2 weeks ago https://github.com/Masterminds/html5-php/releases/tag/2.7.5

effulgentsia’s picture

Is the only reason for this issue just that core isn't yet using masterminds/html5 (much) in production code? If so, then #27 will change that and I think that we should close or postpone this issue based on that.

Or, is there a problem with masterminds/html5? I'm not clear from reading #3040037: Update masterminds/html5 to 2.7.5 how big a problem that presented to the amp module. Are there other html5 parsing libraries that we want to consider instead of masterminds/html5? I don't think we can get away from needing some html5-compatible parser in core.

andypost’s picture

longwave’s picture

Re #29 as far as I can see there are no other viable HTML5 parsers. libxml2 isn't likely to do it in the near future and masterminds/html5 is the only PHP library that I can find.

After reviewing the recently linked issues (one of which I commented in 9 years ago!) I now also think this should be closed and we should aim to complete #2441811: Upgrade filter system to HTML5 instead which will require this library at runtime.

andypost’s picture

Status: Needs work » Closed (won't fix)

+1 on it

The #2441811: Upgrade filter system to HTML5 is great way forward

wim leers’s picture

No need for a change record if we're not doing this!