diff --git a/core/modules/file/file.install b/core/modules/file/file.install index 5d5f6c5..462e682 100644 --- a/core/modules/file/file.install +++ b/core/modules/file/file.install @@ -206,3 +206,124 @@ function file_requirements($phase) { return $requirements; } + +/** + * Implements hook_update_dependencies(). + */ +function file_update_dependencies() { + // Convert fields and instances to ConfigEntities after the {file_usage}.id + // column has moved to varchar. + $dependencies['field'][8003] = array( + 'file' => 8001, + ); + + // Convert the 'fid' column of file fields to 'target_id' after the field + // tables have been reorganized. + $dependencies['file'][8003] = array( + 'field' => 8006, + ); + return $dependencies; +} + +/** +* Converts default_file_main variable to config. +* +* @ingroup config_upgrade +*/ +function file_update_8000() { + update_variables_to_config('file.settings', array( + 'file_description_type' => 'description.type', + 'file_description_length' => 'description.length', + 'file_icon_directory' => 'icon.directory', + )); +} + +/* + * Convert the 'id' column in {file_usage} to accept UUIDs. + */ +function file_update_8001() { + $spec = array( + 'description' => 'The primary key of the object using the file.', + 'type' => 'varchar', + 'length' => 64, + 'not null' => TRUE, + 'default' => '', + ); + db_change_field('file_usage', 'id', 'id', $spec); +} + +/** + * Convert the 'module' column in {file_usage} to the maximum shortname length. + */ +function file_update_8002() { + if (db_field_exists('file_usage', 'module')) { + $spec = array( + 'description' => 'The name of the module that is using the file.', + 'type' => 'varchar', + 'length' => 50, + 'not null' => TRUE, + 'default' => '', + ); + db_change_field('file_usage', 'module', 'module', $spec); + } +} + +/** + * Update file field tables to use target_id instead of fid. + */ +function file_update_8003() { + foreach (config_get_storage_names_with_prefix('field.field.') as $config_name) { + $field_config = \Drupal::config($config_name); + // Only update file fields that use the default SQL storage. + if (in_array($field_config->get('type'), array('file', 'image'))) { + $field = new Field($field_config->get()); + + if (db_table_exists(FieldableDatabaseStorageController::_fieldTableName($field))) { + $tables = array( + FieldableDatabaseStorageController::_fieldTableName($field), + FieldableDatabaseStorageController::_fieldRevisionTableName($field), + ); + + foreach ($tables as $table_name) { + // Skip fields which were created during the upgrade process. + if (!db_field_exists($table_name, $field->name . '_fid')) { + continue 2; + } + + db_change_field($table_name, $field->name . '_fid', $field->name . '_target_id', array( + 'description' => 'The ID of the target entity.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + )); + + // Change the index. + db_drop_index($table_name, $field->name . '_fid'); + db_add_index($table_name, $field->name . '_target_id', array($field->name . '_target_id')); + } + + // Update the indexes in field config as well. + $indexes = $field_config->get('indexes'); + unset($indexes['fid']); + $indexes['target_id'] = array('target_id'); + $field_config->set('indexes', $indexes); + $field_config->save(); + } + } + } +} + +/* + * Convert the 'filesize' column in {file_managed} to a bigint. + */ +function file_update_8004() { + $spec = array( + 'description' => 'The size of the file in bytes.', + 'type' => 'int', + 'size' => 'big', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ); + db_change_field('file_managed', 'filesize', 'filesize', $spec); +} diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 6bf4d29..3e62397 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -23,15 +23,24 @@ function file_help($path, $arg) { case 'admin/help#file': $output = ''; $output .= '

' . t('About') . '

'; - $output .= '

' . t('The File module allows you to create fields that contain files. See the Field module help and the Field UI help pages for general information on fields and how to create and manage them. For more information, see the online documentation for the File module.', array('!field' => \Drupal::url('help.page', array('name' => 'field')), '!field_ui' => \Drupal::url('help.page', array('name' => 'field_ui')), '!file_documentation' => 'https://drupal.org/documentation/modules/file')) . '

'; + $output .= '

' . t('The File module allows you to create fields that contain files. See the Field module help and the Field UI help pages for general information on fields and how to create and manage them. For more information, see the online documentation for the File module.', + array( + '!field' => \Drupal::url('help.page', array('name' => 'field')), + '!field_ui' => \Drupal::url('help.page', array('name' => 'field_ui')), + '!file_documentation' => 'https://drupal.org/documentation/modules/file', + )) . '

'; $output .= '

' . t('Uses') . '

'; $output .= '
'; $output .= '
' . t('Managing and displaying file fields') . '
'; $output .= '
' . t('The settings and the display of the file field can be configured separately. See the Field UI help for more information on how to manage fields and their display.', array('!field_ui' => \Drupal::url('help.page', array('name' => 'field_ui')))) . '
'; $output .= '
' . t('Allowing file extensions') . '
'; $output .= '
' . t('In the field settings, you can define the allowed file extensions (for example pdf docx psd) for the files that will be uploaded with the file field.') . '
'; - $output .= '
' . t('Storing files ') . '
'; - $output .= '
' . t('Uploaded files can either be stored as public or private, depending on the File system settings. For more information, see the System module help page.', array('!file-system' => \Drupal::url('system.file_system_settings'), '!system-help' => \Drupal::url('help.page', array('name' => 'system')))) . '
'; + $output .= '
' . t('Storing files') . '
'; + $output .= '
' . t('Uploaded files can either be stored as public or private, depending on the File system settings. For more information, see the System module help page.', + array( + '!file-system' => \Drupal::url('system.file_system_settings'), + '!system-help' => \Drupal::url('help.page', array('name' => 'system')), + )) . '
'; $output .= '
' . t('Restricting the maximum file size') . '
'; $output .= '
' . t('The maximum file size that users can upload is limited by PHP settings of the server, but you can restrict by entering the desired value as the Maximum upload size setting. The maximum file size is automatically displayed to users in the help text of the file field.') . '
'; $output .= '
' . t('Displaying files and descriptions') . '
'; @@ -63,7 +72,7 @@ function file_element_info() { '#multiple' => FALSE, '#extended' => FALSE, '#attached' => array( - 'library' => array(array('file','drupal.file')), + 'library' => array(array('file', 'drupal.file')), ), ); return $types; @@ -74,7 +83,7 @@ function file_element_info() { * * @param array $fids * (optional) An array of entity IDs. If omitted, all entities are loaded. - * @param $reset + * @param bool $reset * Whether to reset the internal file_load_multiple() cache. * * @return array @@ -92,9 +101,9 @@ function file_load_multiple(array $fids = NULL, $reset = FALSE) { /** * Loads a single file entity from the database. * - * @param $fid + * @param int $fid * A file ID. - * @param $reset + * @param bool $reset * Whether to reset the internal file_load_multiple() cache. * * @return \Drupal\file\FileInterface @@ -114,6 +123,7 @@ function file_load($fid, $reset = FALSE) { * even better have the file usage service injected into your object. * * @return \Drupal\file\FileUsage\FileUsageInterface. + * A file entity. */ function file_usage() { return \Drupal::service('file.usage'); @@ -137,10 +147,10 @@ function file_usage() { * * @param \Drupal\file\File $source * A file entity. - * @param $destination + * @param string $destination * A string containing the destination that $source should be copied to. * This must be a stream wrapper URI. - * @param $replace + * @param string $replace * Replace behavior when the destination file already exists: * - FILE_EXISTS_REPLACE - Replace the existing file. If a managed file with * the destination name exists then its database entry will be updated. If @@ -149,7 +159,7 @@ function file_usage() { * unique. * - FILE_EXISTS_ERROR - Do nothing and return FALSE. * - * @return + * @return object * File object if the copy is successful, or FALSE in the event of an error. * * @see file_unmanaged_copy() @@ -158,7 +168,11 @@ function file_usage() { function file_copy(File $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) { if (!file_valid_uri($destination)) { if (($realpath = drupal_realpath($source->getFileUri())) !== FALSE) { - watchdog('file', 'File %file (%realpath) could not be copied because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', array('%file' => $source->getFileUri(), '%realpath' => $realpath, '%destination' => $destination)); + watchdog('file', 'File %file (%realpath) could not be copied because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', array( + '%file' => $source->getFileUri(), + '%realpath' => $realpath, + '%destination' => $destination, + )); } else { watchdog('file', 'File %file could not be copied because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', array('%file' => $source->getFileUri(), '%destination' => $destination)); @@ -209,10 +223,10 @@ function file_copy(File $source, $destination = NULL, $replace = FILE_EXISTS_REN * * @param \Drupal\file\File $source * A file entity. - * @param $destination + * @param string $destination * A string containing the destination that $source should be moved to. * This must be a stream wrapper URI. - * @param $replace + * @param string $replace * Replace behavior when the destination file already exists: * - FILE_EXISTS_REPLACE - Replace the existing file. If a managed file with * the destination name exists then its database entry will be updated and @@ -232,7 +246,11 @@ function file_copy(File $source, $destination = NULL, $replace = FILE_EXISTS_REN function file_move(File $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) { if (!file_valid_uri($destination)) { if (($realpath = drupal_realpath($source->getFileUri())) !== FALSE) { - watchdog('file', 'File %file (%realpath) could not be moved because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', array('%file' => $source->getFileUri(), '%realpath' => $realpath, '%destination' => $destination)); + watchdog('file', 'File %file (%realpath) could not be moved because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', array( + '%file' => $source->getFileUri(), + '%realpath' => $realpath, + '%destination' => $destination, + )); } else { watchdog('file', 'File %file could not be moved because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', array('%file' => $source->getFileUri(), '%destination' => $destination)); @@ -284,7 +302,7 @@ function file_move(File $source, $destination = NULL, $replace = FILE_EXISTS_REN * * @param \Drupal\file\File $file * A file entity. - * @param $validators + * @param array $validators * An optional, associative array of callback functions used to validate the * file. The keys are function names and the values arrays of callback * parameters which will be passed in after the file entity. The @@ -292,7 +310,7 @@ function file_move(File $source, $destination = NULL, $replace = FILE_EXISTS_REN * indicates that the file passed validation. The functions will be called in * the order specified. * - * @return + * @return array * An array containing validation error messages. * * @see hook_file_validate() @@ -317,7 +335,7 @@ function file_validate(File $file, $validators = array()) { * @param \Drupal\file\File $file * A file entity. * - * @return + * @return array * An array. If the file name is too long, it will contain an error message. */ function file_validate_name_length(File $file) { @@ -337,10 +355,10 @@ function file_validate_name_length(File $file) { * * @param \Drupal\file\File $file * A file entity. - * @param $extensions + * @param string $extensions * A string with a space separated list of allowed extensions. * - * @return + * @return array * An array. If the file extension is not allowed, it will contain an error * message. * @@ -361,14 +379,14 @@ function file_validate_extensions(File $file, $extensions) { * * @param \Drupal\file\File $file * A file entity. - * @param $file_limit + * @param int $file_limit * An integer specifying the maximum file size in bytes. Zero indicates that * no limit should be enforced. - * @param $user_limit + * @param int $user_limit * An integer specifying the maximum number of bytes the user is allowed. * Zero indicates that no limit should be enforced. * - * @return + * @return array * An array. If the file size exceeds limits, it will contain an error * message. * @@ -396,7 +414,7 @@ function file_validate_size(File $file, $file_limit = 0, $user_limit = 0) { * @param \Drupal\file\File $file * A file entity. * - * @return + * @return array * An array. If the file is not an image, it will contain an error message. * * @see hook_file_validate() @@ -425,16 +443,16 @@ function file_validate_is_image(File $file) { * * @param \Drupal\file\File $file * A file entity. This function may resize the file affecting its size. - * @param $maximum_dimensions + * @param string $maximum_dimensions * An optional string in the form WIDTHxHEIGHT e.g. '640x480' or '85x85'. If * an image toolkit is installed the image will be resized down to these * dimensions. A value of 0 indicates no restriction on size, so resizing * will be attempted. - * @param $minimum_dimensions + * @param string $minimum_dimensions * An optional string in the form WIDTHxHEIGHT. This will check that the * image meets a minimum size. A value of 0 indicates no restriction. * - * @return + * @return array * An array. If the file is an image and did not meet the requirements, it * will contain an error message. * @@ -480,13 +498,13 @@ function file_validate_image_resolution(File $file, $maximum_dimensions = 0, $mi /** * Saves a file to the specified destination and creates a database entry. * - * @param $data + * @param string $data * A string containing the contents of the file. - * @param $destination + * @param string $destination * A string containing the destination URI. This must be a stream wrapper URI. * If no value is provided, a randomized name will be generated and the file * will be saved using Drupal's default files scheme, usually "public://". - * @param $replace + * @param string $replace * Replace behavior when the destination file already exists: * - FILE_EXISTS_REPLACE - Replace the existing file. If a managed file with * the destination name exists then its database entry will be updated. If @@ -546,7 +564,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM * @param \Drupal\file\File $file * A file entity. * - * @return + * @return array * An associative array of headers, as expected by * \Symfony\Component\HttpFoundation\StreamedResponse. */ @@ -567,10 +585,18 @@ function file_theme() { return array( // file.module. 'file_link' => array( - 'variables' => array('file' => NULL, 'icon_directory' => NULL, 'description' => NULL, 'attributes' => array()), + 'variables' => array( + 'file' => NULL, + 'icon_directory' => NULL, + 'description' => NULL, + 'attributes' => array(), + ), ), 'file_icon' => array( - 'variables' => array('file' => NULL, 'icon_directory' => NULL), + 'variables' => array( + 'file' => NULL, + 'icon_directory' => NULL, + ), ), 'file_managed_file' => array( 'render element' => 'element', @@ -587,7 +613,11 @@ function file_theme() { 'variables' => array('items' => NULL), ), 'file_upload_help' => array( - 'variables' => array('description' => NULL, 'upload_validators' => NULL, 'cardinality' => NULL), + 'variables' => array( + 'description' => NULL, + 'upload_validators' => NULL, + 'cardinality' => NULL, + ), ), ); } @@ -652,7 +682,9 @@ function file_file_download($uri, $field_type = 'file') { // Default to FALSE and let entities overrule this ruling. $grants = array('system' => FALSE); foreach (\Drupal::moduleHandler()->getImplementations('file_download_access') as $module) { - $grants = array_merge($grants, array($module => module_invoke($module, 'file_download_access', $field, $entity, $file))); + $grants = array_merge($grants, array( + $module => module_invoke($module, 'file_download_access', $field, $entity, $file), + )); } // Allow other modules to alter the returned grants/denies. $context = array( @@ -690,7 +722,7 @@ function file_file_download($uri, $field_type = 'file') { } /** - * Implements file_cron() + * Implements file_cron(). */ function file_cron() { $result = \Drupal::entityManager()->getStorageController('file')->retrieveTemporaryFiles(); @@ -706,7 +738,11 @@ function file_cron() { } } else { - watchdog('file system', 'Did not delete temporary file "%path" during garbage collection because it is in use by the following modules: %modules.', array('%path' => $file->getFileUri(), '%modules' => implode(', ', array_keys($references))), WATCHDOG_INFO); + watchdog('file system', 'Did not delete temporary file "%path" during garbage collection because it is in use by the following modules: %modules.', + array( + '%path' => $file->getFileUri(), + '%modules' => implode(', ', array_keys($references)), + ), WATCHDOG_INFO); } } } @@ -719,12 +755,12 @@ function file_cron() { * Temporary files are periodically cleaned. Use the 'file.usage' service to * register the usage of the file which will automatically mark it as permanent. * - * @param $form_field_name + * @param string $form_field_name * A string that is the associative array key of the upload form element in * the form array. * @param array $form_state * An associative array containing the current state of the form. - * @param $validators + * @param array $validators * An optional, associative array of callback functions used to validate the * file. See file_validate() for a full discussion of the array format. * If no extension validator is provided it will default to a limited safe @@ -733,20 +769,20 @@ function file_cron() { * explicitly set the 'file_validate_extensions' validator to an empty array * (Beware: this is not safe and should only be allowed for trusted users, if * at all). - * @param $destination + * @param string $destination * A string containing the URI that the file should be copied to. This must * be a stream wrapper URI. If this value is omitted, Drupal's temporary * files scheme will be used ("temporary://"). - * @param $delta + * @param int $delta * Delta of the file to save or NULL to save all files. Defaults to NULL. - * @param $replace + * @param string $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 + * @return array * Function returns array of files or a single file object if $delta * != NULL. Each file object contains the file information if the * upload succeeded or FALSE in the event of an error. Function @@ -809,8 +845,6 @@ function file_save_upload($form_field_name, array &$form_state, $validators = ar if (is_uploaded_file($file_info->getRealPath())) { break; } - - // Unknown error default: drupal_set_message(t('The file %file could not be saved. An unknown error has occurred.', array('%file' => $file_info->getFilename())), 'error'); $files[$i] = FALSE; @@ -836,8 +870,8 @@ function file_save_upload($form_field_name, array &$form_state, $validators = ar } else { // If 'file_validate_extensions' is set and the list is empty then the - // caller wants to allow any extension. In this case we have to remove the - // validator or else it will reject all extensions. + // caller wants to allow any extension. In this case we have to + // remove the validator or else it will reject all extensions. unset($validators['file_validate_extensions']); } } @@ -863,8 +897,8 @@ function file_save_upload($form_field_name, array &$form_state, $validators = ar $file->setMimeType('text/plain'); // The destination filename will also later be used to create the URI. $file->setFilename($file->getFilename() . '.txt'); - // The .txt extension may not be in the allowed list of extensions. We have - // to add it here or else the file upload will fail. + // The .txt extension may not be in the allowed list of extensions. + // We have to add it here or else the file upload will fail. if (!empty($extensions)) { $validators['file_validate_extensions'][0] .= ' txt'; drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $file->getFilename()))); @@ -890,8 +924,8 @@ function file_save_upload($form_field_name, array &$form_state, $validators = ar $destination .= '/'; } $file->destination = file_destination($destination . $file->getFilename(), $replace); - // If file_destination() returns FALSE then $replace === FILE_EXISTS_ERROR and - // there's an existing file so we need to bail. + // If file_destination() returns FALSE then $replace === FILE_EXISTS_ERROR + // and there's an existing file so we need to bail. if ($file->destination === FALSE) { drupal_set_message(t('The file %source could not be uploaded because a file by that name already exists in the destination %directory.', array('%source' => $form_field_name, '%directory' => $destination)), 'error'); $files[$i] = FALSE; @@ -959,7 +993,7 @@ function file_save_upload($form_field_name, array &$form_state, $validators = ar /** * Determines the preferred upload progress implementation. * - * @return + * @return string * A string indicating which upload progress system is available. Either "apc" * or "uploadprogress". If neither are available, returns FALSE. */ @@ -1016,7 +1050,7 @@ function file_tokens($type, $tokens, array $data = array(), array $options = arr $replacements[$original] = $file->id(); break; - // Essential file data + // Essential file data. case 'name': $replacements[$original] = $sanitize ? check_plain($file->getFilename()) : $file->getFilename(); break; @@ -1037,7 +1071,8 @@ function file_tokens($type, $tokens, array $data = array(), array $options = arr $replacements[$original] = $sanitize ? check_plain(file_create_url($file->getFileUri())) : file_create_url($file->getFileUri()); break; - // These tokens are default variations on the chained tokens handled below. + // These tokens are default variations on the chained tokens + // handled below. case 'created': $replacements[$original] = format_date($file->getCreatedTime(), 'medium', '', NULL, $langcode); break; @@ -1266,8 +1301,10 @@ function file_managed_file_process($element, &$form_state, $form) { $element['upload']['#attached']['js'] = array( array( 'type' => 'setting', - 'data' => array('file' => array('elements' => array('#' . $element['#id'] => $extension_list))) - ) + 'data' => array( + 'file' => array('elements' => array('#' . $element['#id'] . '-upload' => $extension_list)), + ), + ), ); } @@ -1430,8 +1467,8 @@ function file_managed_file_submit($form, &$form_state) { foreach ($remove_fids as $fid) { // If it's a temporary file we can safely remove it immediately, otherwise - // it's up to the implementing module to remove usages of files to have them - // removed. + // it's up to the implementing module to remove usages of files + // to have them removed. if ($element['#files'][$fid] && $element['#files'][$fid]->isTemporary()) { $element['#files'][$fid]->delete(); } @@ -1459,12 +1496,12 @@ function file_managed_file_submit($form, &$form_state) { /** * Saves any files that have been uploaded into a managed_file element. * - * @param $element + * @param string $element * The FAPI element whose values are being saved. * @param array $form_state * An associative array containing the current state of the form. * - * @return + * @return array * An array of file entities for each file that was saved, keyed by its file * ID, or FALSE if no files were saved. */ @@ -1494,7 +1531,9 @@ function file_managed_file_save_upload($element, array &$form_state) { // Value callback expects FIDs to be keys. $files = array_filter($files); - $fids = array_map(function($file) { return $file->id(); }, $files); + $fids = array_map(function($file) { + return $file->id(); + }, $files); return empty($files) ? array() : array_combine($fids, $files); } @@ -1505,7 +1544,7 @@ function file_managed_file_save_upload($element, array &$form_state) { /** * Returns HTML for a managed file element. * - * @param $variables + * @param array $variables * An associative array containing: * - element: A render element representing the file. * @@ -1569,7 +1608,7 @@ function file_managed_file_pre_render($element) { /** * Returns HTML for a link to a file. * - * @param $variables + * @param array $variables * An associative array containing: * - file: A file object to which the link will be created. * - icon_directory: (optional) A path to a directory of icons to be used for @@ -1611,7 +1650,7 @@ function theme_file_link($variables) { /** * Returns HTML for an image with an appropriate icon for the given file. * - * @param $variables + * @param array $variables * An associative array containing: * - file: A file entity for which to make an icon. * - icon_directory: (optional) A path to a directory of icons to be used for @@ -1634,11 +1673,11 @@ function theme_file_icon($variables) { * * @param \Drupal\file\File $file * A file entity. - * @param $icon_directory + * @param string $icon_directory * (optional) A path to a directory of icons to be used for files. Defaults to * the value of the "icon.directory" variable. * - * @return + * @return string * A URL string to the icon, or FALSE if an appropriate icon cannot be found. */ function file_icon_url(File $file, $icon_directory = NULL) { @@ -1653,11 +1692,11 @@ function file_icon_url(File $file, $icon_directory = NULL) { * * @param \Drupal\file\File $file * A file entity. - * @param $icon_directory + * @param string $icon_directory * (optional) A path to a directory of icons to be used for files. Defaults to * the value of the "icon.directory" variable. * - * @return + * @return string * A string to the icon as a local path, or FALSE if an appropriate icon could * not be found. */ @@ -1707,7 +1746,7 @@ function file_icon_path(File $file, $icon_directory = NULL) { * @param \Drupal\file\File $file * A file entity. * - * @return + * @return MIME * The generic icon MIME package expected for this file. */ function file_icon_map(File $file) { @@ -1838,22 +1877,22 @@ function file_icon_map(File $file) { * * @param \Drupal\file\File $file * A file entity. - * @param $field + * @param array $field * (optional) A field array to be used for this check. If given, limits the * reference check to the given field. - * @param $age + * @param int $age * (optional) A constant that specifies which references to count. Use * EntityStorageControllerInterface::FIELD_LOAD_REVISION to retrieve all * references within all revisions or * EntityStorageControllerInterface::FIELD_LOAD_CURRENT to retrieve references * only in the current revisions. - * @param $field_type + * @param string $field_type * (optional) The name of a field type. If given, limits the reference check * to fields of the given type. If both $field and $field_type is given but * $field is not the same type as $field_type, an empty array will be * returned. * - * @return + * @return array * A multidimensional array. The keys are field_name, entity_type, * entity_id and the value is an entity referencing this file. */ @@ -1945,7 +1984,7 @@ function file_library_info() { drupal_get_path('module', 'file') . '/file.js' => array(), ), 'css' => array( - drupal_get_path('module', 'file') . '/css/file.admin.css' + drupal_get_path('module', 'file') . '/css/file.admin.css', ), 'dependencies' => array( array('system', 'jquery'), @@ -1964,9 +2003,7 @@ function file_permission() { $perms = array( 'access files overview' => array( 'title' => t('Access the Files overview page'), - 'description' => user_access('access files overview') - ? t('Get an overview of all files.', array('@url' => url('admin/content/files'))) - : t('Get an overview of all files.'), + 'description' => user_access('access files overview') ? t('Get an overview of all files.', array('@url' => url('admin/content/files'))) : t('Get an overview of all files.'), ), ); @@ -1978,6 +2015,7 @@ function file_permission() { * * @param int $choice * integer Status code. + * * @return string * string Text-represented file status. */ diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php index bf80c17..c8e2af3 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php @@ -130,7 +130,7 @@ function testMultiValuedWidget() { // - First remove the 2nd file. // - Then remove what is then the 2nd file (was originally the 3rd file). // - Then remove the first file. - foreach (array(1,1,0) as $delta) { + foreach (array(1, 1, 0) as $delta) { // Ensure we have the expected number of Remove buttons, and that they // are numbered sequentially. $buttons = $this->xpath('//input[@type="submit" and @value="Remove"]'); @@ -142,7 +142,7 @@ function testMultiValuedWidget() { $check_field_name = $field_name; } - $this->assertIdentical((string) $button['name'], $check_field_name . '_' . $key. '_remove_button'); + $this->assertIdentical((string) $button['name'], $check_field_name . '_' . $key . '_remove_button'); } // "Click" the remove button (emulating either a nojs or js submission).