Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/update/update.manager.inc @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
34 * authorized operation (which lives in update.authorize.inc) sets up a batch to | 34 * authorized operation (which lives in update.authorize.inc) sets up a batch to |
35 * copy each extracted update from the temporary location into the live web | 35 * copy each extracted update from the temporary location into the live web |
36 * root. | 36 * root. |
37 */ | 37 */ |
38 | 38 |
39 use Drupal\Core\Url; | |
40 use Drupal\Core\File\Exception\FileException; | |
39 use Symfony\Component\HttpFoundation\RedirectResponse; | 41 use Symfony\Component\HttpFoundation\RedirectResponse; |
40 | 42 |
41 /** | 43 /** |
42 * Batch callback: Performs actions when the download batch is completed. | 44 * Batch callback: Performs actions when the download batch is completed. |
43 * | 45 * |
56 \Drupal::messenger()->addError(\Drupal::service('renderer')->render($item_list)); | 58 \Drupal::messenger()->addError(\Drupal::service('renderer')->render($item_list)); |
57 } | 59 } |
58 elseif ($success) { | 60 elseif ($success) { |
59 \Drupal::messenger()->addStatus(t('Updates downloaded successfully.')); | 61 \Drupal::messenger()->addStatus(t('Updates downloaded successfully.')); |
60 $_SESSION['update_manager_update_projects'] = $results['projects']; | 62 $_SESSION['update_manager_update_projects'] = $results['projects']; |
61 return new RedirectResponse(\Drupal::url('update.confirmation_page', [], ['absolute' => TRUE])); | 63 return new RedirectResponse(Url::fromRoute('update.confirmation_page', [], ['absolute' => TRUE])->toString()); |
62 } | 64 } |
63 else { | 65 else { |
64 // Ideally we're catching all Exceptions, so they should never see this, | 66 // Ideally we're catching all Exceptions, so they should never see this, |
65 // but just in case, we have to tell them something. | 67 // but just in case, we have to tell them something. |
66 \Drupal::messenger()->addError(t('Fatal error trying to download.')); | 68 \Drupal::messenger()->addError(t('Fatal error trying to download.')); |
163 // and others list an actual file (i.e., MODULE/README.TXT). | 165 // and others list an actual file (i.e., MODULE/README.TXT). |
164 $project = strtok($files[0], '/\\'); | 166 $project = strtok($files[0], '/\\'); |
165 | 167 |
166 $extract_location = $directory . '/' . $project; | 168 $extract_location = $directory . '/' . $project; |
167 if (file_exists($extract_location)) { | 169 if (file_exists($extract_location)) { |
168 file_unmanaged_delete_recursive($extract_location); | 170 try { |
171 \Drupal::service('file_system')->deleteRecursive($extract_location); | |
172 } | |
173 catch (FileException $e) { | |
174 // Ignore failed deletes. | |
175 } | |
169 } | 176 } |
170 | 177 |
171 $archiver->extract($directory); | 178 $archiver->extract($directory); |
172 return $archiver; | 179 return $archiver; |
173 } | 180 } |
211 return \Drupal::service('file_system')->realpath($url); | 218 return \Drupal::service('file_system')->realpath($url); |
212 } | 219 } |
213 | 220 |
214 // Check the cache and download the file if needed. | 221 // Check the cache and download the file if needed. |
215 $cache_directory = _update_manager_cache_directory(); | 222 $cache_directory = _update_manager_cache_directory(); |
216 $local = $cache_directory . '/' . drupal_basename($parsed_url['path']); | 223 $local = $cache_directory . '/' . \Drupal::service('file_system')->basename($parsed_url['path']); |
217 | 224 |
218 if (!file_exists($local) || update_delete_file_if_stale($local)) { | 225 if (!file_exists($local) || update_delete_file_if_stale($local)) { |
219 return system_retrieve_file($url, $local, FALSE, FILE_EXISTS_REPLACE); | 226 return system_retrieve_file($url, $local, FALSE, FILE_EXISTS_REPLACE); |
220 } | 227 } |
221 else { | 228 else { |
303 */ | 310 */ |
304 function update_manager_local_transfers_allowed() { | 311 function update_manager_local_transfers_allowed() { |
305 // Compare the owner of a webserver-created temporary file to the owner of | 312 // Compare the owner of a webserver-created temporary file to the owner of |
306 // the configuration directory to determine if local transfers will be | 313 // the configuration directory to determine if local transfers will be |
307 // allowed. | 314 // allowed. |
308 $temporary_file = drupal_tempnam('temporary://', 'update_'); | 315 $temporary_file = \Drupal::service('file_system')->tempnam('temporary://', 'update_'); |
309 $site_path = \Drupal::service('site.path'); | 316 $site_path = \Drupal::service('site.path'); |
310 $local_transfers_allowed = fileowner($temporary_file) === fileowner($site_path); | 317 $local_transfers_allowed = fileowner($temporary_file) === fileowner($site_path); |
311 | 318 |
312 // Clean up. If this fails, we can ignore it (since this is just a temporary | 319 // Clean up. If this fails, we can ignore it (since this is just a temporary |
313 // file anyway). | 320 // file anyway). |