function feeds_jsonpath_parser_update_7001 in Feeds JSONPath Parser 7
Enable Xautoload as it's required for the new library.
File
- ./
feeds_jsonpath_parser.install, line 53 - Installation file for Feeds JSONPath Parser module.
Code
function feeds_jsonpath_parser_update_7001() {
$t = get_t();
if (!module_enable(array(
'xautoload',
))) {
throw new DrupalUpdateException("The module 'xautoload' couldn't be installed. Please download it.");
}
// Interesting edge case here. If you are using drush updb, and drush is
// provided by composer, and you have flow/jsonpath installed, but you don't
// have composer_autoload installed... or include vendor/autoload.php
// elsewhere, class_exists() still returns TRUE because drush runs
// vendor/autoload.php which allows this namespace to exist. However, this
// namespace would still not exist on the Drupal website because it never
// loads vendor/autoload.php.
if (!class_exists('\\Flow\\JSONPath\\JSONPath', TRUE)) {
// If not, then we should have libraries installed.
if (!module_enable(array(
'libraries',
))) {
throw new DrupalUpdateException("You are not loading flow/jsonpath using composer and libraries couldn't be installed. Please download the libraries module or ensure flow/jsonpath is being loaded via your composer setup.");
}
if (!file_exists(libraries_get_path('jsonpath') . '/src/Flow/JSONPath/JSONPath.php')) {
$message = '';
// Lets make sure they know about the security issue.
if (file_exists(libraries_get_path('jsonpath') . '/jsonpath.php')) {
$message = $t('To remain secure because of issues identified in <a href="https://www.drupal.org/sa-contrib-2019-083">SA-CONTRIB-2019-083</a>, you must remove goessner/jsonpath and replace it with flow/jsonpath.');
}
$message .= ' ' . $t('The <a href="@jsonpath">JSONPath</a> library is missing. Download <a href="@download">@download</a> and place the contents of JSONPath-@version in sites/all/libraries/jsonpath', array(
'@jsonpath' => 'https://github.com/FlowCommunications/JSONPath',
'@version' => FEEDS_JSONPATH_PARSER_LIBRARY_VERSION,
'@download' => 'https://github.com/FlowCommunications/JSONPath/archive/' . FEEDS_JSONPATH_PARSER_LIBRARY_VERSION . '.tar.gz',
));
throw new DrupalUpdateException($message);
}
}
}