diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-06-18 03:36:24 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-06-18 03:36:24 +0000 |
commit | 6e2358b23208ef7e2119d95b0cea1537d9a863c8 (patch) | |
tree | b8bf1811f88615c35d40c540c3070269cc9ed1e6 /includes | |
parent | 0889c01d21ded9b07b117868d12b1032d7c9317c (diff) | |
download | brdo-6e2358b23208ef7e2119d95b0cea1537d9a863c8.tar.gz brdo-6e2358b23208ef7e2119d95b0cea1537d9a863c8.tar.bz2 |
- Patch #270045 by drewish, Susurrus: clean up return values.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/batch.inc | 6 | ||||
-rw-r--r-- | includes/cache.inc | 5 | ||||
-rw-r--r-- | includes/common.inc | 6 | ||||
-rw-r--r-- | includes/file.inc | 38 | ||||
-rw-r--r-- | includes/path.inc | 2 | ||||
-rw-r--r-- | includes/unicode.inc | 4 |
6 files changed, 31 insertions, 30 deletions
diff --git a/includes/batch.inc b/includes/batch.inc index 798d2b3eb..c489f9301 100644 --- a/includes/batch.inc +++ b/includes/batch.inc @@ -179,7 +179,7 @@ function _batch_process() { include_once($current_set['file']); } - $finished = 1; + $finished = TRUE; $task_message = ''; if ((list($function, $args) = reset($current_set['operations'])) && function_exists($function)) { // Build the 'context' array, execute the function call, @@ -189,9 +189,9 @@ function _batch_process() { call_user_func_array($function, array_merge($args, array(&$batch_context))); } - if ($finished == 1) { + if ($finished == TRUE) { // Make sure this step isn't counted double when computing $current. - $finished = 0; + $finished = FALSE; // Remove the operation and clear the sandbox. array_shift($current_set['operations']); $current_set['sandbox'] = array(); diff --git a/includes/cache.inc b/includes/cache.inc index 06b03fe2c..e21346a9e 100644 --- a/includes/cache.inc +++ b/includes/cache.inc @@ -10,6 +10,7 @@ * @param $table * The table $table to store the data in. Valid core values are 'cache_filter', * 'cache_menu', 'cache_page', or 'cache' for the default cache. + * @return The cache or FALSE on failure. */ function cache_get($cid, $table = 'cache') { global $user; @@ -41,7 +42,7 @@ function cache_get($cid, $table = 'cache') { else { if ($user->cache > $cache->created) { // This cache data is too old and thus not valid for us, ignore it. - return 0; + return FALSE; } else { $cache->data = db_decode_blob($cache->data); @@ -52,7 +53,7 @@ function cache_get($cid, $table = 'cache') { } return $cache; } - return 0; + return FALSE; } /** diff --git a/includes/common.inc b/includes/common.inc index 883371ff4..3296d98c1 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -819,7 +819,7 @@ function valid_email_address($mail) { $ipv4 = '[0-9]{1,3}(\.[0-9]{1,3}){3}'; $ipv6 = '[0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7}'; - return preg_match("/^$user@($domain|(\[($ipv4|$ipv6)\]))$/", $mail); + return (bool)preg_match("/^$user@($domain|(\[($ipv4|$ipv6)\]))$/", $mail); } /** @@ -838,10 +838,10 @@ function valid_email_address($mail) { function valid_url($url, $absolute = FALSE) { $allowed_characters = '[a-z0-9\/:_\-_\.\?\$,;~=#&%\+]'; if ($absolute) { - return preg_match("/^(http|https|ftp):\/\/" . $allowed_characters . "+$/i", $url); + return (bool)preg_match("/^(http|https|ftp):\/\/" . $allowed_characters . "+$/i", $url); } else { - return preg_match("/^" . $allowed_characters . "+$/i", $url); + return (bool)preg_match("/^" . $allowed_characters . "+$/i", $url); } } diff --git a/includes/file.inc b/includes/file.inc index a01fad778..2de64c10b 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -214,7 +214,7 @@ function file_check_path(&$path) { * * @param $source A string set to the file to check. * @param $directory A string where the file should be located. - * @return 0 for invalid path or the real path of the source. + * @return FALSE for invalid path or the real path of the source. */ function file_check_location($source, $directory = '') { $check = realpath($source); @@ -227,7 +227,7 @@ function file_check_location($source, $directory = '') { } $directory = realpath($directory); if ($directory && strpos($source, $directory) !== 0) { - return 0; + return FALSE; } return $source; } @@ -262,7 +262,7 @@ function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { $source = is_object($source) ? $source->filepath : $source; drupal_set_message(t('The selected file %file could not be uploaded, because the destination %directory is not properly configured.', array('%file' => $source, '%directory' => $dest)), 'error'); watchdog('file system', 'The selected file %file could not be uploaded, because the destination %directory could not be found, or because its permissions do not allow the file to be written.', array('%file' => $source, '%directory' => $dest), WATCHDOG_ERROR); - return 0; + return FALSE; } // Process a file upload object. @@ -277,7 +277,7 @@ function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { $source = realpath($source); if (!file_exists($source)) { drupal_set_message(t('The selected file %file could not be copied, because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $source)), 'error'); - return 0; + return FALSE; } // If the destination file is not specified then use the filename of the source file. @@ -295,7 +295,7 @@ function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { if (!@copy($source, $dest)) { drupal_set_message(t('The selected file %file could not be copied.', array('%file' => $source)), 'error'); - return 0; + return FALSE; } // Give everyone read access so that FTP'd users or @@ -314,7 +314,7 @@ function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { $source = $dest; } - return 1; // Everything went ok. + return TRUE; // Everything went ok. } /** @@ -363,7 +363,7 @@ function file_destination($destination, $replace) { * - 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 for success, FALSE for failure. + * @return TRUE for success, FALSE for failure. */ function file_move(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { $path_original = is_object($source) ? $source->filepath : $source; @@ -372,11 +372,11 @@ function file_move(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { $path_current = is_object($source) ? $source->filepath : $source; if ($path_original == $path_current || file_delete($path_original)) { - return 1; + return TRUE; } drupal_set_message(t('The removal of the original file %file has failed.', array('%file' => $path_original)), 'error'); } - return 0; + return FALSE; } /** @@ -513,7 +513,7 @@ function file_space_used($uid = NULL) { * destination directory should overwritten. A false value will generate a * new, unique filename in the destination directory. * @return - * An object containing the file information, or 0 in the event of an error. + * An object containing the file information, or FALSE in the event of an error. */ function file_save_upload($source, $validators = array(), $dest = FALSE, $replace = FILE_EXISTS_RENAME) { global $user; @@ -540,17 +540,17 @@ function file_save_upload($source, $validators = array(), $dest = FALSE, $replac case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: drupal_set_message(t('The file %file could not be saved, because it exceeds %maxsize, the maximum allowed size for uploads.', array('%file' => $source, '%maxsize' => format_size(file_upload_max_size()))), 'error'); - return 0; + return FALSE; case UPLOAD_ERR_PARTIAL: case UPLOAD_ERR_NO_FILE: drupal_set_message(t('The file %file could not be saved, because the upload did not complete.', array('%file' => $source)), 'error'); - return 0; + return FALSE; // Unknown error default: drupal_set_message(t('The file %file could not be saved. An unknown error has occurred.', array('%file' => $source)), 'error'); - return 0; + return FALSE; } // Build the list of non-munged extensions. @@ -601,7 +601,7 @@ function file_save_upload($source, $validators = array(), $dest = FALSE, $replac $message .= ' ' . array_pop($errors); } form_set_error($source, $message); - return 0; + return FALSE; } // Move uploaded files from PHP's upload_tmp_dir to Drupal's temporary directory. @@ -610,7 +610,7 @@ function file_save_upload($source, $validators = array(), $dest = FALSE, $replac if (!move_uploaded_file($_FILES['files']['tmp_name'][$source], $file->filepath)) { form_set_error($source, t('File upload error. Could not move uploaded file.')); watchdog('file', 'Upload error. Could not move uploaded file %file to destination %destination.', array('%file' => $file->filename, '%destination' => $file->filepath)); - return 0; + return FALSE; } // If we made it this far it's safe to record this file in the database. @@ -623,7 +623,7 @@ function file_save_upload($source, $validators = array(), $dest = FALSE, $replac $upload_cache[$source] = $file; return $file; } - return 0; + return FALSE; } /** @@ -786,7 +786,7 @@ function file_validate_image_resolution(&$file, $maximum_dimensions = 0, $minimu * - FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique * - FILE_EXISTS_ERROR - Do nothing and return FALSE. * - * @return A string containing the resulting filename or 0 on error + * @return A string containing the resulting filename or FALSE on error */ function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) { $temp = file_directory_temp(); @@ -794,13 +794,13 @@ function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) { $file = tempnam(realpath($temp), 'file'); if (!$fp = fopen($file, 'wb')) { drupal_set_message(t('The file could not be created.'), 'error'); - return 0; + return FALSE; } fwrite($fp, $data); fclose($fp); if (!file_move($file, $dest, $replace)) { - return 0; + return FALSE; } return $file; diff --git a/includes/path.inc b/includes/path.inc index 8f2939c33..fd1e3448d 100644 --- a/includes/path.inc +++ b/includes/path.inc @@ -233,5 +233,5 @@ function drupal_match_path($path, $patterns) { if (!isset($regexps[$patterns])) { $regexps[$patterns] = '/^(' . preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\2'), preg_quote($patterns, '/')) . ')$/'; } - return preg_match($regexps[$patterns], $path); + return (bool)preg_match($regexps[$patterns], $path); } diff --git a/includes/unicode.inc b/includes/unicode.inc index cb3b0a8fc..93a522d09 100644 --- a/includes/unicode.inc +++ b/includes/unicode.inc @@ -121,7 +121,7 @@ function unicode_requirements() { * @param &$data * The XML data which will be parsed later. * @return - * An XML parser object. + * An XML parser object or FALSE on error. */ function drupal_xml_parser_create(&$data) { // Default XML encoding is UTF-8 @@ -149,7 +149,7 @@ function drupal_xml_parser_create(&$data) { } else { watchdog('php', 'Could not convert XML encoding %s to UTF-8.', array('%s' => $encoding), WATCHDOG_WARNING); - return 0; + return FALSE; } } |