Module Conflict with AMP using deprecated querypath library

Created on 23 July 2022, over 2 years ago
Updated 21 July 2023, over 1 year ago

Problem/Motivation

There is a conflict with using the AMP module and this one. AMP uses querypath/querypath, whereas this module uses arthurkushman/query-path.

When you have composer download them both you end up with the following error:

Fatal error: Cannot redeclare qp() (previously declared in /home/sitename/vendor/querypath/querypath/src/qp_functions.php:152) in /home/sitename/vendor/arthurkushman/query-path/src/qp_functions.php on line 155

This is bound to be an issue because one is a fork of the other.

Suggestions?

πŸ› Bug report
Status

Active

Version

1.0

Component

QueryPath parser

Created by

πŸ‡ΊπŸ‡ΈUnited States Christopher Riley

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States robpowell Boston

    Without 8.1 support arthurkushman/querypath fails on exceptions because they have required exception args that are no longer required in php 8. This will make debugging any QP errors impossible and we should think about updating to a maintained library.

    I ran into this while working in the migration_tools custom migration. It turned out that the HTML I was parsing had two elements with the same id. Because the library doesn't support php 8 I wasn't able to get this information without hacking the exception as it is wrapped/consumed by the subsequent ArgumentCountError exception:

    ArgumentCountError: Too few arguments to function QueryPath\ParseException::initializeFromError(), 4 passed and exactly 5 expected in QueryPath\ParseException::initializeFromError() (line 45 of /var/www/html/vendor/arthurkushman/query-path/src/ParseException.php) #0 [internal function]: QueryPath\ParseException::initializeFromError(2, 'DOMDocument::lo...', '/var/www/html/v...', 209)
    #1 /var/www/html/vendor/arthurkushman/query-path/src/DOM.php(209): DOMDocument->loadHTML('\xEF\xBB\xBF #2 /var/www/html/vendor/arthurkushman/query-path/src/DOM.php(140): QueryPath\DOM->parseXMLString('\xEF\xBB\xBF #3 /var/www/html/vendor/arthurkushman/query-path/src/QueryPath.php(191): QueryPath\DOM->__construct('\xEF\xBB\xBF #4 /var/www/html/vendor/arthurkushman/query-path/src/qp_functions.php(157): QueryPath\QueryPath::with('\xEF\xBB\xBF

    @slucero and spoke in slack and he pointed out that because gravityPDF's version of the library has in its composer.json a replace for the library that is out of date, all we have to do is require this library in our project:

    drush require gravitypdf/querypath -w

  • πŸ‡³πŸ‡±Netherlands megachriz

    I see on https://github.com/technosophos/querypath that they recommend gravitypdf/querypath. And on https://github.com/GravityPDF/querypath it is mentioned that that library is a fork of https://github.com/arthurkushman/querypath.

    So I guess we could try to switch to gravitypdf/querypath here.

  • πŸ‡³πŸ‡±Netherlands megachriz

    Hm, but the switch wouldn't solve the issue of other projects that require querypath/querypath or arthurkushman/query-path, because the namespace between these projects looks like to be the same.

    If the forks would use an other namespace than the project they forked, then we wouldn't have this issue.

  • Hi.
    is there a way to force lullabot dependency to gravitypdf/querypath instead of querypath/querypath with composer?
    Thank you and regards.

  • Hello,

    I've opened an issue on gravitypdf/querypath repo (https://github.com/GravityPDF/querypath/issues/52) to ask if they could help avoiding conflicts with querypath/querypath and they have very kindly agreed to update qp_functions.php.

    In order to test this I've created an issue fork (https://git.drupalcode.org/issue/feeds_ex-3299193/-/commit/e6ce9779b00f6...) with composer.json updated from "gravitypdf/querypath": "^3.0 || ^4.0" to "gravitypdf/querypath": "main-dev" then on a local ddev D10 I've added this code to the root composer.json

    "repositories": [
    		{
                "type": "package",
                "package": {
                    "name": "drupal/feeds_ex",
                    "version": "1.0-beta",
                    "type": "drupal-module",
                    "source": {
                        "url": "https://git.drupalcode.org/issue/feeds_ex-3299193.git",
                        "type": "git",
                        "reference": "e6ce9779b00f6b24b097d5426d191afaec2c06c2"
                     }
                }
             },

    when I run composer update the forked version of feeds_ex is installed but no dependencies are installed.
    Can someone give any hint on how to troubleshoot this or try this forked version togheter with amp module to test is it fixes the conflict?
    thank you.

  • Hi,
    this issue should be fixed by version 4.0.1 of gravitypdf/querypath (https://github.com/GravityPDF/querypath/issues/52). Updating the module composer.json could help close the issue. Thanks.

Production build 0.71.5 2024