Problem/Motivation

#3086374: Make Drupal 8 & 9 compatible with PHP 7.4 introduces a workaround for easyrdf PHP 7.4 compatibility. We should remove that workaround.

Proposed resolution

Either:
Update easyrdf/easyrdf to a release containing https://github.com/njh/easyrdf/pull/311
OR:
Rewrite \Drupal\Tests\rdf\Traits\RdfParsingTrait to not rely on it

Remaining tasks

  • D9: Update the dev dependency
  • D8: Leave as is, but allow for updating through contrib
  • Inform the contrib maintainers about the issue

Here's the contrib situation:

Project Stability Sites Drupal9 Declared easyrdf dependency Last commit
https://www.drupal.org/project/dcat not stable ? no no 1 year ago
https://www.drupal.org/project/rdfui not stable 366 no no last commit 3 years ago
https://www.drupal.org/project/rdf_entity not stable 503 no dev - "0.10.0-alpha.1 as 0.9.2" one week ago
https://www.drupal.org/project/semantic_connector stable 134 no no 6 months ago
https://www.drupal.org/project/skosmos_feeds stable 1 no * 9 months ago
https://www.drupal.org/project/smart_glossary not stable 32 sites no no 9 months ago
https://www.drupal.org/project/sparql_entity_storage not stable ? no 0.10.0-alpha.1 as 0.9.2 5 days ago
https://www.drupal.org/project/wisski stable 30 yes ^0.9 1 week ago

User interface changes

None

API changes

TBD

Data model changes

None

Release notes snippet

The EasyRDF development dependency has been updated to 1.0.0. See the change record for more details.

Comments

alexpott created an issue. See original summary.

xjm’s picture

I'd go for rewriting the trait and dropping the dependency, since it's barely maintained.

xjm’s picture

Issue tags: +beta target

We could also probably get away with dropping the dependency during beta (though maybe not RC) in order to avoid it being in our lockfile until D10.

sanduhrs’s picture

The pull request has been merged: https://github.com/easyrdf/easyrdf/pull/311
Also, they are trying to establish a broader maintenance model and are heading for a 1.0 release: https://github.com/easyrdf/easyrdf/issues/320

sanduhrs’s picture

Version: 9.0.x-dev » 9.1.x-dev
Status: Active » Needs review
StatusFileSize
new23.02 KB

Status: Needs review » Needs work

The last submitted patch, 5: 3110972-5-Update-easyrdf-library.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jungle’s picture

+++ b/composer.json
@@ -32,7 +32,7 @@
-        "easyrdf/easyrdf": "^0.9"
+        "easyrdf/easyrdf": "dev-master"

Re #5. Instead of dev-master, I would suggest using 1395e5d6ed9ee8efbb4c76ef7227ec69b271616b as 1.0.0, doing so we get a fixed commit locked.

sanduhrs’s picture

Status: Needs work » Needs review
StatusFileSize
new23.47 KB

Added the alias, also added the codesniffer suggestions.

Status: Needs review » Needs work

The last submitted patch, 8: 3110972-7-Update-easyrdf-library.patch, failed testing. View results

alexpott’s picture

Issue summary: View changes

So the problem with this approach is that there definitely is contrib that is using the EasyRdf library. So updating it will break those projects :(

At some point though we need to address this because I don't think the current version is Composer2 compatible and Drupal 9 definitely needs to be D9 compatible.

One thing that's good for D9 is that it is only a dev dependency so in order to be D9 compatible these projects should have already declared their dependency in their composer.json - however I wonder how many have done... here's the list of projects and some info.

Project Stability Sites Drupal9 Declared easyrdf dependency Last commit
https://www.drupal.org/project/dcat not stable ? no no 1 year ago
https://www.drupal.org/project/rdfui not stable 366 no no last commit 3 years ago
https://www.drupal.org/project/rdf_entity not stable 503 no dev - "0.10.0-alpha.1 as 0.9.2" one week ago
https://www.drupal.org/project/semantic_connector stable 134 no no 6 months ago
https://www.drupal.org/project/skosmos_feeds stable 1 no * 9 months ago
https://www.drupal.org/project/smart_glossary not stable 32 sites no no 9 months ago
https://www.drupal.org/project/sparql_entity_storage not stable ? no 0.10.0-alpha.1 as 0.9.2 5 days ago
https://www.drupal.org/project/wisski stable 30 yes ^0.9 1 week ago
sanduhrs’s picture

As far as I can tell, the main difference between 0.9.8 and 0.10.0-alpha.1 (and upcoming 1.0.0) compatibility wise is namespaces and changed class names. That should be rather easy to update.

So, for Drupal 9 we would be free to either update the dependency in --dev or remove it?

For Drupal 8 we'd need contrib to explicitly require an updated version and update their code?
We have two modules that already require a newer version that should be (mostly) compatible with the upcoming 1.0.0 release.
We have 5 that rely on core shipping the library, after a quick look, updating them should be really, really easy.
For RDFUI I've already done this, now waiting for git access, see https://github.com/sanduhrs/drupal-rdfui and https://www.drupal.org/project/rdfui/issues/3155327
And we have one that explicitly requires the 0.9.x version, updating this should also be relatively easy.

I'd suggest to inform the maintainers of the needed changes.
They should declare the dependency and update the code to work with the upcoming 1.0.0.
Where they do not respond, I'd be willing to provide initial patches - so existing users still have the possibility to update their setups.

alexpott’s picture

As far as I can tell, the main difference between 0.9.8 and 0.10.0-alpha.1 (and upcoming 1.0.0) compatibility wise is namespaces and changed class names. That should be rather easy to update.

Yep it's not a tricky update but it is a breaking update. And the situation for D9 is simpler because I think upgrading the dev dependency is okay - we don't ship with it in the tarball and it is included in the composer project. But unfortunately for D8 the situation is more complex because whilst easyrdf is only used in tests it is a production dependency

+1 for creating an issue on every project. I also think we need some wider communication about when this is going to happen for D8 because I think we need D8 to be composer2 compatible.

So the question is do we need to touch Drupal 8? I'm not sure we do. At least atm update using composer 2 works on Drupal 8 and there are no warnings or anything during a regular install. You only get a warning when doing composer dump-autoload --optimize so it's not that bad imo. So maybe the thing to do here is upgrade Drupal 9 because it is a dev dependency and tell projects to that this is going to happen. And we could also change the composer.json in Drupal 8 to allow v1 of easyrdf once it exists but continue to allow 0.9 and leave the lock file alone - so projects that want to upgrade can - or something like that.

sanduhrs’s picture

StatusFileSize
new20.17 KB
new478 bytes

Fine with that.
Attached is an updated patch for D9 updating the --dev dependency
and a patch for D8 allowing for an updated library through contrib.

sanduhrs’s picture

Status: Needs work » Needs review
sanduhrs’s picture

Issue summary: View changes

The last submitted patch, 13: 3110972-13-Update-easyrdf-library.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 13: 3110972-13-D8-Update-easyrdf-library.patch, failed testing. View results

alexpott’s picture

I think we should wait until there is actually a 1.0.0 release - hopefully that'll be soon but things have taken time with easyrdf before. But we definitely should do the work on communicating what contrib needs to do. Which is to ensure they have a composer.json with the correct dependency version and in the correct place i.e. prod or dev.

jungle’s picture

sanduhrs’s picture

Status: Needs work » Needs review
StatusFileSize
new19.44 KB

easyrdf has an 1.0.0 release, now.
Patch attached.

alexpott’s picture

Title: Update easyrdf library or change \Drupal\Tests\rdf\Traits\RdfParsingTrait to not rely on it » Update easyrdf library to 1.0.0
Status: Needs review » Needs work

Yay to see the back of the class_alias fudge...

+++ b/composer.json
@@ -32,7 +32,7 @@
+        "easyrdf/easyrdf": "1.0.0"

Should be "^1.0"

sanduhrs’s picture

Status: Needs work » Needs review
StatusFileSize
new19.79 KB

^1.0 it is!

sanduhrs’s picture

StatusFileSize
new476 bytes
alexpott’s picture

@sanduhrs Drupal 8 is much much harder than Drupal 9 because easyrdf is incorrectly not a dev dependency. So we can't do that - our usage in Drupal 8 is not compatible. We'd need to fix the our usage to work with either version - so min/max testing...

Status: Needs review » Needs work

The last submitted patch, 23: 3110972-23-D8-Update-easyrdf-library.patch, failed testing. View results

alexpott’s picture

@sanduhrs I think we should only do Drupal 9 in this issue and then tackle Drupal 8 in a separate issue. It's going to need very different code changes.

sanduhrs’s picture

Status: Needs work » Needs review
StatusFileSize
new4.61 KB

Actually a few more class aliases might work ;)
Or should we go for conditional class usage in the trait's methods?

