function locale_translation_http_check

Same name and namespace in other branches
  1. 10 core/modules/locale/locale.batch.inc \locale_translation_http_check()
  2. 11.x core/modules/locale/locale.batch.inc \locale_translation_http_check()
  3. 9 core/modules/locale/locale.batch.inc \locale_translation_http_check()
  4. 8.9.x core/modules/locale/locale.batch.inc \locale_translation_http_check()

Check if remote file exists and when it was last updated.

Parameters

string $uri: URI of remote file.

Return value

array|bool Associative array of file data with the following elements:

  • last_modified: Last modified timestamp of the translation file.
  • (optional) location: The location of the translation file. Is only set when a redirect (301) has occurred.

TRUE if the file is not found. FALSE if a fault occurred.

Deprecated

in drupal:11.4.0 and is removed from drupal:13.0.0. Use \Drupal::service(LocaleFileManager::class)checkRemoteFileStatus($uri) instead.

See also

https://www.drupal.org/node/3577675

File

core/modules/locale/locale.batch.inc, line 307

Code

function locale_translation_http_check($uri) {
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal::service(LocaleFileManager::class)->checkRemoteFileStatus($uri) instead. See https://www.drupal.org/node/3577675', E_USER_DEPRECATED);
  $remoteFileInfo = \Drupal::service(LocaleFileManager::class)->checkRemoteFileStatus($uri);
  if ($remoteFileInfo->status === RemoteFileStatus::Error) {
    return FALSE;
  }
  if ($remoteFileInfo->status === RemoteFileStatus::Missing) {
    return TRUE;
  }
  $result['last_modified'] = $remoteFileInfo->lastModified;
  if ($remoteFileInfo->location) {
    $result['location'] = $remoteFileInfo->location;
  }
  return $result;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.