Return xml data for update status checks as streamed response
parent
c37ad75c3a
commit
3f67d56abb
|
@ -1,5 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_system_theme_info().
|
* Implements hook_system_theme_info().
|
||||||
*/
|
*/
|
||||||
|
@ -105,13 +108,26 @@ function update_test_mock_page($project_name) {
|
||||||
// The test didn't specify (for example, the webroot has other modules and
|
// The test didn't specify (for example, the webroot has other modules and
|
||||||
// themes installed but they're disabled by the version of the site
|
// themes installed but they're disabled by the version of the site
|
||||||
// running the test. So, we default to a file we know won't exist, so at
|
// running the test. So, we default to a file we know won't exist, so at
|
||||||
// least we'll get an empty page from readfile instead of a bunch of
|
// least we'll get an empty xml response instead of a bunch of Drupal page
|
||||||
// Drupal page output.
|
// output.
|
||||||
$availability_scenario = '#broken#';
|
$availability_scenario = '#broken#';
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = drupal_get_path('module', 'update_test');
|
$path = drupal_get_path('module', 'update_test');
|
||||||
readfile("$path/$project_name.$availability_scenario.xml");
|
$file = "$path/$project_name.$availability_scenario.xml";
|
||||||
|
if (!is_file($file)) {
|
||||||
|
// Return an empty response.
|
||||||
|
return new Response('', 200, array('Content-Type' => 'text/xml; charset=utf-8'));
|
||||||
|
}
|
||||||
|
return new StreamedResponse(function() use ($file) {
|
||||||
|
// Transfer file in 1024 byte chunks to save memory usage.
|
||||||
|
if ($fd = fopen($file, 'rb')) {
|
||||||
|
while (!feof($fd)) {
|
||||||
|
print fread($fd, 1024);
|
||||||
|
}
|
||||||
|
fclose($fd);
|
||||||
|
}
|
||||||
|
}, 200, array('Content-Type' => 'text/xml; charset=utf-8'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -142,7 +142,7 @@ function _update_process_fetch_task($project) {
|
||||||
$project_name = $project['name'];
|
$project_name = $project['name'];
|
||||||
|
|
||||||
if (empty($fail[$fetch_url_base]) || $fail[$fetch_url_base] < $max_fetch_attempts) {
|
if (empty($fail[$fetch_url_base]) || $fail[$fetch_url_base] < $max_fetch_attempts) {
|
||||||
$xml = drupal_http_request($url);
|
$xml = drupal_http_request($url, array('headers' => array('accept' => 'text/xml')));
|
||||||
if (!isset($xml->error) && isset($xml->data)) {
|
if (!isset($xml->error) && isset($xml->data)) {
|
||||||
$data = $xml->data;
|
$data = $xml->data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue