- Patch #561520 by Pasqualle: is an object.

merge-requests/26/head
Dries Buytaert 2009-08-29 05:39:37 +00:00
parent 737bf95499
commit eca9c6cc16
1 changed files with 14 additions and 22 deletions

View File

@ -465,8 +465,7 @@ function file_load($fid) {
* @see hook_file_insert() * @see hook_file_insert()
* @see hook_file_update() * @see hook_file_update()
*/ */
function file_save($file) { function file_save(stdClass $file) {
$file = (object)$file;
$file->timestamp = REQUEST_TIME; $file->timestamp = REQUEST_TIME;
$file->filesize = filesize($file->uri); $file->filesize = filesize($file->uri);
@ -519,9 +518,7 @@ function file_save($file) {
* @see file_unmanaged_copy() * @see file_unmanaged_copy()
* @see hook_file_copy() * @see hook_file_copy()
*/ */
function file_copy($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) { function file_copy(stdClass $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
$source = (object)$source;
if ($uri = file_unmanaged_copy($source->uri, $destination, $replace)) { if ($uri = file_unmanaged_copy($source->uri, $destination, $replace)) {
$file = clone $source; $file = clone $source;
$file->fid = NULL; $file->fid = NULL;
@ -722,9 +719,7 @@ function file_destination($destination, $replace) {
* @see file_unmanaged_move() * @see file_unmanaged_move()
* @see hook_file_move() * @see hook_file_move()
*/ */
function file_move($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) { function file_move(stdClass $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
$source = (object)$source;
if ($uri = file_unmanaged_move($source->uri, $destination, $replace)) { if ($uri = file_unmanaged_move($source->uri, $destination, $replace)) {
$delete_source = FALSE; $delete_source = FALSE;
@ -914,9 +909,7 @@ function file_create_filename($basename, $directory) {
* @see hook_file_references() * @see hook_file_references()
* @see hook_file_delete() * @see hook_file_delete()
*/ */
function file_delete($file, $force = FALSE) { function file_delete(stdClass $file, $force = FALSE) {
$file = (object)$file;
// If any module returns a value from the reference hook, the file will not // If any module returns a value from the reference hook, the file will not
// be deleted from Drupal, but file_delete will return a populated array that // be deleted from Drupal, but file_delete will return a populated array that
// tests as TRUE. // tests as TRUE.
@ -1219,7 +1212,7 @@ function file_save_upload($source, $validators = array(), $destination = FALSE,
* *
* @see hook_file_validate() * @see hook_file_validate()
*/ */
function file_validate(&$file, $validators = array()) { function file_validate(stdClass &$file, $validators = array()) {
// Call the validation functions specified by this function's caller. // Call the validation functions specified by this function's caller.
$errors = array(); $errors = array();
foreach ($validators as $function => $args) { foreach ($validators as $function => $args) {
@ -1241,7 +1234,7 @@ function file_validate(&$file, $validators = array()) {
* @return * @return
* An array. If the file name is too long, it will contain an error message. * An array. If the file name is too long, it will contain an error message.
*/ */
function file_validate_name_length($file) { function file_validate_name_length(stdClass $file) {
$errors = array(); $errors = array();
if (empty($file->filename)) { if (empty($file->filename)) {
@ -1266,7 +1259,7 @@ function file_validate_name_length($file) {
* *
* @see hook_file_validate() * @see hook_file_validate()
*/ */
function file_validate_extensions($file, $extensions) { function file_validate_extensions(stdClass $file, $extensions) {
$errors = array(); $errors = array();
$regex = '/\.(' . preg_replace('/ +/', '|', preg_quote($extensions)) . ')$/i'; $regex = '/\.(' . preg_replace('/ +/', '|', preg_quote($extensions)) . ')$/i';
@ -1295,7 +1288,7 @@ function file_validate_extensions($file, $extensions) {
* *
* @see hook_file_validate() * @see hook_file_validate()
*/ */
function file_validate_size($file, $file_limit = 0, $user_limit = 0) { function file_validate_size(stdClass $file, $file_limit = 0, $user_limit = 0) {
global $user; global $user;
$errors = array(); $errors = array();
@ -1324,7 +1317,7 @@ function file_validate_size($file, $file_limit = 0, $user_limit = 0) {
* *
* @see hook_file_validate() * @see hook_file_validate()
*/ */
function file_validate_is_image($file) { function file_validate_is_image(stdClass $file) {
$errors = array(); $errors = array();
$info = image_get_info($file->uri); $info = image_get_info($file->uri);
@ -1359,7 +1352,7 @@ function file_validate_is_image($file) {
* *
* @see hook_file_validate() * @see hook_file_validate()
*/ */
function file_validate_image_resolution($file, $maximum_dimensions = 0, $minimum_dimensions = 0) { function file_validate_image_resolution(stdClass $file, $maximum_dimensions = 0, $minimum_dimensions = 0) {
$errors = array(); $errors = array();
// Check first that the file is an image. // Check first that the file is an image.
@ -1608,11 +1601,10 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
elseif ($depth >= $options['min_depth'] && preg_match($mask, $filename)) { elseif ($depth >= $options['min_depth'] && preg_match($mask, $filename)) {
// Always use this match over anything already set in $files with the // Always use this match over anything already set in $files with the
// same $$options['key']. // same $$options['key'].
$file = (object) array( $file = new StdClass;
'uri' => $uri, $file->uri = $uri;
'filename' => $filename, $file->filename = $filename;
'name' => pathinfo($filename, PATHINFO_FILENAME), $file->name = pathinfo($filename, PATHINFO_FILENAME);
);
$key = $options['key']; $key = $options['key'];
$files[$file->$key] = $file; $files[$file->$key] = $file;
if ($options['callback']) { if ($options['callback']) {