sanduhrs’s picture

alexpott’s picture

@sanduhrs we need to fix Drupal 9 first. Let's make the latest patch the Drupal 9 patch - discuss and review that and then deal with Drupal 8 - it's way more complicated because we're not even testing with easyrdf 1.0.0 because of how DrupalCI works.

FWIW on D8 patch...

+++ b/core/composer.json
@@ -37,7 +37,7 @@
-        "easyrdf/easyrdf": "^0.9",

^0.9 | ^1.0 unless we're not compatible with 0.10.0 in which case... ">=0.9.0 <0.10.0 | ^1.0" is what it should be but we should be careful with that cause some contrib requires 0.10... as far as I remember. But again let's fix D9 first.

sanduhrs’s picture

StatusFileSize
new19.79 KB

Reattached the patch for D9 from #22.

- It requires easyrdf/easyrdf: ^1.0 as a dev dependency
- It removes the workaround from #3110972: Update easyrdf library to 1.0.0
- It updates \EasyRdf usage to use namespaces

Tests passed already in #22.
What's left to be done?

The last submitted patch, 27: 3110972-27-D8-Update-easyrdf-library.patch, failed testing. View results

alexpott’s picture

Issue tags: +Needs change record

I think as this is a dependency update I think we need a change record. It's a bit tricky because it only affects dev dependencies but we do ship dev dependencies as a package so I think we need one.

sanduhrs’s picture

Here is a draft change record https://www.drupal.org/node/3159977

sanduhrs’s picture

samiullah’s picture

StatusFileSize
new16.49 KB

Tested the latest patch on local instance of drupal 9.1.x
Checked if easyrdf is updated to 1.0.0 version
Looks good
This can be moved to RTBC if code review is fine

jungle’s picture

Issue tags: -Needs change record

@samiullah, thanks for the review.

But in general, you do not have to attach any screenshots, unless it's asked. For example: tagged Needs manual testing.

Attaching screenshot of patch applying, which might be taken as a behavior of credit gaming by committer.

CR added. removing the Needs change record tag.

jungle’s picture

Status: Needs review » Reviewed & tested by the community

- It requires easyrdf/easyrdf: ^1.0 as a dev dependency
- It removes the workaround from #3110972: Update easyrdf library to 1.0.0
- It updates \EasyRdf usage to use namespaces

@sanduhrs's "self-review" is good. besides, the link to the workaround issue points THIS, it should be #3090017: Isolate test dependency on easyrdf/easyrdf to a single trait

Thanks!

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Needs a re-roll.

sanduhrs’s picture

Assigned: Unassigned » sanduhrs
sanduhrs’s picture

composer require easyrdf/easyrdf:"^1.0" --dev --no-update
composer update easyrdf/easyrdf       
> Drupal\Composer\Composer::ensureComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Updating easyrdf/easyrdf (0.9.1 => 1.0.0): Loading from cache
    Cleaning: easyrdf/easyrdf
Writing lock file
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
Hardening vendor directory with .htaccess and web.config files.
44 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Cleaning vendor directory.
> Drupal\Composer\Composer::generateMetapackages
Updated metapackage file composer/Metapackage/CoreRecommended/composer.json.
Updated metapackage file composer/Metapackage/DevDependencies/composer.json.
Updated metapackage file composer/Metapackage/PinnedDevDependencies/composer.json.
If you make a patch, ensure that the files above are included.
composer update easyrdf/easyrdf  17.02s user 1.43s system 38% cpu 48.299 total

Ho can I prevent composer from updating the metapackages?
Did not have this issue before :/

sanduhrs’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new22.38 KB

Attached is a patch that includes the metapackage updates.

sanduhrs’s picture

Assigned: sanduhrs » Unassigned

Status: Needs review » Needs work

The last submitted patch, 41: 3110972-41-Update-easyrdf-library.patch, failed testing. View results

alexpott’s picture

@sanduhrs the meta packages need updating.

raman.b’s picture

Status: Needs work » Needs review
StatusFileSize
new19.92 KB

Patch #41 no longer applies. Re-rolling.

