Update to Drupal 8.1.5. For more information, see https://www.drupal.org/project/drupal/releases/8.1.5
This commit is contained in:
parent
13b6ca7cc2
commit
38ba7c357d
342 changed files with 7814 additions and 1534 deletions
|
@ -32,12 +32,13 @@ function entity_render_cache_clear() {
|
|||
* The bundle info for a specific entity type, or all entity types.
|
||||
*
|
||||
* @deprecated in Drupal 8.x-dev and will be removed before Drupal 9.0.0. Use
|
||||
* \Drupal\Core\Entity\EntityManagerInterface::getBundleInfo() for a single
|
||||
* bundle, or \Drupal\Core\Entity\EntityManagerInterface::getAllBundleInfo()
|
||||
* for all bundles.
|
||||
* \Drupal\Core\Entity\EntityTypeBundleInfoInterface::getBundleInfo() for a
|
||||
* single bundle, or
|
||||
* \Drupal\Core\Entity\EntityTypeBundleInfoInterface::getAllBundleInfo() for
|
||||
* all bundles.
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getBundleInfo()
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getAllBundleInfo()
|
||||
* @see \Drupal\Core\Entity\EntityTypeBundleInfoInterface::getBundleInfo()
|
||||
* @see \Drupal\Core\Entity\EntityTypeBundleInfoInterface::getAllBundleInfo()
|
||||
*/
|
||||
function entity_get_bundles($entity_type = NULL) {
|
||||
if (isset($entity_type)) {
|
||||
|
@ -67,11 +68,11 @@ function entity_get_bundles($entity_type = NULL) {
|
|||
* entity type is variable, use the entity manager service to load the entity
|
||||
* from the entity storage:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)->load($id)
|
||||
* \Drupal::entityTypeManager()->getStorage($entity_type)->load($id);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityInterface::load()
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::load()
|
||||
* @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage
|
||||
* @see \Drupal\Core\Entity\Query\QueryInterface
|
||||
|
@ -100,10 +101,12 @@ function entity_load($entity_type, $id, $reset = FALSE) {
|
|||
* the entity storage's loadRevision() method to load a specific entity
|
||||
* revision:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)->loadRevision($revision_id);
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage($entity_type)
|
||||
* ->loadRevision($revision_id);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadRevision()
|
||||
* @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage
|
||||
*/
|
||||
|
@ -125,10 +128,12 @@ function entity_revision_load($entity_type, $revision_id) {
|
|||
* the entity storage's deleteRevision() method to delete a specific entity
|
||||
* revision:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)>deleteRevision($revision_id);
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage($entity_type)
|
||||
* ->deleteRevision($revision_id);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::deleteRevision()
|
||||
*/
|
||||
function entity_revision_delete($entity_type, $revision_id) {
|
||||
|
@ -171,11 +176,11 @@ function entity_revision_delete($entity_type, $revision_id) {
|
|||
* the entity type is variable, use the entity manager service to load the
|
||||
* entity from the entity storage:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)->loadMultiple($id)
|
||||
* \Drupal::entityTypeManager()->getStorage($entity_type)->loadMultiple($id);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityInterface::loadMultiple()
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadMultiple()
|
||||
* @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage
|
||||
* @see \Drupal\Core\Entity\Query\QueryInterface
|
||||
|
@ -205,10 +210,12 @@ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) {
|
|||
* the entity storage's loadByProperties() method to load an entity by their
|
||||
* property values:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)->loadByProperties($values);
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage($entity_type)
|
||||
* ->loadByProperties($values);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadByProperties()
|
||||
*/
|
||||
function entity_load_multiple_by_properties($entity_type, array $values) {
|
||||
|
@ -236,10 +243,10 @@ function entity_load_multiple_by_properties($entity_type, array $values) {
|
|||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity storage's loadUnchanged() method to load an unchanged entity:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)->loadUnchanged($id).
|
||||
* \Drupal::entityTypeManager()->getStorage($entity_type)->loadUnchanged($id);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadUnchanged()
|
||||
*/
|
||||
function entity_load_unchanged($entity_type, $id) {
|
||||
|
@ -259,12 +266,12 @@ function entity_load_unchanged($entity_type, $id) {
|
|||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity storage's delete() method to delete multiple entities:
|
||||
* @code
|
||||
* $storage_handler = \Drupal::entityManager()->getStorage($entity_type);
|
||||
* $storage_handler = \Drupal::entityTypeManager()->getStorage($entity_type);
|
||||
* $entities = $storage_handler->loadMultiple($ids);
|
||||
* $storage_handler->delete($entities);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadMultiple()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::delete()
|
||||
*/
|
||||
|
@ -292,10 +299,10 @@ function entity_delete_multiple($entity_type, array $ids) {
|
|||
* entity type is variable, use the entity storage's create() method to
|
||||
* construct a new entity:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)->create($values)
|
||||
* \Drupal::entityTypeManager()->getStorage($entity_type)->create($values);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::create()
|
||||
*/
|
||||
function entity_create($entity_type, array $values = array()) {
|
||||
|
@ -349,11 +356,12 @@ function entity_page_label(EntityInterface $entity, $langcode = NULL) {
|
|||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
|
||||
* Use the entity view builder's view() method for creating a render array:
|
||||
* @code
|
||||
* $view_builder = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId());
|
||||
* $view_builder = \Drupal::entityTypeManager()
|
||||
* ->getViewBuilder($entity->getEntityTypeId());
|
||||
* return $view_builder->view($entity, $view_mode, $langcode);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getViewBuilder()
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getViewBuilder()
|
||||
* @see \Drupal\Core\Entity\EntityViewBuilderInterface::view()
|
||||
*/
|
||||
function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $reset = FALSE) {
|
||||
|
@ -386,11 +394,12 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $res
|
|||
* Use the entity view builder's viewMultiple() method for creating a render
|
||||
* array for the provided entities:
|
||||
* @code
|
||||
* $view_builder = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId());
|
||||
* $view_builder = \Drupal::entityTypeManager()
|
||||
* ->getViewBuilder($entity->getEntityTypeId());
|
||||
* return $view_builder->viewMultiple($entities, $view_mode, $langcode);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getViewBuilder()
|
||||
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getViewBuilder()
|
||||
* @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewMultiple()
|
||||
*/
|
||||
function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $reset = FALSE) {
|
||||
|
@ -443,7 +452,9 @@ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $re
|
|||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
|
||||
* If the display is available in configuration use:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage('entity_view_display')->load($entity_type . '.' . $bundle . '.' . $view_mode);
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage('entity_view_display')
|
||||
* ->load($entity_type . '.' . $bundle . '.' . $view_mode);
|
||||
* @endcode
|
||||
* When the display is not available in configuration, you can create a new
|
||||
* EntityViewDisplay object using:
|
||||
|
@ -454,7 +465,9 @@ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $re
|
|||
* 'mode' => $view_mode,
|
||||
* 'status' => TRUE,
|
||||
* ));
|
||||
* \Drupal::entityManager()->getStorage('entity_view_display')->create($values);
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage('entity_view_display')
|
||||
* ->create($values);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::create()
|
||||
|
@ -519,10 +532,12 @@ function entity_get_display($entity_type, $bundle, $view_mode) {
|
|||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
|
||||
* If the entity form display is available in configuration use:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage('entity_form_display')->load($entity_type . '.' . $bundle . '.' . $form_mode);
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage('entity_form_display')
|
||||
* ->load($entity_type . '.' . $bundle . '.' . $form_mode);
|
||||
* @endcode
|
||||
* When the entity form display is not available in configuration, you can create a new
|
||||
* EntityFormDisplay object using:
|
||||
* When the entity form display is not available in configuration, you can
|
||||
* create a new EntityFormDisplay object using:
|
||||
* @code
|
||||
* $values = ('entity_form_display', array(
|
||||
* 'targetEntityType' => $entity_type,
|
||||
|
@ -530,7 +545,9 @@ function entity_get_display($entity_type, $bundle, $view_mode) {
|
|||
* 'mode' => $form_mode,
|
||||
* 'status' => TRUE,
|
||||
* ));
|
||||
* \Drupal::entityManager()->getStorage('entity_form_display')->create($values);
|
||||
* \Drupal::entityTypeManager()
|
||||
* ->getStorage('entity_form_display')
|
||||
* ->create($values);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::create()
|
||||
|
|
|
@ -397,7 +397,7 @@ function file_valid_uri($uri) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Copies a file to a new location without invoking the file API.
|
||||
* Copies a file to a new location without database changes or hook invocation.
|
||||
*
|
||||
* This is a powerful function that in many ways performs like an advanced
|
||||
* version of copy().
|
||||
|
@ -407,10 +407,9 @@ function file_valid_uri($uri) {
|
|||
* - If the $source and $destination are equal, the behavior depends on the
|
||||
* $replace parameter. FILE_EXISTS_REPLACE will error out. FILE_EXISTS_RENAME
|
||||
* will rename the file until the $destination is unique.
|
||||
* - Provides a fallback using realpaths if the move fails using stream
|
||||
* wrappers. This can occur because PHP's copy() function does not properly
|
||||
* support streams if open_basedir is enabled. See
|
||||
* https://bugs.php.net/bug.php?id=60456
|
||||
* - Works around a PHP bug where copy() does not properly support streams if
|
||||
* safe_mode or open_basedir are enabled.
|
||||
* @see https://bugs.php.net/bug.php?id=60456
|
||||
*
|
||||
* @param $source
|
||||
* A string specifying the filepath or URI of the source file.
|
||||
|
@ -431,18 +430,66 @@ function file_valid_uri($uri) {
|
|||
* @see file_copy()
|
||||
*/
|
||||
function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
|
||||
if (!file_unmanaged_prepare($source, $destination, $replace)) {
|
||||
return FALSE;
|
||||
}
|
||||
// Attempt to resolve the URIs. This is necessary in certain configurations
|
||||
// (see above).
|
||||
$real_source = drupal_realpath($source) ?: $source;
|
||||
$real_destination = drupal_realpath($destination) ?: $destination;
|
||||
// Perform the copy operation.
|
||||
if (!@copy($real_source, $real_destination)) {
|
||||
\Drupal::logger('file')->error('The specified file %file could not be copied to %destination.', array('%file' => $source, '%destination' => $destination));
|
||||
return FALSE;
|
||||
}
|
||||
// Set the permissions on the new file.
|
||||
drupal_chmod($destination);
|
||||
return $destination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function that prepares the destination for a file_unmanaged_copy or
|
||||
* file_unmanaged_move operation.
|
||||
*
|
||||
* - Checks if $source and $destination are valid and readable/writable.
|
||||
* - Checks that $source is not equal to $destination; if they are an error
|
||||
* is reported.
|
||||
* - If file already exists in $destination either the call will error out,
|
||||
* replace the file or rename the file based on the $replace parameter.
|
||||
*
|
||||
* @param $source
|
||||
* A string specifying the filepath or URI of the source file.
|
||||
* @param $destination
|
||||
* A URI containing the destination that $source should be moved/copied to.
|
||||
* The URI may be a bare filepath (without a scheme) and in that case the
|
||||
* default scheme (file://) will be used. If this value is omitted, Drupal's
|
||||
* default files scheme will be used, usually "public://".
|
||||
* @param $replace
|
||||
* Replace behavior when the destination file already exists:
|
||||
* - FILE_EXISTS_REPLACE - Replace the existing file.
|
||||
* - FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is
|
||||
* unique.
|
||||
* - FILE_EXISTS_ERROR - Do nothing and return FALSE.
|
||||
*
|
||||
* @return
|
||||
* TRUE, or FALSE in the event of an error.
|
||||
*
|
||||
* @see file_unmanaged_copy()
|
||||
* @see file_unmanaged_move()
|
||||
*/
|
||||
function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_EXISTS_RENAME) {
|
||||
$original_source = $source;
|
||||
$logger = \Drupal::logger('file');
|
||||
|
||||
// Assert that the source file actually exists.
|
||||
if (!file_exists($source)) {
|
||||
// @todo Replace drupal_set_message() calls with exceptions instead.
|
||||
drupal_set_message(t('The specified file %file could not be copied because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $original_source)), 'error');
|
||||
drupal_set_message(t('The specified file %file could not be moved/copied because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $original_source)), 'error');
|
||||
if (($realpath = drupal_realpath($original_source)) !== FALSE) {
|
||||
$logger->notice('File %file (%realpath) could not be copied because it does not exist.', array('%file' => $original_source, '%realpath' => $realpath));
|
||||
$logger->notice('File %file (%realpath) could not be moved/copied because it does not exist.', array('%file' => $original_source, '%realpath' => $realpath));
|
||||
}
|
||||
else {
|
||||
$logger->notice('File %file could not be copied because it does not exist.', array('%file' => $original_source));
|
||||
$logger->notice('File %file could not be moved/copied because it does not exist.', array('%file' => $original_source));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -463,8 +510,8 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
|
|||
$dirname = drupal_dirname($destination);
|
||||
if (!file_prepare_directory($dirname)) {
|
||||
// The destination is not valid.
|
||||
$logger->notice('File %file could not be copied because the destination directory %destination is not configured correctly.', array('%file' => $original_source, '%destination' => $dirname));
|
||||
drupal_set_message(t('The specified file %file could not be copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', array('%file' => $original_source)), 'error');
|
||||
$logger->notice('File %file could not be moved/copied because the destination directory %destination is not configured correctly.', array('%file' => $original_source, '%destination' => $dirname));
|
||||
drupal_set_message(t('The specified file %file could not be moved/copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', array('%file' => $original_source)), 'error');
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -472,8 +519,8 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
|
|||
// Determine whether we can perform this operation based on overwrite rules.
|
||||
$destination = file_destination($destination, $replace);
|
||||
if ($destination === FALSE) {
|
||||
drupal_set_message(t('The file %file could not be copied because a file by that name already exists in the destination directory.', array('%file' => $original_source)), 'error');
|
||||
$logger->notice('File %file could not be copied because a file by that name already exists in the destination directory (%destination)', array('%file' => $original_source, '%destination' => $destination));
|
||||
drupal_set_message(t('The file %file could not be moved/copied because a file by that name already exists in the destination directory.', array('%file' => $original_source)), 'error');
|
||||
$logger->notice('File %file could not be moved/copied because a file by that name already exists in the destination directory (%destination)', array('%file' => $original_source, '%destination' => $destination));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -481,26 +528,13 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
|
|||
$real_source = drupal_realpath($source);
|
||||
$real_destination = drupal_realpath($destination);
|
||||
if ($source == $destination || ($real_source !== FALSE) && ($real_source == $real_destination)) {
|
||||
drupal_set_message(t('The specified file %file was not copied because it would overwrite itself.', array('%file' => $source)), 'error');
|
||||
$logger->notice('File %file could not be copied because it would overwrite itself.', array('%file' => $source));
|
||||
drupal_set_message(t('The specified file %file was not moved/copied because it would overwrite itself.', array('%file' => $source)), 'error');
|
||||
$logger->notice('File %file could not be moved/copied because it would overwrite itself.', array('%file' => $source));
|
||||
return FALSE;
|
||||
}
|
||||
// Make sure the .htaccess files are present.
|
||||
file_ensure_htaccess();
|
||||
// Perform the copy operation.
|
||||
if (!@copy($source, $destination)) {
|
||||
// If the copy failed and realpaths exist, retry the operation using them
|
||||
// instead.
|
||||
if ($real_source === FALSE || $real_destination === FALSE || !@copy($real_source, $real_destination)) {
|
||||
$logger->error('The specified file %file could not be copied to %destination.', array('%file' => $source, '%destination' => $destination));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the permissions on the new file.
|
||||
drupal_chmod($destination);
|
||||
|
||||
return $destination;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -551,12 +585,24 @@ function file_destination($destination, $replace) {
|
|||
/**
|
||||
* Moves a file to a new location without database changes or hook invocation.
|
||||
*
|
||||
* This is a powerful function that in many ways performs like an advanced
|
||||
* version of rename().
|
||||
* - Checks if $source and $destination are valid and readable/writable.
|
||||
* - Checks that $source is not equal to $destination; if they are an error
|
||||
* is reported.
|
||||
* - If file already exists in $destination either the call will error out,
|
||||
* replace the file or rename the file based on the $replace parameter.
|
||||
* - Works around a PHP bug where rename() does not properly support streams if
|
||||
* safe_mode or open_basedir are enabled.
|
||||
* @see https://bugs.php.net/bug.php?id=60456
|
||||
*
|
||||
* @param $source
|
||||
* A string specifying the filepath or URI of the original file.
|
||||
* A string specifying the filepath or URI of the source file.
|
||||
* @param $destination
|
||||
* A string containing the destination that $source should be moved to.
|
||||
* This must be a stream wrapper URI. If this value is omitted, Drupal's
|
||||
* default files scheme will be used, usually "public://".
|
||||
* A URI containing the destination that $source should be moved to. The
|
||||
* URI may be a bare filepath (without a scheme) and in that case the default
|
||||
* scheme (file://) will be used. If this value is omitted, Drupal's default
|
||||
* files scheme will be used, usually "public://".
|
||||
* @param $replace
|
||||
* Replace behavior when the destination file already exists:
|
||||
* - FILE_EXISTS_REPLACE - Replace the existing file.
|
||||
|
@ -565,16 +611,37 @@ function file_destination($destination, $replace) {
|
|||
* - FILE_EXISTS_ERROR - Do nothing and return FALSE.
|
||||
*
|
||||
* @return
|
||||
* The URI of the moved file, or FALSE in the event of an error.
|
||||
* The path to the new file, or FALSE in the event of an error.
|
||||
*
|
||||
* @see file_move()
|
||||
*/
|
||||
function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
|
||||
$filepath = file_unmanaged_copy($source, $destination, $replace);
|
||||
if ($filepath == FALSE || file_unmanaged_delete($source) == FALSE) {
|
||||
if (!file_unmanaged_prepare($source, $destination, $replace)) {
|
||||
return FALSE;
|
||||
}
|
||||
return $filepath;
|
||||
// Ensure compatibility with Windows.
|
||||
// @see drupal_unlink()
|
||||
if ((substr(PHP_OS, 0, 3) == 'WIN') && (!file_stream_wrapper_valid_scheme(file_uri_scheme($source)))) {
|
||||
chmod($source, 0600);
|
||||
}
|
||||
// Attempt to resolve the URIs. This is necessary in certain configurations
|
||||
// (see above) and can also permit fast moves across local schemes.
|
||||
$real_source = drupal_realpath($source) ?: $source;
|
||||
$real_destination = drupal_realpath($destination) ?: $destination;
|
||||
// Perform the move operation.
|
||||
if (!@rename($real_source, $real_destination)) {
|
||||
// Fall back to slow copy and unlink procedure. This is necessary for
|
||||
// renames across schemes that are not local, or where rename() has not been
|
||||
// implemented. It's not necessary to use drupal_unlink() as the Windows
|
||||
// issue has already been resolved above.
|
||||
if (!@copy($real_source, $real_destination) || !@unlink($real_source)) {
|
||||
\Drupal::logger('file')->error('The specified file %file could not be moved to %destination.', array('%file' => $source, '%destination' => $destination));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
// Set the permissions on the new file.
|
||||
drupal_chmod($destination);
|
||||
return $destination;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1084,7 +1084,7 @@ function install_verify_completed_task() {
|
|||
* The site path.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if there are no database errors.
|
||||
* TRUE if there are no database errors.
|
||||
*/
|
||||
function install_verify_database_settings($site_path) {
|
||||
if ($database = Database::getConnectionInfo()) {
|
||||
|
|
|
@ -115,8 +115,8 @@ function drupal_install_profile_distribution_name() {
|
|||
* Loads the installation profile, extracting its defined version.
|
||||
*
|
||||
* @return string Distribution version defined in the profile's .info.yml file.
|
||||
* Defaults to \Drupal::VERSION if no version is explicitly provided
|
||||
* by the installation profile.
|
||||
* Defaults to \Drupal::VERSION if no version is explicitly provided
|
||||
* by the installation profile.
|
||||
*
|
||||
* @see install_profile_info()
|
||||
*/
|
||||
|
@ -139,7 +139,7 @@ function drupal_install_profile_distribution_version() {
|
|||
* Detects all supported databases that are compiled into PHP.
|
||||
*
|
||||
* @return
|
||||
* An array of database types compiled into PHP.
|
||||
* An array of database types compiled into PHP.
|
||||
*/
|
||||
function drupal_detect_database_types() {
|
||||
$databases = drupal_get_database_types();
|
||||
|
@ -724,7 +724,7 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
|
|||
* (optional) Whether to output messages. Defaults to TRUE.
|
||||
*
|
||||
* @return
|
||||
* TRUE/FALSE whether or not the directory was successfully created.
|
||||
* TRUE/FALSE whether or not the directory was successfully created.
|
||||
*/
|
||||
function drupal_install_mkdir($file, $mask, $message = TRUE) {
|
||||
$mod = 0;
|
||||
|
@ -773,7 +773,7 @@ function drupal_install_mkdir($file, $mask, $message = TRUE) {
|
|||
* (optional) Whether to output messages. Defaults to TRUE.
|
||||
*
|
||||
* @return
|
||||
* TRUE/FALSE whether or not we were able to fix the file's permissions.
|
||||
* TRUE/FALSE whether or not we were able to fix the file's permissions.
|
||||
*/
|
||||
function drupal_install_fix_file($file, $mask, $message = TRUE) {
|
||||
// If $file does not exist, fileperms() issues a PHP warning.
|
||||
|
|
|
@ -65,7 +65,7 @@ function update_check_incompatibility($name, $type = 'module') {
|
|||
* Returns whether the minimum schema requirement has been satisfied.
|
||||
*
|
||||
* @return array
|
||||
* A requirements info array.
|
||||
* A requirements info array.
|
||||
*/
|
||||
function update_system_schema_requirements() {
|
||||
$requirements = array();
|
||||
|
|
Reference in a new issue