Why doesn't this module have a dependency to QueryPath?

Created on 14 July 2023, over 1 year ago
Updated 21 July 2023, over 1 year ago

Problem/Motivation

I've noticed this module doesn't have a dependency to QueryPath even though to use any Obtainer and possibly Modifier you need it. Why is this the case? I feel the majority of the benefit added is via these classes. While it might not be a "hard" dependency, you cannot run the example migration mt_example_dom_import without it. Which at the very least, adds a barrier for new adopters of the module.

Another issue is since it isn't a dependency, our site may already have a QP library from another module and that one might not work as expected. For example, feeds_ex has a dependency on arthurkushman/query-path. If I run the same test migration with this QP I get a rather lengthy failure message:

[error] 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('...')
#2 /var/www/html/vendor/arthurkushman/query-path/src/DOM.php(140): QueryPath\DOM->parseXMLString('...')
#3 /var/www/html/vendor/arthurkushman/query-path/src/QueryPath.php(191): QueryPath\DOM->__construct('...', '', Array)
#4 /var/www/html/vendor/arthurkushman/query-path/src/qp_functions.php(157): QueryPath\QueryPath::with('...', NULL, Array)
#5 /var/www/html/docroot/modules/contrib/migration_tools/src/SourceParser/HtmlBase.php(247): qp('...', NULL, Array)
#6 /var/www/html/docroot/modules/contrib/migration_tools/src/SourceParser/HtmlBase.php(62): Drupal\migration_tools\SourceParser\HtmlBase->initQueryPath()
#7 /var/www/html/docroot/modules/contrib/migration_tools/src/Operations.php(90): Drupal\migration_tools\SourceParser\HtmlBase->__construct('about', '...', Object(Drupal\migrate\Row))
#8 /var/www/html/docroot/modules/contrib/migration_tools/src/Plugin/migrate_plus/data_parser/Dom.php(63): Drupal\migration_tools\Operations::process(Array, Object(Drupal\migrate\Row))
#9 /var/www/html/docroot/modules/contrib/migration_tools/src/Plugin/migrate_plus/data_parser/Dom.php(94): Drupal\migration_tools\Plugin\migrate_plus\data_parser\Dom->getSourceIterator('https://www.eff...')
#10 /var/www/html/docroot/modules/contrib/migrate_plus/src/DataParserPluginBase.php(155): Drupal\migration_tools\Plugin\migrate_plus\data_parser\Dom->openSourceUrl('https://www.eff...')

However, if I run it again with gravitypdf/querypath I get the correct response.

Steps to reproduce

  • enable module
  • try to run drush mt_example_dom_import
  • see that it fails with notice "I need a QP library"
  • run composer require gravitypdf/querypath
  • rerun migration
  • see that it passes
  • remove QP, composer remove gravitypdf/querypath
  • add different QP, composer require arthurkushman/query-path
  • rerun migration
  • see that it fails with error above

Proposed resolution

* Become opinionated about what QP library is used
* update notification message to suggest a QP library
* require a QP library in composer

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Active

Version

2.7

Component

Code

Created by

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

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

Comments & Activities

Production build 0.71.5 2024