Status: Needs review » Needs work

The last submitted patch, 45: 3110972-45.patch, failed testing. View results

raman.b’s picture

Status: Needs work » Needs review

Unrelated test failure.

1) Drupal\Tests\quickedit\FunctionalJavascript\QuickEditIntegrationTest::testCustomBlock
Field block_content/1/body/en/full did not match its expectation selector (.cke_editable_inline), actual HTML: The name "llama" was adopted by European settlers from native Peruvians.
Failed asserting that 'The name "llama" was adopted by European settlers from native Peruvians.' is true.

Triggering test again

jungle’s picture

Issue tags: +Composer 2

FYI, following warnings got while running composer install against Drupal core 9.0.7

Generating optimized autoload files
Deprecation Notice: Class EasyRdf_Parser_JsonLd located in ./vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/JsonLdImplementation.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Stack trace:
 phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:116
 phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:355
 phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:341
 phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:264
 phar:///usr/local/bin/composer/src/Composer/Installer.php:307
 phar:///usr/local/bin/composer/src/Composer/Command/InstallCommand.php:122
 phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:245
 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:835
 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:185
 phar:///usr/local/bin/composer/src/Composer/Console/Application.php:281
 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117
 phar:///usr/local/bin/composer/src/Composer/Console/Application.php:113
 phar:///usr/local/bin/composer/bin/composer:61
 /usr/local/bin/composer:24
Deprecation Notice: Class EasyRdf_Serialiser_JsonLd located in ./vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/JsonLd_real.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Stack trace:
 phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:116
 phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:355
 phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:341
 phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php:264
 phar:///usr/local/bin/composer/src/Composer/Installer.php:307
 phar:///usr/local/bin/composer/src/Composer/Command/InstallCommand.php:122
 phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:245
 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:835
 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:185
 phar:///usr/local/bin/composer/src/Composer/Console/Application.php:281
 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117
 phar:///usr/local/bin/composer/src/Composer/Console/Application.php:113
 phar:///usr/local/bin/composer/bin/composer:61
 /usr/local/bin/composer:24
jungle’s picture

StatusFileSize
new2.05 KB
new61.21 KB
new41.51 KB

Attaching a raw interdiff for #45.

Updated composer.lock with composer update --lock -vvv and Composer version 2.0.0-RC1 2020-09-10 15:39:45

jungle’s picture

All changes in interdiff-45-49.txt are support key added to each packages. See https://getcomposer.org/doc/04-schema.md#support. So if #49 passes, I would set it to RTBC.

andypost’s picture

+++ b/composer.lock
@@ -7181,5 +7605,5 @@
-    "plugin-api-version": "1.1.0"
+    "plugin-api-version": "2.0.0"

this change looks unrelated

jungle’s picture

StatusFileSize
new289 bytes
new19.7 KB

Thanks, @andypost!

Started from #45 again with Composer version 1.10.13 2020-09-09 11:46:34

And got composer.lock updated with composer update --lock -vvv, reverted

-    "plugin-api-version": "1.1.0"
+    "plugin-api-version": "2.0.0"
This release has been tagged with Composer 2.0.0-RC1. Please report any issues in the Drupal core issue queue.

Meanwhile, as https://www.drupal.org/project/drupal/releases/9.0.7 tagged with Composer 2.0.0-RC1 already, maybe it's time and it's ok switching to "plugin-api-version": "2.0.0".

andypost’s picture

Status: Needs review » Reviewed & tested by the community
samiullah’s picture

catch’s picture

@alexpott asked me to look at the issues raised in #10.

Only one of these modules is both stable and Drupal 9 compatible: https://www.drupal.org/project/wisski, and this patch will break it by the looks of things. I think we should file an issue asking them to loosen to ^0.9|^1.0 or similar before this goes in. (And the other modules too, but they already have other work to do to become Drupal 9 compatible and/or stable).

For Drupal 8... I think we just can't commit this to Drupal 8 and it won't fully support Composer 2 (but de facto, it mostly does), agree with #3110972-12: Update easyrdf library to 1.0.0:

So the question is do we need to touch Drupal 8? I'm not sure we do. At least atm update using composer 2 works on Drupal 8 and there are no warnings or anything during a regular install. You only get a warning when doing composer dump-autoload --optimize so it's not that bad imo.

