diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-02-22 17:55:30 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-02-22 17:55:30 +0000 |
commit | 5d658d08481c22b5ef577b39a29cd647438b211f (patch) | |
tree | 74fca69f981d985604b126943aed71bb79d1bbcb | |
parent | b3e36d655c831c63c26a710eb3c8bd82ca3b6fc5 (diff) | |
download | brdo-5d658d08481c22b5ef577b39a29cd647438b211f.tar.gz brdo-5d658d08481c22b5ef577b39a29cd647438b211f.tar.bz2 |
- Patch #380064 by c960657: make file_scan_directory() use save property names as file_load().
-rw-r--r-- | includes/file.inc | 39 | ||||
-rw-r--r-- | includes/install.inc | 10 | ||||
-rw-r--r-- | includes/locale.inc | 29 | ||||
-rw-r--r-- | includes/module.inc | 26 | ||||
-rw-r--r-- | includes/registry.inc | 2 | ||||
-rw-r--r-- | includes/theme.inc | 6 | ||||
-rw-r--r-- | install.php | 4 | ||||
-rw-r--r-- | modules/blogapi/blogapi.test | 2 | ||||
-rw-r--r-- | modules/simpletest/drupal_web_test_case.php | 6 | ||||
-rw-r--r-- | modules/simpletest/simpletest.install | 2 | ||||
-rw-r--r-- | modules/simpletest/simpletest.module | 2 | ||||
-rw-r--r-- | modules/simpletest/tests/file.test | 36 | ||||
-rw-r--r-- | modules/system/system.module | 16 | ||||
-rw-r--r-- | modules/update/update.compare.inc | 2 | ||||
-rw-r--r-- | modules/upload/upload.test | 10 | ||||
-rw-r--r-- | modules/user/user.test | 24 |
16 files changed, 109 insertions, 107 deletions
diff --git a/includes/file.inc b/includes/file.inc index 878c1789b..7ffefe1f9 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -1395,9 +1395,9 @@ function file_download() { * the provided directory. Defaults to TRUE. * - 'key' * The key to be used for the returned array of files. Possible values are - * "filename", for the path starting with $dir, "basename", for the - * basename of the file, and "name" for the name of the file without an - * extension. Defaults to 'filename'. + * 'filepath', for the path starting with $dir, 'filename', for the + * basename of the file, and 'name' for the name of the file without an + * extension. Defaults to 'filepath'. * - 'min_depth' * Minimum depth of directories to return files from. Defaults to 0. * @param $depth @@ -1405,8 +1405,8 @@ function file_download() { * should not be passed. * @return * An associative array (keyed on the provided key) of objects with - * "filename", "basename", and "name" members corresponding to the - * matching files. + * 'filepath', 'filename', and 'name' members corresponding to the + * matching files. */ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) { // Merge in defaults. @@ -1414,33 +1414,32 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) { 'nomask' => '/(\.\.?|CVS)$/', 'callback' => 0, 'recurse' => TRUE, - 'key' => 'filename', + 'key' => 'filepath', 'min_depth' => 0, ); - $options['key'] = (in_array($options['key'], array('filename', 'basename', 'name')) ? $options['key'] : 'filename'); + $options['key'] = in_array($options['key'], array('filepath', 'filename', 'name')) ? $options['key'] : 'filepath'; $files = array(); - if (is_dir($dir) && $handle = opendir($dir)) { - while (FALSE !== ($file = readdir($handle))) { - if (!preg_match($options['nomask'], $file) && $file[0] != '.') { - if (is_dir("$dir/$file") && $options['recurse']) { + while (FALSE !== ($filename = readdir($handle))) { + if (!preg_match($options['nomask'], $filename) && $filename[0] != '.') { + $filepath = "$dir/$filename"; + if (is_dir($filepath) && $options['recurse']) { // Give priority to files in this folder by merging them in after any subdirectory files. - $files = array_merge(file_scan_directory("$dir/$file", $mask, $options, $depth + 1), $files); + $files = array_merge(file_scan_directory($filepath, $mask, $options, $depth + 1), $files); } - elseif ($depth >= $options['min_depth'] && preg_match($mask, $file)) { + elseif ($depth >= $options['min_depth'] && preg_match($mask, $filename)) { // Always use this match over anything already set in $files with the // same $$options['key']. - $filename = "$dir/$file"; - $basename = basename($file); - $name = substr($basename, 0, strrpos($basename, '.')); - $files[${$options['key']}] = (object) array( + $file = (object) array( + 'filepath' => $filepath, 'filename' => $filename, - 'basename' => $basename, - 'name' => $name, + 'name' => pathinfo($filename, PATHINFO_FILENAME), ); + $key = $options['key']; + $files[$file->$key] = $file; if ($options['callback']) { - $options['callback']($filename); + $options['callback']($filepath); } } } diff --git a/includes/install.inc b/includes/install.inc index 36d1b6bcb..125989679 100644 --- a/includes/install.inc +++ b/includes/install.inc @@ -216,9 +216,9 @@ function drupal_detect_database_types() { // file for the driver explicitly. foreach (file_scan_directory(DRUPAL_ROOT . '/includes/database', '/^[a-z]*$/i', array('recurse' => FALSE)) as $file) { - include_once "{$file->filename}/install.inc"; - include_once "{$file->filename}/database.inc"; - $drivers[$file->basename] = $file->filename; + include_once "{$file->filepath}/install.inc"; + include_once "{$file->filepath}/database.inc"; + $drivers[$file->filename] = $file->filepath; } foreach ($drivers as $driver => $file) { @@ -934,7 +934,7 @@ function drupal_check_profile($profile) { // Collect requirement testing results $requirements = array(); foreach ($installs as $install) { - require_once DRUPAL_ROOT . '/' . $install->filename; + require_once DRUPAL_ROOT . '/' . $install->filepath; $function = $install->name. '_requirements'; if (function_exists($function)) { $requirements = array_merge($requirements, $function('install')); @@ -974,7 +974,7 @@ function drupal_check_module($module) { // Include install file $install = drupal_get_install_files(array($module)); if (isset($install[$module])) { - require_once DRUPAL_ROOT . '/' . $install[$module]->filename; + require_once DRUPAL_ROOT . '/' . $install[$module]->filepath; // Check requirements $requirements = module_invoke($module, 'requirements', 'install'); diff --git a/includes/locale.inc b/includes/locale.inc index 10e9729bf..322b5f7d1 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -2675,20 +2675,21 @@ function _locale_batch_build($files, $finished = NULL, $components = array()) { $operations = array(); foreach ($files as $file) { // We call _locale_batch_import for every batch operation. - $operations[] = array('_locale_batch_import', array($file->filename)); } - $batch = array( - 'operations' => $operations, - 'title' => $t('Importing interface translations'), - 'init_message' => $t('Starting import'), - 'error_message' => $t('Error importing interface translations'), - 'file' => 'includes/locale.inc', - // This is not a batch API construct, but data passed along to the - // installer, so we know what did we import already. - '#components' => $components, - ); - if (isset($finished)) { - $batch['finished'] = $finished; - } + $operations[] = array('_locale_batch_import', array($file->filepath)); + } + $batch = array( + 'operations' => $operations, + 'title' => $t('Importing interface translations'), + 'init_message' => $t('Starting import'), + 'error_message' => $t('Error importing interface translations'), + 'file' => 'includes/locale.inc', + // This is not a batch API construct, but data passed along to the + // installer, so we know what did we import already. + '#components' => $components, + ); + if (isset($finished)) { + $batch['finished'] = $finished; + } return $batch; } return FALSE; diff --git a/includes/module.inc b/includes/module.inc index ca5388e57..71db71f57 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -101,41 +101,41 @@ function module_rebuild_cache() { 'files' => array(), ); - foreach ($files as $filename => $file) { + foreach ($files as $filepath => $file) { // Look for the info file. - $file->info = drupal_parse_info_file(dirname($file->filename) . '/' . $file->name . '.info'); + $file->info = drupal_parse_info_file(dirname($file->filepath) . '/' . $file->name . '.info'); // Skip modules that don't provide info. if (empty($file->info)) { - unset($files[$filename]); + unset($files[$filepath]); continue; } // Merge in defaults and save. - $files[$filename]->info = $file->info + $defaults; + $files[$filepath]->info = $file->info + $defaults; // Invoke hook_system_info_alter() to give installed modules a chance to // modify the data in the .info files if necessary. - drupal_alter('system_info', $files[$filename]->info, $files[$filename]); + drupal_alter('system_info', $files[$filepath]->info, $files[$filepath]); // Update the contents of the system table: - if (isset($file->status) || (isset($file->old_filename) && $file->old_filename != $file->filename)) { + if (isset($file->status) || (isset($file->old_filepath) && $file->old_filepath != $file->filepath)) { db_update('system') ->fields(array( - 'info' => serialize($files[$filename]->info), + 'info' => serialize($files[$filepath]->info), 'name' => $file->name, - 'filename' => $file->filename)) - ->condition('filename', $file->old_filename) + 'filename' => $file->filepath)) + ->condition('filename', $file->old_filepath) ->execute(); } else { // This is a new module. - $files[$filename]->status = 0; + $files[$filepath]->status = 0; db_insert('system') ->fields(array( 'name' => $file->name, - 'info' => serialize($files[$filename]->info), + 'info' => serialize($files[$filepath]->info), 'type' => 'module', - 'filename' => $file->filename, + 'filename' => $file->filepath, 'status' => 0)) ->execute(); } @@ -535,7 +535,7 @@ function drupal_required_modules() { $files = drupal_system_listing('/\.info$/', 'modules', 'name', 0); $required = array(); foreach ($files as $name => $file) { - $info = drupal_parse_info_file($file->filename); + $info = drupal_parse_info_file($file->filepath); if (!empty($info) && !empty($info['required']) && $info['required']) { $required[] = $name; } diff --git a/includes/registry.inc b/includes/registry.inc index c3e88f1d0..35caaa3fb 100644 --- a/includes/registry.inc +++ b/includes/registry.inc @@ -43,7 +43,7 @@ function _registry_rebuild() { $files = array(); foreach (module_rebuild_cache() as $module) { if ($module->status) { - $dir = dirname($module->filename); + $dir = dirname($module->filepath); foreach ($module->info['files'] as $file) { $files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight); } diff --git a/includes/theme.inc b/includes/theme.inc index 1b5d03afd..7f81b4c2a 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -831,7 +831,7 @@ function drupal_find_theme_templates($cache, $extension, $path) { $files = drupal_system_listing($regex, $path, 'name', 0); foreach ($files as $template => $file) { // Ignore sub-theme templates for the current theme. - if (strpos($file->filename, str_replace($subtheme_paths, '', $file->filename)) !== 0) { + if (strpos($file->filepath, str_replace($subtheme_paths, '', $file->filepath)) !== 0) { continue; } // Chop off the remaining extensions if there are any. $template already @@ -846,7 +846,7 @@ function drupal_find_theme_templates($cache, $extension, $path) { if (isset($cache[$hook])) { $templates[$hook] = array( 'template' => $template, - 'path' => dirname($file->filename), + 'path' => dirname($file->filepath), ); } // Ensure that the pattern is maintained from base themes to its sub-themes. @@ -872,7 +872,7 @@ function drupal_find_theme_templates($cache, $extension, $path) { // Put the underscores back in for the hook name and register this pattern. $templates[strtr($file, '-', '_')] = array( 'template' => $file, - 'path' => dirname($files[$match]->filename), + 'path' => dirname($files[$match]->filepath), 'arguments' => $info['arguments'], ); } diff --git a/install.php b/install.php index 367f15650..3c4f8f9b7 100644 --- a/install.php +++ b/install.php @@ -420,7 +420,7 @@ function install_select_profile() { // Don't need to choose profile if only one available. if (sizeof($profiles) == 1) { $profile = array_pop($profiles); - require_once $profile->filename; + require_once $profile->filepath; return $profile->name; } elseif (sizeof($profiles) > 1) { @@ -451,7 +451,7 @@ function install_select_profile_form(&$form_state, $profile_files) { $names = array(); foreach ($profile_files as $profile) { - include_once DRUPAL_ROOT . '/' . $profile->filename; + include_once DRUPAL_ROOT . '/' . $profile->filepath; // Load profile details and store them for later retrieval. $function = $profile->name . '_profile_details'; diff --git a/modules/blogapi/blogapi.test b/modules/blogapi/blogapi.test index 14242d122..dd0d72ee6 100644 --- a/modules/blogapi/blogapi.test +++ b/modules/blogapi/blogapi.test @@ -68,7 +68,7 @@ class BlogAPITestCase extends DrupalWebTestCase { // Upload file. $file = current($this->drupalGetTestFiles('text')); - $file_contents = file_get_contents($file->filename); + $file_contents = file_get_contents($file->filepath); $file = array(); $file['name'] = $this->randomName() . '.txt'; $file['type'] = 'text'; diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index cd8b16216..062fb6531 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -593,9 +593,9 @@ class DrupalWebTestCase { // If size is set then remove any files that are not of that size. if ($size !== NULL) { foreach ($files as $file) { - $stats = stat($file->filename); + $stats = stat($file->filepath); if ($stats['size'] != $size) { - unset($files[$file->filename]); + unset($files[$file->filepath]); } } } @@ -609,7 +609,7 @@ class DrupalWebTestCase { */ protected function drupalCompareFiles($file1, $file2) { // Determine which file is larger. - $compare_size = (filesize($file1->filename) > filesize($file2->filename)); + $compare_size = (filesize($file1->filepath) > filesize($file2->filepath)); if (!$compare_size) { // Both files were the same size, so return whichever one is alphabetically greater. return strnatcmp($file1->name, $file2->name); diff --git a/modules/simpletest/simpletest.install b/modules/simpletest/simpletest.install index 2aa13e926..94a8d6960 100644 --- a/modules/simpletest/simpletest.install +++ b/modules/simpletest/simpletest.install @@ -33,7 +33,7 @@ function simpletest_install() { $original = drupal_get_path('module', 'simpletest') . '/files'; $files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/'); foreach ($files as $file) { - file_unmanaged_copy($file->filename, $path . '/' . $file->basename); + file_unmanaged_copy($file->filepath, $path); } $generated = TRUE; } diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module index fe3127758..f0ab28fd7 100644 --- a/modules/simpletest/simpletest.module +++ b/modules/simpletest/simpletest.module @@ -465,7 +465,7 @@ function simpletest_get_all_tests() { $tests_directory = $module_path . '/tests'; if (is_dir($tests_directory)) { foreach (file_scan_directory($tests_directory, '/\.test$/') as $file) { - $files[] = $file->filename; + $files[] = $file->filepath; } } } diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test index 2935bfd18..09a75b78e 100644 --- a/modules/simpletest/tests/file.test +++ b/modules/simpletest/tests/file.test @@ -21,14 +21,14 @@ function file_test_validator($file, $errors) { * When the function is called with $reset parameter TRUE the cache is cleared * and the results returned. * - * @param $file - * File object + * @param $filepath + * File path * @param $reset * Boolean indicating that the stored files should be removed and returned. * @return * An array of all previous $file parameters since $reset was last called. */ -function file_test_file_scan_callback($file, $reset = FALSE) { +function file_test_file_scan_callback($filepath, $reset = FALSE) { static $files = array(); if ($reset) { @@ -37,7 +37,7 @@ function file_test_file_scan_callback($file, $reset = FALSE) { return $ret; } - $files[] = $file; + $files[] = $filepath; } /** @@ -525,14 +525,14 @@ class FileSaveUploadTest extends FileHookTestCase { $this->drupalLogin($account); $this->image = current($this->drupalGetTestFiles('image')); - $this->assertTrue(is_file($this->image->filename), t("The file we're going to upload exists.")); + $this->assertTrue(is_file($this->image->filepath), t("The file we're going to upload exists.")); $this->maxFidBefore = db_query('SELECT MAX(fid) AS fid FROM {files}')->fetchField(); // Upload with replace to gurantee there's something there. $edit = array( 'file_test_replace' => FILE_EXISTS_REPLACE, - 'files[file_test_upload]' => realpath($this->image->filename) + 'files[file_test_upload]' => realpath($this->image->filepath) ); $this->drupalPost('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, t('Received a 200 response for posted test file.')); @@ -559,7 +559,7 @@ class FileSaveUploadTest extends FileHookTestCase { // Upload a second file. $max_fid_before = db_query('SELECT MAX(fid) AS fid FROM {files}')->fetchField(); $image2 = current($this->drupalGetTestFiles('image')); - $edit = array('files[file_test_upload]' => realpath($image2->filename)); + $edit = array('files[file_test_upload]' => realpath($image2->filepath)); $this->drupalPost('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, t('Received a 200 response for posted test file.')); $this->assertRaw(t('You WIN!')); @@ -584,7 +584,7 @@ class FileSaveUploadTest extends FileHookTestCase { function testExistingRename() { $edit = array( 'file_test_replace' => FILE_EXISTS_RENAME, - 'files[file_test_upload]' => realpath($this->image->filename) + 'files[file_test_upload]' => realpath($this->image->filepath) ); $this->drupalPost('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, t('Received a 200 response for posted test file.')); @@ -600,7 +600,7 @@ class FileSaveUploadTest extends FileHookTestCase { function testExistingReplace() { $edit = array( 'file_test_replace' => FILE_EXISTS_REPLACE, - 'files[file_test_upload]' => realpath($this->image->filename) + 'files[file_test_upload]' => realpath($this->image->filepath) ); $this->drupalPost('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, t('Received a 200 response for posted test file.')); @@ -616,7 +616,7 @@ class FileSaveUploadTest extends FileHookTestCase { function testExistingError() { $edit = array( 'file_test_replace' => FILE_EXISTS_ERROR, - 'files[file_test_upload]' => realpath($this->image->filename) + 'files[file_test_upload]' => realpath($this->image->filepath) ); $this->drupalPost('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, t('Received a 200 response for posted test file.')); @@ -829,16 +829,16 @@ class FileScanDirectoryTest extends FileTestCase { // Check the first file. $file = reset($all_files); - $this->assertEqual(key($all_files), $file->filename, t('Correct array key was used for the first returned file.')); - $this->assertEqual($file->filename, $this->path . '/javascript-1.txt', t('First file name was set correctly.')); - $this->assertEqual($file->basename, 'javascript-1.txt', t('First basename was set correctly')); + $this->assertEqual(key($all_files), $file->filepath, t('Correct array key was used for the first returned file.')); + $this->assertEqual($file->filepath, $this->path . '/javascript-1.txt', t('First file name was set correctly.')); + $this->assertEqual($file->filename, 'javascript-1.txt', t('First basename was set correctly')); $this->assertEqual($file->name, 'javascript-1', t('First name was set correctly.')); // Check the second file. $file = next($all_files); - $this->assertEqual(key($all_files), $file->filename, t('Correct array key was used for the second returned file.')); - $this->assertEqual($file->filename, $this->path . '/javascript-2.script', t('Second file name was set correctly.')); - $this->assertEqual($file->basename, 'javascript-2.script', t('Second basename was set correctly')); + $this->assertEqual(key($all_files), $file->filepath, t('Correct array key was used for the second returned file.')); + $this->assertEqual($file->filepath, $this->path . '/javascript-2.script', t('Second file name was set correctly.')); + $this->assertEqual($file->filename, 'javascript-2.script', t('Second basename was set correctly')); $this->assertEqual($file->name, 'javascript-2', t('Second name was set correctly.')); } @@ -879,13 +879,13 @@ class FileScanDirectoryTest extends FileTestCase { function testOptionKey() { // "filename", for the path starting with $dir. $expected = array($this->path . '/javascript-1.txt', $this->path . '/javascript-2.script'); - $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'filename'))); + $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'filepath'))); sort($actual); $this->assertEqual($expected, $actual, t('Returned the correct values for the filename key.')); // "basename", for the basename of the file. $expected = array('javascript-1.txt', 'javascript-2.script'); - $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'basename'))); + $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'filename'))); sort($actual); $this->assertEqual($expected, $actual, t('Returned the correct values for the basename key.')); diff --git a/modules/system/system.module b/modules/system/system.module index f4f0ca744..ef9bd565f 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1062,7 +1062,8 @@ function system_get_files_database(&$files, $type) { $result = db_query("SELECT filename, name, type, status, schema_version, weight FROM {system} WHERE type = '%s'", $type); while ($file = db_fetch_object($result)) { if (isset($files[$file->name]) && is_object($files[$file->name])) { - $file->old_filename = $file->filename; + $file->filepath = $file->filename; + $file->old_filepath = $file->filepath; foreach ($file as $key => $value) { if (!isset($files[$file->name]) || !isset($files[$file->name]->$key)) { $files[$file->name]->$key = $value; @@ -1155,7 +1156,8 @@ function _system_theme_data() { $sub_themes = array(); // Read info files for each theme foreach ($themes as $key => $theme) { - $themes[$key]->info = drupal_parse_info_file($theme->filename) + $defaults; + $themes[$key]->filename = $theme->filepath; + $themes[$key]->info = drupal_parse_info_file($theme->filepath) + $defaults; // Invoke hook_system_info_alter() to give installed modules a chance to // modify the data in the .info files if necessary. @@ -1165,7 +1167,7 @@ function _system_theme_data() { $sub_themes[] = $key; } if (empty($themes[$key]->info['engine'])) { - $filename = dirname($themes[$key]->filename) . '/' . $themes[$key]->name . '.theme'; + $filename = dirname($themes[$key]->filepath) . '/' . $themes[$key]->name . '.theme'; if (file_exists($filename)) { $themes[$key]->owner = $filename; $themes[$key]->prefix = $key; @@ -1174,7 +1176,7 @@ function _system_theme_data() { else { $engine = $themes[$key]->info['engine']; if (isset($engines[$engine])) { - $themes[$key]->owner = $engines[$engine]->filename; + $themes[$key]->owner = $engines[$engine]->filepath; $themes[$key]->prefix = $engines[$engine]->name; $themes[$key]->template = TRUE; } @@ -1184,7 +1186,7 @@ function _system_theme_data() { $pathed_stylesheets = array(); foreach ($themes[$key]->info['stylesheets'] as $media => $stylesheets) { foreach ($stylesheets as $stylesheet) { - $pathed_stylesheets[$media][$stylesheet] = dirname($themes[$key]->filename) . '/' . $stylesheet; + $pathed_stylesheets[$media][$stylesheet] = dirname($themes[$key]->filepath) . '/' . $stylesheet; } } $themes[$key]->info['stylesheets'] = $pathed_stylesheets; @@ -1192,12 +1194,12 @@ function _system_theme_data() { // Give the scripts proper path information. $scripts = array(); foreach ($themes[$key]->info['scripts'] as $script) { - $scripts[$script] = dirname($themes[$key]->filename) . '/' . $script; + $scripts[$script] = dirname($themes[$key]->filepath) . '/' . $script; } $themes[$key]->info['scripts'] = $scripts; // Give the screenshot proper path information. if (!empty($themes[$key]->info['screenshot'])) { - $themes[$key]->info['screenshot'] = dirname($themes[$key]->filename) . '/' . $themes[$key]->info['screenshot']; + $themes[$key]->info['screenshot'] = dirname($themes[$key]->filepath) . '/' . $themes[$key]->info['screenshot']; } } diff --git a/modules/update/update.compare.inc b/modules/update/update.compare.inc index 34b74849e..f2c183b86 100644 --- a/modules/update/update.compare.inc +++ b/modules/update/update.compare.inc @@ -69,7 +69,7 @@ function _update_process_info_list(&$projects, $list, $project_type) { // which is left alone by tar and correctly set to the time the .info file // was unpacked. if (!isset($file->info['_info_file_ctime'])) { - $info_filename = dirname($file->filename) . '/' . $file->name . '.info'; + $info_filename = dirname($file->filepath) . '/' . $file->name . '.info'; $file->info['_info_file_ctime'] = filectime($info_filename); } diff --git a/modules/upload/upload.test b/modules/upload/upload.test index bd4bfbdc9..b95ff78f8 100644 --- a/modules/upload/upload.test +++ b/modules/upload/upload.test @@ -39,7 +39,7 @@ class UploadTestCase extends DrupalWebTestCase { // Create a node and attempt to attach files. $node = $this->drupalCreateNode(); $text_files = $this->drupalGetTestFiles('text'); - $files = array(current($text_files)->filename, next($text_files)->filename); + $files = array(current($text_files)->filepath, next($text_files)->filepath); $this->uploadFile($node, $files[0]); $this->uploadFile($node, $files[1]); @@ -108,17 +108,17 @@ class UploadTestCase extends DrupalWebTestCase { $text_file = current($this->drupalGetTestFiles('text')); // Select a file that's less than the 1MB upload limit so we only test one // limit at a time. - $this->uploadFile($node, $text_file->filename, FALSE); + $this->uploadFile($node, $text_file->filepath, FALSE); // Test the error message in two steps in case there are additional errors // that change the error message's format. - $this->assertRaw(t('The specified file %name could not be uploaded.', array('%name' => $text_file->basename)), t('File %filename was not allowed to be uploaded', array('%filename' => $text_file->filename))); + $this->assertRaw(t('The specified file %name could not be uploaded.', array('%name' => $text_file->filename)), t('File %filepath was not allowed to be uploaded', array('%filepath' => $text_file->filepath))); $this->assertRaw(t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => $settings['upload_extensions'])), t('File extension cited as reason for failure')); // Attempt to upload .html file when .html is only extension allowed. $html_files = array_values($this->drupalGetTestFiles('html')); // Use the HTML file with the .html extension, $html_files[0] has a .txt // extension. - $html_file = $html_files[1]->filename; + $html_file = $html_files[1]->filepath; $this->uploadFile($node, $html_file); $this->assertNoRaw(t('The specified file %name could not be uploaded.', array('%name' => basename($html_file))), t('File '. $html_file . ' was allowed to be uploaded')); } @@ -128,7 +128,7 @@ class UploadTestCase extends DrupalWebTestCase { */ function testLimit() { $files = $this->drupalGetTestFiles('text', 1310720); // 1 MB. - $file = current($files)->filename; + $file = current($files)->filepath; $admin_user = $this->drupalCreateUser(array('administer site configuration')); $web_user = $this->drupalCreateUser(array('access content', 'edit any page content', 'upload files', 'view uploaded files')); diff --git a/modules/user/user.test b/modules/user/user.test index 89c534a26..228be6b81 100644 --- a/modules/user/user.test +++ b/modules/user/user.test @@ -535,7 +535,7 @@ class UserPictureTestCase extends DrupalWebTestCase { $this->drupalLogin($this->user); $image = current($this->drupalGetTestFiles('image')); - $info = image_get_info($image->filename); + $info = image_get_info($image->filepath); // Set new variables: invalid dimensions, valid filesize (0 = no limit). $test_dim = ($info['width'] - 10) . 'x' . ($info['height'] - 10); @@ -569,7 +569,7 @@ class UserPictureTestCase extends DrupalWebTestCase { $this->drupalLogin($this->user); $image = current($this->drupalGetTestFiles('image')); - $info = image_get_info($image->filename); + $info = image_get_info($image->filepath); // Set new variables: valid dimensions, invalid filesize. $test_dim = ($info['width'] + 10) . 'x' . ($info['height'] + 10); @@ -580,9 +580,9 @@ class UserPictureTestCase extends DrupalWebTestCase { $pic_path = $this->saveUserPicture($image); // Test that the upload failed and that the correct reason was cited. - $text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->basename)); + $text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->filename)); $this->assertRaw($text, t('Upload failed.')); - $text = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size(filesize($image->filename)), '%maxsize' => format_size($test_size * 1024))); + $text = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size(filesize($image->filepath)), '%maxsize' => format_size($test_size * 1024))); $this->assertRaw($text, t('File size cited as reason for failure.')); // Check if file is not uploaded. @@ -604,7 +604,7 @@ class UserPictureTestCase extends DrupalWebTestCase { $this->drupalLogin($this->user); $image = current($this->drupalGetTestFiles('image')); - $info = image_get_info($image->filename); + $info = image_get_info($image->filepath); // Set new variables: invalid dimensions, valid filesize (0 = no limit). $test_dim = ($info['width'] - 10) . 'x' . ($info['height'] - 10); @@ -614,7 +614,7 @@ class UserPictureTestCase extends DrupalWebTestCase { $pic_path = $this->saveUserPicture($image); // Test that the upload failed and that the correct reason was cited. - $text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->basename)); + $text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->filename)); $this->assertRaw($text, t('Upload failed.')); $text = t('The image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => $test_dim)); $this->assertRaw($text, t('Checking response on invalid image (dimensions).')); @@ -637,7 +637,7 @@ class UserPictureTestCase extends DrupalWebTestCase { $this->drupalLogin($this->user); $image = current($this->drupalGetTestFiles('image')); - $info = image_get_info($image->filename); + $info = image_get_info($image->filepath); // Set new variables: valid dimensions, invalid filesize. $test_dim = ($info['width'] + 10) . 'x' . ($info['height'] + 10); @@ -648,9 +648,9 @@ class UserPictureTestCase extends DrupalWebTestCase { $pic_path = $this->saveUserPicture($image); // Test that the upload failed and that the correct reason was cited. - $text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->basename)); + $text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->filename)); $this->assertRaw($text, t('Upload failed.')); - $text = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size(filesize($image->filename)), '%maxsize' => format_size($test_size * 1024))); + $text = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size(filesize($image->filepath)), '%maxsize' => format_size($test_size * 1024))); $this->assertRaw($text, t('File size cited as reason for failure.')); // Check if file is not uploaded. @@ -669,7 +669,7 @@ class UserPictureTestCase extends DrupalWebTestCase { $this->drupalLogin($this->user); $image = current($this->drupalGetTestFiles('image')); - $info = image_get_info($image->filename); + $info = image_get_info($image->filepath); // Set new variables: valid dimensions, valid filesize (0 = no limit). $test_dim = ($info['width'] + 10) . 'x' . ($info['height'] + 10); @@ -688,10 +688,10 @@ class UserPictureTestCase extends DrupalWebTestCase { } function saveUserPicture($image) { - $edit = array('files[picture_upload]' => realpath($image->filename)); + $edit = array('files[picture_upload]' => realpath($image->filepath)); $this->drupalPost('user/' . $this->user->uid.'/edit', $edit, t('Save')); - $img_info = image_get_info($image->filename); + $img_info = image_get_info($image->filepath); $picture_dir = variable_get('user_picture_path', 'pictures'); $pic_path = file_directory_path() . '/' . $picture_dir . '/picture-' . $this->user->uid . '.' . $img_info['extension']; |