Module Conflict with AMP using deprecated querypath library

Created on 23 July 2022, almost 2 years ago
Updated 21 July 2023, 11 months 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.

Production build 0.69.0 2024