aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_admin.php
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2015-09-23 10:17:38 +0200
committerMarc Alexander <admin@m-a-styles.de>2015-10-09 10:18:31 +0200
commit04786313892df25f5adce555ebae6b2e5ad4d222 (patch)
treef02c037a6c853945f384c31169494236172ad4f6 /phpBB/includes/functions_admin.php
parent8d03b9e001526fb237cdb744dd832c1dd4182d01 (diff)
downloadforums-04786313892df25f5adce555ebae6b2e5ad4d222.tar
forums-04786313892df25f5adce555ebae6b2e5ad4d222.tar.gz
forums-04786313892df25f5adce555ebae6b2e5ad4d222.tar.bz2
forums-04786313892df25f5adce555ebae6b2e5ad4d222.tar.xz
forums-04786313892df25f5adce555ebae6b2e5ad4d222.zip
[ticket/14168] Move phpbb_unlink() into attachment delete class
PHPBB3-14168
Diffstat (limited to 'phpBB/includes/functions_admin.php')
-rw-r--r--phpBB/includes/functions_admin.php24
1 files changed, 8 insertions, 16 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 228de95996..8928aeb2d6 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -1243,27 +1243,19 @@ function update_posted_info(&$topic_ids)
/**
* Delete attached file
+*
+* @deprecated 3.2.0-a1 (To be removed: 3.4.0)
*/
function phpbb_unlink($filename, $mode = 'file', $entry_removed = false)
{
- global $db, $phpbb_root_path, $config;
-
- // Because of copying topics or modifications a physical filename could be assigned more than once. If so, do not remove the file itself.
- $sql = 'SELECT COUNT(attach_id) AS num_entries
- FROM ' . ATTACHMENTS_TABLE . "
- WHERE physical_filename = '" . $db->sql_escape(utf8_basename($filename)) . "'";
- $result = $db->sql_query($sql);
- $num_entries = (int) $db->sql_fetchfield('num_entries');
- $db->sql_freeresult($result);
+ global $phpbb_container;;
- // Do not remove file if at least one additional entry with the same name exist.
- if (($entry_removed && $num_entries > 0) || (!$entry_removed && $num_entries > 1))
- {
- return false;
- }
+ /** @var \phpbb\attachment\delete $attachment_delete */
+ $attachment_delete = $phpbb_container->get('attachment.delete');
+ $unlink = $attachment_delete->unlink_attachment($filename, $mode, $entry_removed);
+ unset($attachment_delete);
- $filename = ($mode == 'thumbnail') ? 'thumb_' . utf8_basename($filename) : utf8_basename($filename);
- return @unlink($phpbb_root_path . $config['upload_path'] . '/' . $filename);
+ return $unlink;
}
/**