Fullscreen
Loading...
 
Skip to main content

Deletion of forum attachment does not remove linked file

Status
Closed
Subject
Deletion of forum attachment does not remove linked file
Version
1.9.x
Category
  • Error
Feature
Forum
Resolution status
Fixed or Solved
Submitted by
Nelson Ko
Lastmod by
pkdille
Rating
(0)
Description

As described in title. Problem exists when forum attachments are stored in linked files (vs. database)

Something should be done also for case where forum topic or thread is deleted. function remove_comment($threadId) does not do this either.

Problem is that the following function in commentslib.php does not delete linked file
function remove_thread_attachment($attId) {
232 $query = "delete from `tiki_forum_attachments` where `attId`=?";
233
234 $this->query($query,array($attId));
235 }


Solution

Possible solution:

function remove_thread_attachment($attId) {

$path = $this->getOne("select `path` from `tiki_forum_attachments` where `attId`=$attId");
$dir = $this->getOne("select `dir` from `tiki_forum_attachments` where `attId`=$attId");

if ($path) {
@unlink ($dir . $path);
}

$query = "delete from `tiki_forum_attachments` where `attId`=?";

$this->query($query,array($attId));
}

Tested on 2008-10-11 on tiki 3.0. Fixed

Importance
7
Priority
35
Demonstrate Bug on Tiki 19+
Demonstrate Bug (older Tiki versions)
Ticket ID
926
Created
Tuesday 31 October, 2006 15:41:44 UTC
by Unknown
LastModif
Saturday 11 October, 2008 05:46:02 UTC


Show PHP error messages