From 3c295abd66121d84a10487bca91ceea10713ea78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Fri, 11 Aug 2017 21:55:46 +0200 Subject: [PATCH] [ticket/15286] Remove download_mode PHPBB3-15286 --- phpBB/download/file.php | 24 +----------- phpBB/includes/acp/acp_attachments.php | 5 --- phpBB/includes/constants.php | 5 --- phpBB/install/convertors/convert_phpbb20.php | 1 - phpBB/install/schemas/schema_data.sql | 12 +++--- phpBB/phpbb/cache/service.php | 1 - .../v330/remove_attachment_download_mode.php | 39 +++++++++++++++++++ tests/attachment/fixtures/resync.xml | 2 - 8 files changed, 47 insertions(+), 42 deletions(-) create mode 100644 phpBB/phpbb/db/migration/data/v330/remove_attachment_download_mode.php diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 23658db5d3..dd9df06f08 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -254,7 +254,6 @@ else } } - $download_mode = (int) $extensions[$attachment['extension']]['download_mode']; $display_cat = $extensions[$attachment['extension']]['display_cat']; if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !$user->optionget('viewimg')) @@ -274,7 +273,6 @@ else * @var int attach_id The attachment ID * @var array attachment Array with attachment data * @var int display_cat Attachment category - * @var int download_mode File extension specific download mode * @var array extensions Array with file extensions data * @var string mode Download mode * @var bool thumbnail Flag indicating if the file is a thumbnail @@ -285,7 +283,6 @@ else 'attach_id', 'attachment', 'display_cat', - 'download_mode', 'extensions', 'mode', 'thumbnail', @@ -309,24 +306,7 @@ else } else { - // - // Determine the 'presenting'-method - if ($download_mode == PHYSICAL_LINK) - { - // This presenting method should no longer be used - if (!@is_dir($phpbb_root_path . $config['upload_path'])) - { - send_status_line(500, 'Internal Server Error'); - trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']); - } - - redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']); - file_gc(); - } - else - { - send_file_to_browser($attachment, $display_cat); - file_gc(); - } + send_file_to_browser($attachment, $display_cat); + file_gc(); } } diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index c735c6265b..acb5d7d6e5 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -586,11 +586,6 @@ class acp_attachments 'allow_in_pm' => ($allow_in_pm) ? 1 : 0, ); - if ($action == 'add') - { - $group_ary['download_mode'] = INLINE_LINK; - } - $sql = ($action == 'add') ? 'INSERT INTO ' . EXTENSION_GROUPS_TABLE . ' ' : 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' SET '; $sql .= $db->sql_build_array((($action == 'add') ? 'INSERT' : 'UPDATE'), $group_ary); $sql .= ($action == 'edit') ? " WHERE group_id = $group_id" : ''; diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 6460a1ae7c..2fa11e4d86 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -157,11 +157,6 @@ define('FULL_FOLDER_NONE', -3); define('FULL_FOLDER_DELETE', -2); define('FULL_FOLDER_HOLD', -1); -// Download Modes - Attachments -define('INLINE_LINK', 1); -// This mode is only used internally to allow modders extending the attachment functionality -define('PHYSICAL_LINK', 2); - // Confirm types define('CONFIRM_REG', 1); define('CONFIRM_LOGIN', 2); diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php index d0885dc620..60f3550651 100644 --- a/phpBB/install/convertors/convert_phpbb20.php +++ b/phpBB/install/convertors/convert_phpbb20.php @@ -439,7 +439,6 @@ if (!$get_info) array('group_name', 'extension_groups.group_name', array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')), array('cat_id', 'extension_groups.cat_id', 'phpbb_attachment_category'), array('allow_group', 'extension_groups.allow_group', ''), - array('download_mode', 1, ''), array('upload_icon', '', ''), array('max_filesize', 'extension_groups.max_filesize', ''), array('allowed_forums', 'extension_groups.forum_permissions', 'phpbb_attachment_forum_perms'), diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index c802480eea..c6a60af67b 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -730,12 +730,12 @@ INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_orde INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('other', '{L_REPORT_OTHER}', 4); # -- extension_groups -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('IMAGES', 1, 1, 1, '', 0, ''); -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('ARCHIVES', 0, 1, 1, '', 0, ''); -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('PLAIN_TEXT', 0, 0, 1, '', 0, ''); -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('DOCUMENTS', 0, 0, 1, '', 0, ''); -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('FLASH_FILES', 5, 0, 1, '', 0, ''); -INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('DOWNLOADABLE_FILES', 0, 0, 1, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, upload_icon, max_filesize, allowed_forums) VALUES ('IMAGES', 1, 1, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, upload_icon, max_filesize, allowed_forums) VALUES ('ARCHIVES', 0, 1, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, upload_icon, max_filesize, allowed_forums) VALUES ('PLAIN_TEXT', 0, 0, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, upload_icon, max_filesize, allowed_forums) VALUES ('DOCUMENTS', 0, 0, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, upload_icon, max_filesize, allowed_forums) VALUES ('FLASH_FILES', 5, 0, '', 0, ''); +INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, upload_icon, max_filesize, allowed_forums) VALUES ('DOWNLOADABLE_FILES', 0, 0, '', 0, ''); # -- extensions INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'gif'); diff --git a/phpBB/phpbb/cache/service.php b/phpBB/phpbb/cache/service.php index 502ae27625..2d4e55bfbb 100644 --- a/phpBB/phpbb/cache/service.php +++ b/phpBB/phpbb/cache/service.php @@ -214,7 +214,6 @@ class service $extensions[$extension] = array( 'display_cat' => (int) $row['cat_id'], - 'download_mode' => (int) $row['download_mode'], 'upload_icon' => trim($row['upload_icon']), 'max_filesize' => (int) $row['max_filesize'], 'allow_group' => $row['allow_group'], diff --git a/phpBB/phpbb/db/migration/data/v330/remove_attachment_download_mode.php b/phpBB/phpbb/db/migration/data/v330/remove_attachment_download_mode.php new file mode 100644 index 0000000000..f943d7fa25 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v330/remove_attachment_download_mode.php @@ -0,0 +1,39 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v330; + +class remove_attachment_download_mode extends \phpbb\db\migration\migration +{ + public function update_data() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'extension_groups' => array( + 'download_mode', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'extension_groups' => array( + 'download_mode' => array('BOOL', '1'), + ), + ), + ); + } +} diff --git a/tests/attachment/fixtures/resync.xml b/tests/attachment/fixtures/resync.xml index af04701b4a..b06d2db3e2 100644 --- a/tests/attachment/fixtures/resync.xml +++ b/tests/attachment/fixtures/resync.xml @@ -58,7 +58,6 @@ cat_idgroup_id - download_modeupload_iconmax_filesizeallow_group @@ -66,7 +65,6 @@ allowed_forumsgroup_name - 1 1 1