Skip to content

Conversation

@CySSoO
Copy link
Contributor

@CySSoO CySSoO commented Oct 27, 2025

Summary

  • preserve uploaded modal filenames by saving them in product-specific directories and returning preview metadata
  • expose preview data in the admin product modal tab with timestamped URLs for cache busting
  • update the product modal uploader JavaScript to refresh links and previews after uploads or deletions

Testing

  • php -l everblock.php

https://chatgpt.com/codex/tasks/task_e_68ff623cdd648322b2c3feb462bd1b8a

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1152 to 1166
$targetDir = $this->ensureModalDirectory($productId);

if (!empty($modal->file)) {
$oldFile = _PS_IMG_DIR_ . 'cms/' . $modal->file;
if (file_exists($oldFile)) {
@unlink($oldFile);
$this->cleanupModalDirectory(dirname($oldFile));
}
}

$extension = pathinfo($uploadedFile['name'], PATHINFO_EXTENSION);
if ($extension) {
$extension = Tools::strtolower($extension);
}

$fileName = uniqid('everblock_modal_');
if (!empty($extension)) {
$fileName .= '.' . $extension;
}
$fileName = $this->sanitizeModalFileName($uploadedFile['name']);
$destinationPath = $targetDir . $fileName;

if (!move_uploaded_file($uploadedFile['tmp_name'], $dir . $fileName)) {
if (!move_uploaded_file($uploadedFile['tmp_name'], $destinationPath)) {
$response['message'] = $this->l('Unable to move the uploaded file.');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve modal directory before moving replacement uploads

When replacing an existing modal file the code deletes the product’s directory by calling cleanupModalDirectory(dirname($oldFile)) immediately after @unlink. Because this happens before move_uploaded_file runs, the directory no longer exists and the move fails, yielding the "Unable to move the uploaded file" response whenever a product already had a modal file. The same ordering appears later in the product update hook. Cleanup should only occur when no new file is saved or after the new file has been successfully written so the destination folder still exists for the upload.

Useful? React with 👍 / 👎.

@CySSoO CySSoO merged commit 7f16e8d into master Oct 27, 2025
0 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants