From 592eff0e5a8af6f74eff4806dc6e7de56ca02761 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sat, 19 Jan 2013 08:40:19 +0100 Subject: #1942 - Make data_rest and file_proxy more consistent - several minor documentation/formatting changes. No actual functionality changed here. --- modules/gallery/controllers/file_proxy.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules/gallery/controllers/file_proxy.php') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index b9ff7df1..9af58c0c 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -100,6 +100,9 @@ class File_Proxy_Controller extends Controller { throw new Kohana_404_Exception(); } + // Note: this code is roughly duplicated in data_rest, so if you modify this, please look to + // see if you should make the same change there as well. + if ($type == "albums") { $file = $item->file_path(); } else if ($type == "resizes") { -- cgit v1.2.3 From 1927dd00e42062a98855d121ec8427b25d74d015 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sun, 20 Jan 2013 08:34:12 +0100 Subject: #1949 - Fix album thumb mime types given by data_rest and file_proxy Correct result: always "image/jpeg" Old data_rest result: mime of cover item Old file_proxy result: mime of album item (null) --- modules/gallery/controllers/file_proxy.php | 4 ++-- modules/gallery/helpers/data_rest.php | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'modules/gallery/controllers/file_proxy.php') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 9af58c0c..b2120455 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -126,8 +126,8 @@ class File_Proxy_Controller extends Controller { expires::set(2592000, $item->updated); // 30 days - // Dump out the image. If the item is a movie, then its thumbnail will be a JPG. - if ($item->is_movie() && $type != "albums") { + // Dump out the image. If the item is a movie or album, then its thumbnail will be a JPG. + if (($item->is_movie() || $item->is_album()) && $type == "thumbs") { header("Content-Type: image/jpeg"); } else { header("Content-Type: $item->mime_type"); diff --git a/modules/gallery/helpers/data_rest.php b/modules/gallery/helpers/data_rest.php index abd4638e..ef4f17e7 100644 --- a/modules/gallery/helpers/data_rest.php +++ b/modules/gallery/helpers/data_rest.php @@ -57,13 +57,11 @@ class data_rest_Core { return; } - // Dump out the image. If the item is a movie, then its thumbnail will be a JPG. - if ($item->is_movie() && $p->size == "thumb") { + // Dump out the image. If the item is a movie or album, then its thumbnail will be a JPG. + if (($item->is_movie() || $item->is_album()) && $p->size == "thumb") { header("Content-Type: image/jpeg"); - } else if ($item->is_album()) { - header("Content-Type: " . $item->album_cover()->mime_type); } else { - header("Content-Type: {$item->mime_type}"); + header("Content-Type: $item->mime_type"); } Kohana::close_buffers(false); -- cgit v1.2.3 From f1d2a8e871327d250574d2dd7cacbb21ea3ae995 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jan 2013 23:54:01 -0500 Subject: Add a long overdue test for File_Proxy_Controller that tests all the various edge case behaviors. It doesn't cover the various headers, but it does cover the permission based code paths. --- modules/gallery/controllers/file_proxy.php | 34 ++++-- .../gallery/tests/File_Proxy_Controller_Test.php | 130 +++++++++++++++++++++ 2 files changed, 156 insertions(+), 8 deletions(-) create mode 100644 modules/gallery/tests/File_Proxy_Controller_Test.php (limited to 'modules/gallery/controllers/file_proxy.php') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index b2120455..df1f7908 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -49,7 +49,9 @@ class File_Proxy_Controller extends Controller { // Make sure that the request is for a file inside var $offset = strpos(rawurldecode($request_uri), $var_uri); if ($offset !== 0) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 1; + throw $e; } // file_uri: albums/foo/bar.jpg @@ -59,7 +61,9 @@ class File_Proxy_Controller extends Controller { // path: foo/bar.jpg list ($type, $path) = explode("/", $file_uri, 2); if ($type != "resizes" && $type != "albums" && $type != "thumbs") { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 2; + throw $e; } // If the last element is .album.jpg, pop that off since it's not a real item @@ -82,22 +86,30 @@ class File_Proxy_Controller extends Controller { } if (!$item->loaded()) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 3; + throw $e; } // Make sure we have access to the item if (!access::can("view", $item)) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 4; + throw $e; } // Make sure we have view_full access to the original if ($type == "albums" && !access::can("view_full", $item)) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 5; + throw $e; } // Don't try to load a directory if ($type == "albums" && $item->is_album()) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 6; + throw $e; } // Note: this code is roughly duplicated in data_rest, so if you modify this, please look to @@ -112,7 +124,9 @@ class File_Proxy_Controller extends Controller { } if (!file_exists($file)) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 7; + throw $e; } header("Content-Length: " . filesize($file)); @@ -146,6 +160,10 @@ class File_Proxy_Controller extends Controller { } } - readfile($file); + if (TEST_MODE) { + return $file; + } else { + readfile($file); + } } } diff --git a/modules/gallery/tests/File_Proxy_Controller_Test.php b/modules/gallery/tests/File_Proxy_Controller_Test.php new file mode 100644 index 00000000..dab2b8f3 --- /dev/null +++ b/modules/gallery/tests/File_Proxy_Controller_Test.php @@ -0,0 +1,130 @@ +_save = array($_SERVER); + } + + public function teardown() { + list($_SERVER) = $this->_save; + identity::set_active_user(identity::admin_user()); + } + + public function basic_test() { + $photo = test::random_photo(); + $_SERVER["REQUEST_URI"] = url::file("var/albums/{$photo->name}"); + $controller = new File_Proxy_Controller(); + $this->assert_same($photo->file_path(), $controller->__call("", array())); + } + + public function query_params_are_ignored_test() { + $photo = test::random_photo(); + $_SERVER["REQUEST_URI"] = url::file("var/albums/{$photo->name}?a=1&b=2"); + $controller = new File_Proxy_Controller(); + $this->assert_same($photo->file_path(), $controller->__call("", array())); + } + + public function file_must_be_in_var_test() { + $_SERVER["REQUEST_URI"] = url::file("index.php"); + $controller = new File_Proxy_Controller(); + try { + $controller->__call("", array()); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + $this->assert_same(1, $e->test_fail_code); + } + } + + public function file_must_be_in_albums_thumbs_or_resizes_test() { + $_SERVER["REQUEST_URI"] = url::file("var/test/var/uploads/.htaccess"); + $controller = new File_Proxy_Controller(); + try { + $controller->__call("", array()); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + $this->assert_same(2, $e->test_fail_code); + } + } + + public function movie_thumbnails_are_jpgs_test() { + $movie = test::random_movie(); + $name = legal_file::change_extension($movie->name, "jpg"); + $_SERVER["REQUEST_URI"] = url::file("var/thumbs/{$movie->name}"); + $controller = new File_Proxy_Controller(); + $this->assert_same($movie->thumb_path(), $controller->__call("", array())); + } + + public function invalid_item_test() { + $photo = test::random_photo(); + $_SERVER["REQUEST_URI"] = url::file("var/albums/x_{$photo->name}"); + $controller = new File_Proxy_Controller(); + try { + $controller->__call("", array()); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + $this->assert_same(3, $e->test_fail_code); + } + } + + public function need_view_full_permission_to_view_original_test() { + $album = test::random_album(); + $photo = test::random_photo($album); + $album = $album->reload(); // adding the photo changed the album in the db + $_SERVER["REQUEST_URI"] = url::file("var/albums/{$album->name}/{$photo->name}"); + $controller = new File_Proxy_Controller(); + + access::deny(identity::everybody(), "view_full", $album); + identity::set_active_user(identity::guest()); + + try { + $controller->__call("", array()); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + $this->assert_same(5, $e->test_fail_code); + } + } + + public function cant_proxy_an_album_test() { + $album = test::random_album(); + $_SERVER["REQUEST_URI"] = url::file("var/albums/{$album->name}"); + $controller = new File_Proxy_Controller(); + + try { + $controller->__call("", array()); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + $this->assert_same(6, $e->test_fail_code); + } + } + + public function missing_file_test() { + $photo = test::random_photo(); + $_SERVER["REQUEST_URI"] = url::file("var/albums/{$photo->name}"); + unlink($photo->file_path()); + $controller = new File_Proxy_Controller(); + + try { + $controller->__call("", array()); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + $this->assert_same(7, $e->test_fail_code); + } + } +} \ No newline at end of file -- cgit v1.2.3 From d45a73777935c86fc5131955831833d7465b5e9d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 21 Jan 2013 01:22:01 -0500 Subject: Update copyright to 2013. Fixes #1953. --- application/Bootstrap.php | 2 +- application/config/config.php | 2 +- index.php | 2 +- installer/cli.php | 2 +- installer/index.php | 2 +- installer/installer.php | 2 +- installer/web.php | 2 +- modules/akismet/controllers/admin_akismet.php | 2 +- modules/akismet/helpers/akismet.php | 2 +- modules/akismet/helpers/akismet_event.php | 2 +- modules/akismet/helpers/akismet_installer.php | 2 +- modules/akismet/tests/Akismet_Helper_Test.php | 2 +- modules/comment/controllers/admin_comments.php | 2 +- modules/comment/controllers/admin_manage_comments.php | 2 +- modules/comment/controllers/comments.php | 2 +- modules/comment/helpers/comment.php | 2 +- modules/comment/helpers/comment_block.php | 2 +- modules/comment/helpers/comment_event.php | 2 +- modules/comment/helpers/comment_installer.php | 2 +- modules/comment/helpers/comment_rest.php | 2 +- modules/comment/helpers/comment_rss.php | 2 +- modules/comment/helpers/comment_theme.php | 2 +- modules/comment/helpers/comments_rest.php | 2 +- modules/comment/helpers/item_comments_rest.php | 2 +- modules/comment/models/comment.php | 2 +- modules/comment/tests/Comment_Event_Test.php | 2 +- modules/comment/tests/Comment_Helper_Test.php | 2 +- modules/comment/tests/Comment_Model_Test.php | 2 +- modules/digibug/config/digibug.php | 2 +- modules/digibug/controllers/admin_digibug.php | 2 +- modules/digibug/controllers/digibug.php | 2 +- modules/digibug/helpers/digibug_event.php | 2 +- modules/digibug/helpers/digibug_installer.php | 2 +- modules/digibug/helpers/digibug_theme.php | 2 +- modules/digibug/models/digibug_proxy.php | 2 +- modules/digibug/tests/Digibug_Controller_Test.php | 2 +- modules/exif/controllers/exif.php | 2 +- modules/exif/helpers/exif.php | 2 +- modules/exif/helpers/exif_event.php | 2 +- modules/exif/helpers/exif_installer.php | 2 +- modules/exif/helpers/exif_task.php | 2 +- modules/exif/helpers/exif_theme.php | 2 +- modules/exif/models/exif_key.php | 2 +- modules/exif/models/exif_record.php | 2 +- modules/exif/tests/Exif_Test.php | 2 +- modules/g2_import/controllers/admin_g2_import.php | 2 +- modules/g2_import/controllers/g2.php | 2 +- modules/g2_import/helpers/g2_import.php | 2 +- modules/g2_import/helpers/g2_import_event.php | 2 +- modules/g2_import/helpers/g2_import_installer.php | 2 +- modules/g2_import/helpers/g2_import_task.php | 2 +- modules/g2_import/libraries/G2_Import_Exception.php | 2 +- modules/g2_import/models/g2_map.php | 2 +- modules/gallery/config/cache.php | 2 +- modules/gallery/config/cookie.php | 2 +- modules/gallery/config/database.php | 2 +- modules/gallery/config/locale.php | 2 +- modules/gallery/config/log_file.php | 2 +- modules/gallery/config/routes.php | 2 +- modules/gallery/config/session.php | 2 +- modules/gallery/config/upload.php | 2 +- modules/gallery/config/user_agents.php | 2 +- modules/gallery/controllers/admin.php | 2 +- modules/gallery/controllers/admin_advanced_settings.php | 2 +- modules/gallery/controllers/admin_dashboard.php | 2 +- modules/gallery/controllers/admin_graphics.php | 2 +- modules/gallery/controllers/admin_languages.php | 2 +- modules/gallery/controllers/admin_maintenance.php | 2 +- modules/gallery/controllers/admin_modules.php | 2 +- modules/gallery/controllers/admin_sidebar.php | 2 +- modules/gallery/controllers/admin_theme_options.php | 2 +- modules/gallery/controllers/admin_themes.php | 2 +- modules/gallery/controllers/admin_upgrade_checker.php | 2 +- modules/gallery/controllers/albums.php | 2 +- modules/gallery/controllers/combined.php | 2 +- modules/gallery/controllers/file_proxy.php | 2 +- modules/gallery/controllers/items.php | 2 +- modules/gallery/controllers/l10n_client.php | 2 +- modules/gallery/controllers/login.php | 2 +- modules/gallery/controllers/logout.php | 2 +- modules/gallery/controllers/movies.php | 2 +- modules/gallery/controllers/packager.php | 2 +- modules/gallery/controllers/permissions.php | 2 +- modules/gallery/controllers/photos.php | 2 +- modules/gallery/controllers/quick.php | 2 +- modules/gallery/controllers/reauthenticate.php | 2 +- modules/gallery/controllers/upgrader.php | 2 +- modules/gallery/controllers/uploader.php | 2 +- modules/gallery/controllers/user_profile.php | 2 +- modules/gallery/controllers/welcome_message.php | 2 +- modules/gallery/helpers/MY_html.php | 2 +- modules/gallery/helpers/MY_num.php | 2 +- modules/gallery/helpers/MY_remote.php | 2 +- modules/gallery/helpers/MY_url.php | 2 +- modules/gallery/helpers/MY_valid.php | 2 +- modules/gallery/helpers/access.php | 2 +- modules/gallery/helpers/ajax.php | 2 +- modules/gallery/helpers/album.php | 2 +- modules/gallery/helpers/auth.php | 2 +- modules/gallery/helpers/batch.php | 2 +- modules/gallery/helpers/block_manager.php | 2 +- modules/gallery/helpers/data_rest.php | 2 +- modules/gallery/helpers/dir.php | 2 +- modules/gallery/helpers/encoding.php | 2 +- modules/gallery/helpers/gallery.php | 2 +- modules/gallery/helpers/gallery_block.php | 2 +- modules/gallery/helpers/gallery_error.php | 2 +- modules/gallery/helpers/gallery_event.php | 2 +- modules/gallery/helpers/gallery_graphics.php | 2 +- modules/gallery/helpers/gallery_installer.php | 2 +- modules/gallery/helpers/gallery_rss.php | 2 +- modules/gallery/helpers/gallery_task.php | 2 +- modules/gallery/helpers/gallery_theme.php | 2 +- modules/gallery/helpers/graphics.php | 2 +- modules/gallery/helpers/identity.php | 2 +- modules/gallery/helpers/item.php | 2 +- modules/gallery/helpers/item_rest.php | 2 +- modules/gallery/helpers/items_rest.php | 2 +- modules/gallery/helpers/json.php | 2 +- modules/gallery/helpers/l10n_client.php | 2 +- modules/gallery/helpers/l10n_scanner.php | 2 +- modules/gallery/helpers/legal_file.php | 2 +- modules/gallery/helpers/locales.php | 2 +- modules/gallery/helpers/log.php | 2 +- modules/gallery/helpers/message.php | 2 +- modules/gallery/helpers/model_cache.php | 2 +- modules/gallery/helpers/module.php | 2 +- modules/gallery/helpers/movie.php | 2 +- modules/gallery/helpers/photo.php | 2 +- modules/gallery/helpers/random.php | 2 +- modules/gallery/helpers/site_status.php | 2 +- modules/gallery/helpers/system.php | 2 +- modules/gallery/helpers/task.php | 2 +- modules/gallery/helpers/theme.php | 2 +- modules/gallery/helpers/tree_rest.php | 2 +- modules/gallery/helpers/upgrade_checker.php | 2 +- modules/gallery/helpers/user_profile.php | 2 +- modules/gallery/helpers/xml.php | 2 +- modules/gallery/hooks/init_gallery.php | 2 +- modules/gallery/libraries/Admin_View.php | 2 +- modules/gallery/libraries/Block.php | 2 +- modules/gallery/libraries/Breadcrumb.php | 2 +- modules/gallery/libraries/Form_Script.php | 2 +- modules/gallery/libraries/Form_Uploadify.php | 2 +- modules/gallery/libraries/Form_Uploadify_buttons.php | 2 +- modules/gallery/libraries/Gallery_I18n.php | 2 +- modules/gallery/libraries/Gallery_View.php | 2 +- modules/gallery/libraries/IdentityProvider.php | 2 +- modules/gallery/libraries/InPlaceEdit.php | 2 +- modules/gallery/libraries/MY_Database.php | 2 +- modules/gallery/libraries/MY_Forge.php | 2 +- modules/gallery/libraries/MY_Input.php | 2 +- modules/gallery/libraries/MY_Kohana_Exception.php | 2 +- modules/gallery/libraries/MY_ORM.php | 2 +- modules/gallery/libraries/MY_View.php | 2 +- modules/gallery/libraries/Menu.php | 2 +- modules/gallery/libraries/ORM_MPTT.php | 2 +- modules/gallery/libraries/SafeString.php | 2 +- modules/gallery/libraries/Sendmail.php | 2 +- modules/gallery/libraries/Task_Definition.php | 2 +- modules/gallery/libraries/Theme_View.php | 2 +- modules/gallery/libraries/drivers/Cache/Database.php | 2 +- modules/gallery/libraries/drivers/IdentityProvider.php | 2 +- modules/gallery/models/access_cache.php | 2 +- modules/gallery/models/access_intent.php | 2 +- modules/gallery/models/cache.php | 2 +- modules/gallery/models/failed_auth.php | 2 +- modules/gallery/models/graphics_rule.php | 2 +- modules/gallery/models/incoming_translation.php | 2 +- modules/gallery/models/item.php | 2 +- modules/gallery/models/log.php | 2 +- modules/gallery/models/message.php | 2 +- modules/gallery/models/module.php | 2 +- modules/gallery/models/outgoing_translation.php | 2 +- modules/gallery/models/permission.php | 2 +- modules/gallery/models/task.php | 2 +- modules/gallery/models/theme.php | 2 +- modules/gallery/models/var.php | 2 +- modules/gallery/tests/Access_Helper_Test.php | 2 +- modules/gallery/tests/Albums_Controller_Test.php | 2 +- modules/gallery/tests/Breadcrumb_Test.php | 2 +- modules/gallery/tests/Cache_Test.php | 2 +- modules/gallery/tests/Controller_Auth_Test.php | 2 +- modules/gallery/tests/Data_Rest_Helper_Test.php | 2 +- modules/gallery/tests/Database_Test.php | 2 +- modules/gallery/tests/Dir_Helper_Test.php | 2 +- modules/gallery/tests/DrawForm_Test.php | 2 +- modules/gallery/tests/File_Proxy_Controller_Test.php | 2 +- modules/gallery/tests/File_Structure_Test.php | 4 ++-- modules/gallery/tests/Gallery_Filters.php | 2 +- modules/gallery/tests/Gallery_I18n_Test.php | 2 +- modules/gallery/tests/Gallery_Installer_Test.php | 2 +- modules/gallery/tests/Html_Helper_Test.php | 2 +- modules/gallery/tests/Input_Library_Test.php | 2 +- modules/gallery/tests/Item_Helper_Test.php | 2 +- modules/gallery/tests/Item_Model_Test.php | 2 +- modules/gallery/tests/Item_Rest_Helper_Test.php | 2 +- modules/gallery/tests/Items_Rest_Helper_Test.php | 2 +- modules/gallery/tests/Kohana_Exception_Test.php | 2 +- modules/gallery/tests/Legal_File_Helper_Test.php | 2 +- modules/gallery/tests/Locales_Helper_Test.php | 2 +- modules/gallery/tests/Menu_Test.php | 2 +- modules/gallery/tests/Movie_Helper_Test.php | 2 +- modules/gallery/tests/Num_Helper_Test.php | 2 +- modules/gallery/tests/ORM_MPTT_Test.php | 2 +- modules/gallery/tests/Photos_Controller_Test.php | 2 +- modules/gallery/tests/SafeString_Test.php | 2 +- modules/gallery/tests/Sendmail_Test.php | 2 +- modules/gallery/tests/System_Helper_Test.php | 2 +- modules/gallery/tests/Url_Security_Test.php | 2 +- modules/gallery/tests/Valid_Test.php | 2 +- modules/gallery/tests/Var_Test.php | 2 +- modules/gallery/tests/Xss_Security_Test.php | 2 +- modules/gallery_unit_test/controllers/gallery_unit_test.php | 2 +- modules/gallery_unit_test/helpers/MY_request.php | 2 +- modules/gallery_unit_test/helpers/test.php | 2 +- modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php | 2 +- modules/image_block/controllers/image_block.php | 2 +- modules/image_block/helpers/image_block_block.php | 2 +- modules/image_block/helpers/image_block_installer.php | 2 +- modules/info/helpers/info_block.php | 2 +- modules/info/helpers/info_installer.php | 2 +- modules/info/helpers/info_theme.php | 2 +- modules/kohana23_compat/config/pagination.php | 2 +- modules/kohana23_compat/libraries/MY_Database_Builder.php | 2 +- modules/kohana23_compat/libraries/Pagination.php | 2 +- modules/notification/controllers/notification.php | 2 +- modules/notification/helpers/notification.php | 2 +- modules/notification/helpers/notification_event.php | 2 +- modules/notification/helpers/notification_installer.php | 2 +- modules/notification/models/pending_notification.php | 2 +- modules/notification/models/subscription.php | 2 +- modules/organize/controllers/organize.php | 2 +- modules/organize/helpers/organize_event.php | 2 +- modules/organize/helpers/organize_installer.php | 2 +- modules/recaptcha/controllers/admin_recaptcha.php | 2 +- modules/recaptcha/helpers/recaptcha.php | 2 +- modules/recaptcha/helpers/recaptcha_event.php | 2 +- modules/recaptcha/helpers/recaptcha_installer.php | 2 +- modules/recaptcha/helpers/recaptcha_theme.php | 2 +- modules/recaptcha/libraries/Form_Recaptcha.php | 2 +- modules/rest/controllers/rest.php | 2 +- modules/rest/helpers/registry_rest.php | 2 +- modules/rest/helpers/rest.php | 2 +- modules/rest/helpers/rest_event.php | 2 +- modules/rest/helpers/rest_installer.php | 2 +- modules/rest/libraries/Rest_Exception.php | 2 +- modules/rest/models/user_access_key.php | 2 +- modules/rest/tests/Rest_Controller_Test.php | 2 +- modules/rss/controllers/rss.php | 2 +- modules/rss/helpers/rss.php | 2 +- modules/rss/helpers/rss_block.php | 2 +- modules/search/controllers/search.php | 2 +- modules/search/helpers/search.php | 2 +- modules/search/helpers/search_event.php | 2 +- modules/search/helpers/search_installer.php | 2 +- modules/search/helpers/search_task.php | 2 +- modules/search/helpers/search_theme.php | 2 +- modules/search/models/search_record.php | 2 +- modules/server_add/controllers/admin_server_add.php | 2 +- modules/server_add/controllers/server_add.php | 2 +- modules/server_add/helpers/server_add.php | 2 +- modules/server_add/helpers/server_add_event.php | 2 +- modules/server_add/helpers/server_add_installer.php | 2 +- modules/server_add/helpers/server_add_theme.php | 2 +- modules/server_add/models/server_add_entry.php | 2 +- modules/slideshow/helpers/slideshow_event.php | 2 +- modules/slideshow/helpers/slideshow_installer.php | 2 +- modules/slideshow/helpers/slideshow_theme.php | 2 +- modules/tag/controllers/admin_tags.php | 2 +- modules/tag/controllers/tag.php | 2 +- modules/tag/controllers/tag_name.php | 2 +- modules/tag/controllers/tags.php | 2 +- modules/tag/helpers/item_tags_rest.php | 2 +- modules/tag/helpers/tag.php | 2 +- modules/tag/helpers/tag_block.php | 2 +- modules/tag/helpers/tag_event.php | 2 +- modules/tag/helpers/tag_installer.php | 2 +- modules/tag/helpers/tag_item_rest.php | 2 +- modules/tag/helpers/tag_items_rest.php | 2 +- modules/tag/helpers/tag_rest.php | 2 +- modules/tag/helpers/tag_rss.php | 2 +- modules/tag/helpers/tag_task.php | 2 +- modules/tag/helpers/tag_theme.php | 2 +- modules/tag/helpers/tags_rest.php | 2 +- modules/tag/models/tag.php | 2 +- modules/tag/tests/Tag_Item_Rest_Helper_Test.php | 2 +- modules/tag/tests/Tag_Rest_Helper_Test.php | 2 +- modules/tag/tests/Tag_Test.php | 2 +- modules/tag/tests/Tags_Rest_Helper_Test.php | 2 +- modules/user/config/identity.php | 2 +- modules/user/controllers/admin_users.php | 2 +- modules/user/controllers/password.php | 2 +- modules/user/controllers/users.php | 2 +- modules/user/helpers/group.php | 2 +- modules/user/helpers/user.php | 2 +- modules/user/helpers/user_event.php | 2 +- modules/user/helpers/user_installer.php | 2 +- modules/user/helpers/user_theme.php | 2 +- modules/user/libraries/drivers/IdentityProvider/Gallery.php | 2 +- modules/user/models/group.php | 2 +- modules/user/models/user.php | 2 +- modules/user/tests/No_Direct_ORM_Access_Test.php | 2 +- modules/user/tests/User_Groups_Test.php | 2 +- modules/user/tests/User_Installer_Test.php | 2 +- modules/watermark/controllers/admin_watermarks.php | 2 +- modules/watermark/helpers/watermark.php | 2 +- modules/watermark/helpers/watermark_event.php | 2 +- modules/watermark/helpers/watermark_installer.php | 2 +- 309 files changed, 310 insertions(+), 310 deletions(-) (limited to 'modules/gallery/controllers/file_proxy.php') diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 183705d9..93353b47 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -1,7 +1,7 @@ Date: Mon, 21 Jan 2013 10:45:34 +0100 Subject: #1954 - Skip buffer calls for unit tests of file_proxy and data_rest. Moved the "if (TEST_MODE)" statement before the buffer calls in file_proxy and data_rest. This has no impact on normal use, but will make the unit tests more compatible with different server/PHP configurations. Note: We do not have to skip setting the headers, which means we can build unit tests around them if we wish. --- modules/gallery/controllers/file_proxy.php | 25 ++++++++++++------------- modules/gallery/helpers/data_rest.php | 11 ++++++----- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'modules/gallery/controllers/file_proxy.php') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index f29cdf98..a9e98ce1 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -147,22 +147,21 @@ class File_Proxy_Controller extends Controller { header("Content-Type: $item->mime_type"); } - // Don't use Kohana::close_buffers(false) here because that only closes all the buffers - // that Kohana started. We want to close *all* buffers at this point because otherwise we're - // going to buffer up whatever file we're proxying (and it may be very large). This may - // affect embedding or systems with PHP's output_buffering enabled. - while (ob_get_level()) { - Kohana_Log::add("error","".print_r(ob_get_level(),1)); - if (!@ob_end_clean()) { - // ob_end_clean() can return false if the buffer can't be removed for some reason - // (zlib output compression buffers sometimes cause problems). - break; - } - } - if (TEST_MODE) { return $file; } else { + // Don't use Kohana::close_buffers(false) here because that only closes all the buffers + // that Kohana started. We want to close *all* buffers at this point because otherwise we're + // going to buffer up whatever file we're proxying (and it may be very large). This may + // affect embedding or systems with PHP's output_buffering enabled. + while (ob_get_level()) { + Kohana_Log::add("error","".print_r(ob_get_level(),1)); + if (!@ob_end_clean()) { + // ob_end_clean() can return false if the buffer can't be removed for some reason + // (zlib output compression buffers sometimes cause problems). + break; + } + } readfile($file); } } diff --git a/modules/gallery/helpers/data_rest.php b/modules/gallery/helpers/data_rest.php index 8a3a159d..dc213510 100644 --- a/modules/gallery/helpers/data_rest.php +++ b/modules/gallery/helpers/data_rest.php @@ -57,13 +57,14 @@ class data_rest_Core { } else { header("Content-Type: $item->mime_type"); } - Kohana::close_buffers(false); - if (isset($p->encoding) && $p->encoding == "base64") { - print base64_encode(file_get_contents($file)); + if (TEST_MODE) { + return $file; } else { - if (TEST_MODE) { - return $file; + Kohana::close_buffers(false); + + if (isset($p->encoding) && $p->encoding == "base64") { + print base64_encode(file_get_contents($file)); } else { readfile($file); } -- cgit v1.2.3 From 86a2759062ee3dbf93f4c17c7499e3f506035047 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 24 Jan 2013 18:14:14 -0500 Subject: If profiling is enabled, dump out profiling data instead of proxied images so that we can see how efficient our proxying is. Follow-on for #1959. --- modules/gallery/controllers/file_proxy.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'modules/gallery/controllers/file_proxy.php') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index a9e98ce1..7e5d0038 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -129,6 +129,13 @@ class File_Proxy_Controller extends Controller { throw $e; } + if (gallery::show_profiler()) { + Profiler::enable(); + $profiler = new Profiler(); + $profiler->render(); + exit; + } + header("Content-Length: " . filesize($file)); header("Pragma:"); -- cgit v1.2.3