I do think we should continue trying to remove the dependency altogether, either by refactoring, or #2152459: [Policy] Deprecate RDF module and move it to contrib.

alexpott’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Thinking about this I think we can support both 0.9 and 1.0 in core and then make contrib's / custom life a bit simple unless they are using drupal/core-dev-pinned which not many are.

@@ -113,10 +113,12 @@ protected function getElementByRdfTypeCount(Url $url, $base_uri, $type) {
-    $parser = new \EasyRdf_Parser_Rdfa();
-    $graph = new \EasyRdf_Graph();
+    $parser = new Rdfa();
+    $graph = new Graph();

We can introduce two new private functions getEasyRdfParser and getEasyRdfGraph

And do something like

if (class_exists('EasyRdf\Parser\Rdfa')) {
  return new Rdfa();
}
return new \EasyRdf_Parser_Rdfa();

We'd still dev pin to 1.0 but and remove our PHP 7.4 compatibility layer - but we won't break any projects tests like Wisski. And they can upgrade in their own time. In Drupal 10 we can remove support for 0.9 early.

jungle’s picture

Status: Needs work » Needs review
StatusFileSize
new3.29 KB
new20.48 KB

Addresing #57

alexpott’s picture

Status: Needs review » Needs work
+++ b/composer.json
@@ -33,7 +33,7 @@
-        "easyrdf/easyrdf": "^0.9"
+        "easyrdf/easyrdf": "^1.0"
     },

Thanks @jungle - this needs a change too... ^0.9 | ^1.0 and then the composer templates will need rebuilding

andypost’s picture

Then it needs todo and d10 issue

jungle’s picture

Status: Needs work » Needs review
StatusFileSize
new20.68 KB
new2.42 KB

Addressed #59, added a D10 issue #3176468: Remove support for EasyRDF 0.9 and @todo

Thanks!

andypost’s picture

Looks ready, thanks!

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Missed to change status

alexpott’s picture

I've run \Drupal\Tests\rdf\Functional\CommentAttributesTest with both 0.9 and 1.0 and it works great. I think this is a good pragmatic step to getting everyone who is use EasyRDF onto the 1.0 release.

  • alexpott committed 89d9f11 on 9.1.x
    Issue #3110972 by sanduhrs, jungle, raman.b, samiullah, alexpott,...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 89d9f11 and pushed to 9.1.x. Thanks!

alexpott’s picture

jungle’s picture

+++ b/composer.json
@@ -33,7 +33,7 @@
+        "easyrdf/easyrdf": "^0.9 || ^1.0"
A double pipe (||) will be treated as a logical OR

Sorry, forgot to mention. I have not found docs for the usage of single pipe (|) in composer versions and constraints. Not sure if a single pipe (|) is treated as OR per the official docs here for Version Range, @alexpott suggested to use the single pipe (|) in #59, in the patch #61, I used double pipe (||).

jungle’s picture

  • FYI, following warnings got while running composer install against Drupal core 9.0.7

    For the warnings mentioned in #48, I would suggest backporting this to 9.0.x. In addition, the release note of 9.0.7 says "This release has been tagged with Composer 2.0.0-RC1. Please report any issues in the Drupal core issue queue.", this is another reason to me to backport this. Please set to NW if you agree.

  • And BTW, the CR associated has not been published.
jungle’s picture

Self-reply to #68

We can not ever remove this or it'd break existing versions, we can only tell you || is preferred now :)

-- @Seldaek commented on 7 Apr, @see https://github.com/composer/composer/issues/6755#issuecomment-610363856

That means double pipe (||) is preferred.

Thanks @voleger guided me here to find it.

alexpott’s picture

Published change record (which, I think, anyone can do).

alexpott’s picture

Issue tags: +9.1.0 release notes

I'm not sure this is worth a release notes mention but tagging because it is a dependency (of sorts) update.

claudiu.cristea’s picture

@alexpott, Can we, at least, in 8.9.x, move easyrdf/easyrdf from require (./core/composer.json) to require-dev (./composer.json)? As is now it prevents me updating to 1.0.0 and this is a pain as we plan to stay on 8.9.x more months for now

claudiu.cristea’s picture

I've opened a follow-up for 8.9.x #3176975: Allow updating easyrdf/easyrdf on 8.9.x.

catch’s picture

Issue summary: View changes
xjm’s picture

Issue tags: -beta target

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.