summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorChad Parry <github@chad.parry.org>2011-05-18 22:01:51 -0600
committerChad Parry <github@chad.parry.org>2011-05-18 22:01:51 -0600
commit97c3ded2bae24fa18801c94548d1cfd97e19cf2a (patch)
treef4cc93994d59e8e05be01066f201e0ebce3a31e0 /modules
parentd2d37fe3f2e550dff0c62afa9faa3100f305df0e (diff)
Better validation for uploaded files, especially where third-party modules might make a mistake.
Squashed commit of the following: commit f2336a5aaa0eb797f252388ecd7b93a82f9646fd Author: Chad Parry <github@chad.parry.org> Date: Wed May 18 21:56:10 2011 -0600 Behave reasonably if the image cannot be resized. commit e06b20738d0e0bdb80bae68b7fec2b3746192f6e Author: Chad Parry <github@chad.parry.org> Date: Wed May 18 21:10:08 2011 -0600 Adding an image representing a broken thumbnail. This image was derived from the equivalent Gallery2 icon. It uses the same washed-out gray color scheme as the Gallery3 missing_movie icon. commit 4e3964527b66d8ccd76fb261d549cd9861a7a780 Author: Chad Parry <github@chad.parry.org> Date: Wed May 18 20:30:28 2011 -0600 Initialize legal file arrays correctly. commit e9862d8fbc4d6fd06abf157f48dce671a7283993 Author: Chad Parry <github@chad.parry.org> Date: Wed May 18 20:20:19 2011 -0600 Correction for the merge conflict markers I accidentally committed. commit 5e62d327a8dc477d3edea99826183548aca3e7f3 Author: Chad Parry <github@chad.parry.org> Date: Wed May 18 20:17:36 2011 -0600 Expand the legal_file events to include separate photo and movie events, and to support MIME types. commit f0bfd1fef0b6d17da9a491f7c724ae53491926a2 Merge: 72f3fc4 db73413 Author: Chad Parry <github@chad.parry.org> Date: Wed May 18 19:49:25 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto Conflicts: modules/gallery/helpers/system.php modules/gallery/tests/System_Helper_Test.php commit db734130c5fe10408040b2326b28b102f3131271 Author: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com> Date: Mon May 16 21:38:07 2011 -0700 Automated update of .build_number to 153 for branch master Last update: 9aeb824aa1d15bd94bd7cef0a322c4e8a667e67b (1 commits ago) commit 8549ba30ca5045211d2efcf8e1c4f98f8a1e9f25 Author: Chad Kieffer <ckieffer@gmail.com> Date: Mon May 16 22:37:09 2011 -0600 Stop IE 9 album grid craziness. Thanks floridave. Fixes #1430. commit 9aeb824aa1d15bd94bd7cef0a322c4e8a667e67b Author: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com> Date: Sun May 8 11:43:38 2011 -0700 Automated update of .build_number to 152 for branch master Last update: 7c80e6ef84b460dcade80c4dd5a65b41b0523505 (1 commits ago) commit 57f7e42a128848d73ad2a7ac0bf9df2fee6ba8b8 Author: Bharat Mediratta <bharat@menalto.com> Date: Sun May 8 11:42:40 2011 -0700 Add the item id to the print_proxy line so that we have a little more info about what the original was, and extend the timeout to 90 days from 10. Fixes #1733. commit 7c80e6ef84b460dcade80c4dd5a65b41b0523505 Author: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com> Date: Fri May 6 11:48:43 2011 -0700 Automated update of .build_number to 151 for branch master Last update: 5d09cbff048fc2f457c8b19adb2177a12445890a (1 commits ago) commit 80dda6f64fd26f373cc138a199652099accceb26 Merge: 5d09cbf 46da011 Author: Bharat Mediratta <bharat@menalto.com> Date: Fri May 6 11:48:13 2011 -0700 Merge pull request #52 from chadparry/tempnam Fixes #1732 commit 5d09cbff048fc2f457c8b19adb2177a12445890a Author: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com> Date: Thu May 5 21:53:39 2011 -0700 Automated update of .build_number to 150 for branch master Last update: 011eaa6480cbee8d328a31c9ac5c8e0ddc1f8a84 (1 commits ago) commit d5a31ceedee5841531f57342266746bb62d7d923 Author: Tim Almdal <tnalmdal@shaw.ca> Date: Thu May 5 21:53:10 2011 -0700 Fix for ticket 1275. Do the same checking as Kohana uses and don't worry about calling the utf8_encode routine. Corrected the error messages and also added a check to insure the XML Parser extension is loaded as we still need the utf8_encode function from it. commit 011eaa6480cbee8d328a31c9ac5c8e0ddc1f8a84 Author: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com> Date: Thu May 5 14:53:06 2011 -0700 Automated update of .build_number to 149 for branch master Last update: 05ecfda36b7acee7f8d36df8391ba960097178a8 (1 commits ago) commit 5bae21864f54a03b557ab349cf97ba5f1d4276dc Author: Bharat Mediratta <bharat@menalto.com> Date: Thu May 5 14:52:47 2011 -0700 Follow-on to 6f916e49d5b431c2c1961a13d1a61fef8c02d628 -- don't make database calls if Gallery isn't installed, else we fail to bounce the user to the installer on fresh packages. #1637. commit 46da011bf69bbc4e45757feda8f0d28e91e7fb6a Author: Chad Parry <github@chad.parry.org> Date: Wed May 4 17:51:00 2011 -0600 Remove a newline I accidentally introduced. commit 5c6c71ffcdea354b5b9b30aaea2c1f92c8860d42 Merge: d2331bf 05ecfda Author: Chad Parry <github@chad.parry.org> Date: Wed May 4 17:49:42 2011 -0600 Merge branch 'master' into tempnam commit d2331bf43457a8d33491921f106879f087438171 Author: Chad Parry <github@chad.parry.org> Date: Wed May 4 17:48:25 2011 -0600 Simplified the temp_filename implementation and removed the mocks. commit 72f3fc46f6c7c9043e730063051ecfd88bf314c8 Author: Chad Parry <github@chad.parry.org> Date: Wed May 4 17:22:15 2011 -0600 Avoid "self::" because Kohana can't override it. commit 05ecfda36b7acee7f8d36df8391ba960097178a8 Author: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com> Date: Mon May 2 21:38:50 2011 -0700 Automated update of .build_number to 148 for branch master Last update: 97400b78153620262120868b37545170416413c9 (2 commits ago) commit 229bfc5c7c760c53d1357503fd61bf9a165acf6e Author: Bharat Mediratta <bharat@menalto.com> Date: Mon May 2 21:37:04 2011 -0700 Track and redirect core.DownloadItem requests properly. This can happen if the G2 was imported with rewrite on, so the g2_url in the g2_map table has a shortened url, but then rewrite is disabled and the .htaccess mod_rewrite rules are sending over a &g2_view=core.DownloadItem request. Fixes #1728. commit 68370b92f5f6fa68744655f8c68b4b0ca59bf4fd Author: Bharat Mediratta <bharat@menalto.com> Date: Mon May 2 21:36:17 2011 -0700 Map the G2 album highlight thumbnail derivative id to the G3 album's thumbnail. Fixes #1729. commit 13dbd3515bfb5324cfbcb3bbeafc179771b54f75 Merge: f0f094c 97400b7 Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 20:33:02 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commit f0f094c3f79b09536f58083681c28f73271c506d Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 20:22:49 2011 -0600 Explain the conditional rename in item::save() with a comment. commit 1b3a6b85c156e4777d2aa8205b130984f55dc66d Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 18:29:34 2011 -0600 Improve the comment explaining why the data_file extension is important. commit c3e8c1e3b5e3cb1046acd4c923bb0ae9dbcd603a Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 18:12:56 2011 -0600 The data_file field is public, so we don't need to supply an accessor method. commit 0e844766baf3b3875cbb2d84579626e05e879420 Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 16:40:55 2011 -0600 Change the signature of system::tempnam to something more appropriate for Gallery. commit 5c9a3b3f39f6ff0d5c84c2cf283d27eaebe2e66e Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 23 21:19:47 2011 -0600 Create a tempnam substitute that safely creates files with a given extension. commit 2375a02e2cdbd1ccaf7dc4d3db9d85119972e3a9 Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 16:40:55 2011 -0600 Change the signature of system::tempnam to something more appropriate for Gallery. commit a8ca9dcf9edd54633c0c78b3af76aa974d38fc64 Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 16:10:06 2011 -0600 Change the name of the extensions helper to legal_file. commit 7e61a01a96f5eab7212dba754ac64fdfb4d9e8ab Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 16:08:49 2011 -0600 Change the name of the extensions helper to legal_file. commit 4c2b2ebd3f2052898fbfb175650ed4cf49c8006e Author: Chad Parry <github@chad.parry.org> Date: Wed Apr 27 20:52:35 2011 -0600 Remove a newline at the end of the file that I accidentally introduced. commit 6d564f185e5279d6cca9a7385066514ff18a2455 Merge: 7ff485f 4060640 Author: Chad Parry <github@chad.parry.org> Date: Wed Apr 27 20:35:58 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commit 7ff485fa48c392bbbb0370f67cb1bd6fcc00c2a4 Author: Chad Parry <github@chad.parry.org> Date: Wed Apr 27 20:29:06 2011 -0600 Move the extensions helpers out of the Kohana system directory and into their own Gallery Extensions class. commit 26585fed03236f0f70a75959e1d3002025f4e15e Merge: 809567f c8f90e8 Author: Chad Parry <github@chad.parry.org> Date: Sun Apr 24 08:28:39 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commit 809567f12850f59bdeb47a2963f6968b99b5a201 Author: Chad Parry <github@chad.parry.org> Date: Sun Apr 24 08:10:04 2011 -0600 Expose the data file field. commit fcb06bf175bb9eeff36d9c294e97ace9374ef0f3 Author: Chad Parry <github@chad.parry.org> Date: Sun Apr 24 00:45:12 2011 -0600 Don't assign to the item->name field if the name is unchanged, because the save method will crash. commit c6ef706d70c7e48bea1145eec1b13fb5683e023f Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 23 22:55:59 2011 -0600 Preserve old data files long enough for them to be available to event handlers. commit 0d6a3a3cfc4f38f450db9e18da47a5e2ad826af8 Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 23 21:19:47 2011 -0600 Create a tempnam substitute that safely creates files with a given extension. commit e149cf7238a1f8eaddfc68580f2d636dd8255795 Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 23 16:39:25 2011 -0600 Support data files that change their extension and MIME type. commit 6702104f571413e4d57db3515b2070c48d3e9b55 Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 23 16:35:00 2011 -0600 Resolve an infinite recursion that happens when the path caches are updated during saving. commit 944cb72eea946f4c45a04b7e4c7c33929fa8b9f3 Merge: 567522b 5af74d4 Author: Chad Parry <github@chad.parry.org> Date: Fri Apr 22 14:10:42 2011 -0600 Merge remote branch 'origin/master' into rawphoto commit 567522bfa08c370bb5baf8454afc5b04bc9e49b4 Author: Chad Parry <github@chad.parry.org> Date: Thu Apr 21 20:12:32 2011 -0600 Add an event for when a new graphics toolkit is chosen. commit 31ba081b793141ca36866a6dd349cd2eac5af68e Author: Chad Parry <github@chad.parry.org> Date: Thu Apr 21 02:06:53 2011 -0600 Add an event that will collect all valid filename extensions.
Diffstat (limited to 'modules')
-rw-r--r--modules/digibug/controllers/digibug.php6
-rw-r--r--modules/g2_import/controllers/g2.php4
-rw-r--r--modules/g2_import/helpers/g2_import.php7
-rw-r--r--modules/gallery/config/locale.php7
-rw-r--r--modules/gallery/helpers/graphics.php22
-rw-r--r--modules/gallery/helpers/legal_file.php39
-rw-r--r--modules/gallery/helpers/system.php13
-rw-r--r--modules/gallery/images/missing_photo.pngbin0 -> 1570 bytes
-rw-r--r--modules/gallery/models/item.php15
-rw-r--r--modules/gallery/tests/System_Helper_Test.php25
10 files changed, 83 insertions, 55 deletions
diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php
index 4acb6513..672afe57 100644
--- a/modules/digibug/controllers/digibug.php
+++ b/modules/digibug/controllers/digibug.php
@@ -33,8 +33,8 @@ class Digibug_Controller extends Controller {
$proxy->uuid = random::hash();
$proxy->item_id = $item->id;
$proxy->save();
- $full_url = url::abs_site("digibug/print_proxy/full/$proxy->uuid");
- $thumb_url = url::abs_site("digibug/print_proxy/thumb/$proxy->uuid");
+ $full_url = url::abs_site("digibug/print_proxy/full/$proxy->uuid/$item->id");
+ $thumb_url = url::abs_site("digibug/print_proxy/thumb/$proxy->uuid/$item->id");
}
$v = new View("digibug_form.html");
@@ -114,7 +114,7 @@ class Digibug_Controller extends Controller {
private function _clean_expired() {
db::build()
->delete("digibug_proxies")
- ->where("request_date", "<=", db::expr("(CURDATE() - INTERVAL 10 DAY)"))
+ ->where("request_date", "<=", db::expr("(CURDATE() - INTERVAL 90 DAY)"))
->limit(20)
->execute();
}
diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php
index 6e60bed0..90984e84 100644
--- a/modules/g2_import/controllers/g2.php
+++ b/modules/g2_import/controllers/g2.php
@@ -41,7 +41,9 @@ class G2_Controller extends Controller {
// (bbcode, embedding) people are using the id style URLs although URL rewriting is enabled.
$where = array(array("g2_id", "=", $id));
$view = $input->get("g2_view");
- if ($view) {
+ if ($view == "core.DownloadItem") {
+ $where[] = array("resource_type", "IN", array("file", "resize", "thumbnail", "full"));
+ } else if ($view) {
$where[] = array("g2_url", "like", "%g2_view=$view%");
} // else: Assuming that the first search hit is sufficiently good.
} else if ($path) {
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 3606c7ef..c79a8d36 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -560,7 +560,7 @@ class g2_import_Core {
$table = g2(GalleryCoreApi::fetchThumbnailsByItemIds(array($g2_album_id)));
if (isset($table[$g2_album_id])) {
// Backtrack the source id to an item
- $g2_source = $table[$g2_album_id];
+ $orig_g2_source = $g2_source = $table[$g2_album_id];
while (GalleryUtilities::isA($g2_source, "GalleryDerivative")) {
$g2_source = g2(GalleryCoreApi::loadEntitiesById($g2_source->getDerivativeSourceId()));
}
@@ -584,6 +584,11 @@ class g2_import_Core {
array("name" => $g3_album->name)),
$e);
}
+
+ self::set_map(
+ $orig_g2_source->getId(), $g3_album->id,
+ "thumbnail",
+ self::g2_url(array("view" => "core.DownloadItem", "itemId" => $orig_g2_source->getId())));
}
}
}
diff --git a/modules/gallery/config/locale.php b/modules/gallery/config/locale.php
index 13de9098..bce7fb49 100644
--- a/modules/gallery/config/locale.php
+++ b/modules/gallery/config/locale.php
@@ -32,7 +32,12 @@ $config['language'] = array('en_US', 'English_United States');
* Locale timezone. Set in 'Advanced' settings, falling back to the server's zone.
* @see http://php.net/timezones
*/
-$config['timezone'] = module::get_var("gallery", "timezone", date_default_timezone_get());
+if (file_exists(VARPATH . "database.php")) {
+ $config['timezone'] = module::get_var("gallery", "timezone", date_default_timezone_get());
+} else {
+ // Gallery3 is not installed yet -- don't make module::get_var() calls.
+ $config['timezone'] = date_default_timezone_get();
+}
// i18n settings
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index acb11bfb..3b9769de 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -170,23 +170,37 @@ class graphics_Core {
foreach (self::_get_rules($target) as $rule) {
$args = array($working_file, $output_file, unserialize($rule->args), $item);
- call_user_func_array($rule->operation, $args);
- $working_file = $output_file;
+ try {
+ call_user_func_array($rule->operation, $args);
+ $working_file = $output_file;
+ } catch (Exception $e) {
+ // Ignore this filter and move on.
+ Kohana_Log::add("error", "Caught exception filtering image: {$item->title}\n" .
+ $e->getMessage() . "\n" . $e->getTraceAsString());
+ }
}
}
if (!empty($ops["thumb"])) {
+ if (file_exists($item->thumb_path())) {
+ $item->thumb_dirty = 0;
+ } else {
+ copy(MODPATH . "gallery/images/missing_photo.png", $item->thumb_path());
+ }
$dims = getimagesize($item->thumb_path());
$item->thumb_width = $dims[0];
$item->thumb_height = $dims[1];
- $item->thumb_dirty = 0;
}
if (!empty($ops["resize"])) {
+ if (file_exists($item->resize_path())) {
+ $item->resize_dirty = 0;
+ } else {
+ copy(MODPATH . "gallery/images/missing_photo.png", $item->resize_path());
+ }
$dims = getimagesize($item->resize_path());
$item->resize_width = $dims[0];
$item->resize_height = $dims[1];
- $item->resize_dirty = 0;
}
$item->save();
} catch (Exception $e) {
diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php
index 2cb0fb25..0d3e9728 100644
--- a/modules/gallery/helpers/legal_file.php
+++ b/modules/gallery/helpers/legal_file.php
@@ -18,22 +18,51 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class legal_file_Core {
- static function get_extensions() {
+ static function get_photo_extensions() {
// Create a default list of allowed extensions and then let modules modify it.
$extensions_wrapper = new stdClass();
$extensions_wrapper->extensions = array("gif", "jpg", "jpeg", "png");
+ module::event("legal_photo_extensions", $extensions_wrapper);
+ return $extensions_wrapper->extensions;
+ }
+
+ static function get_movie_extensions() {
+ // Create a default list of allowed extensions and then let modules modify it.
+ $extensions_wrapper = new stdClass();
+ $extensions_wrapper->extensions = array("flv", "mp4", "m4v");
+ module::event("legal_movie_extensions", $extensions_wrapper);
+ return $extensions_wrapper->extensions;
+ }
+
+ static function get_extensions() {
+ $extensions = legal_file::get_photo_extensions();
if (movie::find_ffmpeg()) {
- array_push($extensions_wrapper->extensions, "flv", "mp4", "m4v");
+ $extensions = array_merge($extensions, legal_file::get_movie_extensions());
}
- module::event("legal_file_extensions", $extensions_wrapper);
- return $extensions_wrapper->extensions;
+ return $extensions;
}
static function get_filters() {
$filters = array();
- foreach (self::get_extensions() as $extension) {
+ foreach (legal_file::get_extensions() as $extension) {
array_push($filters, "*." . $extension, "*." . strtoupper($extension));
}
return $filters;
}
+
+ static function get_photo_types() {
+ // Create a default list of allowed types and then let modules modify it.
+ $types_wrapper = new stdClass();
+ $types_wrapper->types = array("image/jpeg", "image/gif", "image/png");
+ module::event("legal_photo_types", $types_wrapper);
+ return $types_wrapper->types;
+ }
+
+ static function get_movie_types() {
+ // Create a default list of allowed types and then let modules modify it.
+ $types_wrapper = new stdClass();
+ $types_wrapper->types = array("video/flv", "video/x-flv", "video/mp4");
+ module::event("legal_movie_types", $types_wrapper);
+ return $types_wrapper->types;
+ }
}
diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php
index 9815d588..4110b4ed 100644
--- a/modules/gallery/helpers/system.php
+++ b/modules/gallery/helpers/system.php
@@ -47,20 +47,13 @@ class system_Core {
* It allows the caller to specify a prefix and an extension.
* It always places the file in TMPPATH.
*/
- static function temp_filename($prefix = "", $extension = "") {
- return self::_tempnam(TMPPATH, $prefix, ".$extension", "tempnam");
- }
-
- /**
- * This helper provides a dependency-injected implementation of tempnam.
- */
- static function _tempnam($dir, $prefix, $postfix, $builtin) {
+ static function temp_filename($prefix="", $extension="") {
do {
- $basename = call_user_func($builtin, $dir, $prefix);
+ $basename = tempnam(TMPPATH, $prefix);
if (!$basename) {
return false;
}
- $filename = $basename . $postfix;
+ $filename = "$basename.$extension";
$success = !file_exists($filename) && @rename($basename, $filename);
if (!$success) {
@unlink($basename);
diff --git a/modules/gallery/images/missing_photo.png b/modules/gallery/images/missing_photo.png
new file mode 100644
index 00000000..67786275
--- /dev/null
+++ b/modules/gallery/images/missing_photo.png
Binary files differ
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 6eb93cfa..4a0c8e38 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -813,10 +813,13 @@ class Item_Model_Core extends ORM_MPTT {
return;
}
- if (($this->is_movie() || $this->is_photo()) &&
+ if ($this->is_photo() &&
!preg_match("/^(" .
- implode("|", array_map("preg_quote",
- legal_file::get_extensions())) .
+ implode("|", array_map("preg_quote", legal_file::get_photo_extensions())) .
+ ")\$/i", $ext) ||
+ $this->is_movie() &&
+ !preg_match("/^(" .
+ implode("|", array_map("preg_quote", legal_file::get_movie_extensions())) .
")\$/i", $ext)) {
$v->add_error("name", "illegal_data_file_extension");
}
@@ -896,9 +899,9 @@ class Item_Model_Core extends ORM_MPTT {
switch($field) {
case "mime_type":
if ($this->is_movie()) {
- $legal_values = array("video/flv", "video/x-flv", "video/mp4");
- } if ($this->is_photo()) {
- $legal_values = array("image/jpeg", "image/gif", "image/png", "image/tiff");
+ $legal_values = legal_file::get_movie_types();
+ } else if ($this->is_photo()) {
+ $legal_values = legal_file::get_photo_types();
}
break;
diff --git a/modules/gallery/tests/System_Helper_Test.php b/modules/gallery/tests/System_Helper_Test.php
index dfe5d9ab..3d56c516 100644
--- a/modules/gallery/tests/System_Helper_Test.php
+++ b/modules/gallery/tests/System_Helper_Test.php
@@ -18,33 +18,10 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class System_Helper_Test extends Gallery_Unit_Test_Case {
- public function temp_filename_random_test() {
+ public function temp_filename_test() {
$filename = system::temp_filename("file", "ext");
$this->assert_true(file_exists($filename), "File not created");
unlink($filename);
$this->assert_pattern($filename, "|/file.*\\.ext$|");
}
-
- public function tempnam_collision_test() {
- require_once('Mock_Built_In.php');
- $existing = TMPPATH . "/file1.ext";
- $available = TMPPATH . "/file2.ext";
- touch($existing);
- $filename = system::_tempnam(TMPPATH, "file", ".ext",
- array(new Mock_Built_In("1", "2"), "_tempnam"));
- unlink($existing);
- $this->assert_true(file_exists($filename), "File not created");
- unlink($filename);
- $this->assert_equal($available, $filename, "Incorrect filename created");
- }
-
- public function tempnam_abort_test() {
- require_once('Mock_Built_In.php');
- $filename = system::_tempnam(TMPPATH, "file", ".ext",
- array(new Mock_Built_In(), "_tempnam"));
- if ($filename) {
- @unlink($filename);
- }
- $this->assert_false($filename, "Operation not aborted");
- }
}