Loading...
 
Skip to main content

Article own image is lost if changing the classification of the article

Status
Open
Subject
Article own image is lost if changing the classification of the article
Version
29.x
Regression from 28.x to 29.x
Category
  • Bug
  • Regression
  • Easy for Newbie Dev
Feature
Article
Resolution status
New
Submitted by
Bernard Sfez / Tiki Specialist
Lastmod by
Bernard Sfez / Tiki Specialist
Rating
(0)
Description

As seen in the video attached to this item. (demo tiki)
The own image article is lost if the classification (topic or type) of an article is changed.

To reproduce;
In the Tiki Articles I create an article and set his own image.
I save, the image is displayed.

I edit the article change the topic or the type of the article and save.
The image is gone.
It was working fine, this is a regression on Tiki 29.

Files
  1. Screen Recording 2026 02 23 At 11.41.32
Solution
Workaround

I fixed by replacing some code at tiki-edit_article.php around line 531

before
Copy to clipboard
$imgdata = urldecode($_REQUEST['image_data']); if (strlen($imgdata) > 0) { $hasImage = 'y'; } $imgname = $_REQUEST['image_name']; $imgtype = $_REQUEST['image_type']; $imgsize = $_REQUEST['image_size']; if (isset($_FILES['userfile1'])) { if (is_uploaded_file($_FILES['userfile1']['tmp_name'])) { $filegallib = TikiLib::lib('filegal'); try { $filegallib->assertUploadedFileIsSafe($_FILES['userfile1']['tmp_name'], $_FILES['userfile1']['name']); } catch (Exception $e) { Feedback::errorAndDie($e->getMessage(), \Laminas\Http\Response::STATUS_CODE_403); } $file_name = $_FILES['userfile1']['name']; $file_tmp_name = $_FILES['userfile1']['tmp_name']; $tmp_dest = $prefs['tmpDir'] . '/' . $file_name . '.tmp'; if (! move_uploaded_file($file_tmp_name, $tmp_dest)) { Feedback::errorAndDie(tra('Errors detected'), \Laminas\Http\Response::STATUS_CODE_409); } $fp = fopen($tmp_dest, 'rb'); if (! $fp && $_FILES['userfile1']['error']) { Feedback::error($artlib->uploaded_file_error($_FILES['userfile1']['error'])); } $imgdata = fread($fp, filesize($tmp_dest)); if (! $imgdata && isset($_FILES['userfile1']['error'])) { Feedback::error($artlib->uploaded_file_error($_FILES['userfile1']['error'])); } fclose($fp); if (is_file($tmp_dest)) { @unlink($tmp_dest); } $imgtype = $_FILES['userfile1']['type']; $imgsize = $_FILES['userfile1']['size']; $imgname = $_FILES['userfile1']['name']; } }

after
Copy to clipboard
// Only use image data from form if a new file was uploaded if (isset($_FILES['userfile1']) && is_uploaded_file($_FILES['userfile1']['tmp_name'])) { $filegallib = TikiLib::lib('filegal'); try { $filegallib->assertUploadedFileIsSafe($_FILES['userfile1']['tmp_name'], $_FILES['userfile1']['name']); } catch (Exception $e) { Feedback::errorAndDie($e->getMessage(), \Laminas\Http\Response::STATUS_CODE_403); } $file_name = $_FILES['userfile1']['name']; $file_tmp_name = $_FILES['userfile1']['tmp_name']; $tmp_dest = $prefs['tmpDir'] . '/' . $file_name . '.tmp'; if (! move_uploaded_file($file_tmp_name, $tmp_dest)) { Feedback::errorAndDie(tra('Errors detected'), \Laminas\Http\Response::STATUS_CODE_409); } $fp = fopen($tmp_dest, 'rb'); if (! $fp && $_FILES['userfile1']['error']) { Feedback::error($artlib->uploaded_file_error($_FILES['userfile1']['error'])); } $imgdata = fread($fp, filesize($tmp_dest)); if (! $imgdata && isset($_FILES['userfile1']['error'])) { Feedback::error($artlib->uploaded_file_error($_FILES['userfile1']['error'])); } fclose($fp); if (is_file($tmp_dest)) { @unlink($tmp_dest); } $imgtype = $_FILES['userfile1']['type']; $imgsize = $_FILES['userfile1']['size']; $imgname = $_FILES['userfile1']['name']; } elseif ($articleId) { // No new image uploaded — preserve existing image from DB $existing = $artlib->get_article($articleId); $imgdata = $existing['image_data']; $imgname = $existing['image_name']; $imgtype = $existing['image_type']; $imgsize = $existing['image_size']; } else { $imgdata = ''; $imgname = ''; $imgtype = ''; $imgsize = ''; } if (strlen($imgdata) > 0) { $hasImage = 'y'; }
Importance
6
Easy to solve?
5
Priority
30
Demonstrate Bug on Tiki 19+
Demonstrate Bug (older Tiki versions)
Ticket ID
8932
Created
Monday 23 February, 2026 10:49:51 UTC
by Bernard Sfez / Tiki Specialist
LastModif
Monday 23 February, 2026 11:13:07 UTC


Show PHP error messages