function feeds_ex_update_7102 in Feeds extensible parsers 7
Checks if for any importers libraries got missing.
File
- ./
feeds_ex.install, line 141 - Install/enable/update hooks for feeds_ex.
Code
function feeds_ex_update_7102() {
if (!class_exists('\\Flow\\JSONPath\\JSONPath', TRUE)) {
if (!module_exists('feeds')) {
throw new DrupalUpdateException('Please enable the Feeds module to run this update.');
}
if (!module_exists('feeds_ex')) {
throw new DrupalUpdateException('Please enable the Feeds extensible parser module to run this update.');
}
if (FeedsExJsonUtility::jsonPathParserInstalled()) {
return;
}
$has_json_importer = FALSE;
// Check if any of the feeds importers are using the JSON parser.
foreach (feeds_importer_load_all(TRUE) as $importer) {
$plugin = $importer->config['parser']['plugin_key'];
switch ($plugin) {
case 'FeedsExJsonPath':
case 'FeedsExJsonPathLines':
// We've found an importer using jsonpath.
$has_json_importer = TRUE;
break 2;
}
}
if ($has_json_importer) {
// Try to enable xautoload and libraries.
$xautoload = module_enable(array(
'xautoload',
));
$libraries = module_enable(array(
'libraries',
));
if (!$xautoload || !$libraries) {
$modules = [];
if (!$xautoload) {
$modules[] = 'xautoload';
}
if (!$libraries) {
$modules[] = 'libraries';
}
throw new DrupalUpdateException(format_string("You are not loading flow/jsonpath using composer and the following modules couldn't be installed: @modules. Please download these modules or ensure flow/jsonpath is being loaded via your composer setup.", array(
'@modules' => implode(', ', $modules),
)));
}
// Libraries should be enabled at this point.
if (!file_exists(libraries_get_path('jsonpath') . '/src/Flow/JSONPath/JSONPath.php')) {
drupal_load('module', 'feeds_ex');
$message = '';
// Let's make sure they know about the security issue.
if (file_exists(libraries_get_path('jsonpath') . '/jsonpath.php')) {
$message = format_string('To remain secure because of issues identified in !sa, you must remove goessner/jsonpath and replace it with flow/jsonpath.', array(
'!sa' => '<a href="https://www.drupal.org/sa-contrib-2019-083">SA-CONTRIB-2019-083</a>',
));
}
$message .= ' ' . format_string('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_EX_JSONPATH_LIBRARY_VERSION,
'@download' => 'https://github.com/FlowCommunications/JSONPath/archive/' . FEEDS_EX_JSONPATH_LIBRARY_VERSION . '.tar.gz',
));
throw new DrupalUpdateException($message);
}
}
}
}