Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cancan101
Copy link
Contributor

Changes in this pull request

Resolves #

Additional info

@github-actions
Copy link

github-actions bot commented Jul 9, 2025

Review Checklist

  • Target branch (11.5 for bug fixes, others 11.x)
  • Tests (if it's testable code, there should be a test for it - get help)
  • Docs (every functionality needs to be documented, see here)
  • Migration incl. install.sql (e.g. if the database schema changes, ...)
  • Upgrade notes (deprecations, important information, migration hints, ...)
  • Label
  • Milestone

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 9, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
D Maintainability Rating on New Code (required ≥ A)
1 New Major Issues (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@fashxp
Copy link
Member

fashxp commented Jul 9, 2025

Didn't look in detail, but what happens if a new version of the PDF is uploaded? Is it checked again in that case?

@cancan101
Copy link
Contributor Author

I don't know, that is a good question.

That said, if the value is not cleared out / reset on a new upload, then there is a bug now: the flag will show "safe" until this upload handler is run and there is no guarantee if / when it will run.

@fashxp
Copy link
Member

fashxp commented Jul 9, 2025

This is now just speculation: but if on upload (or save) checkIfPdfContainsJS is called, right now the check would restarted and updated.
After the change of this PR, not any more.

@cancan101
Copy link
Contributor Author

After the change of this PR, not any more.

Agreed, and this PR might be "bad".

My only point above was that checkIfPdfContainsJS is called asynchronously as part of AssetUpdateTasksHandler so unless the flag is cleared synchronously on / as part of the re-upload, the safe flag will remain set until / if the handler is re-run.

@fashxp
Copy link
Member

fashxp commented Jul 9, 2025

that is a good point 👍

@cancan101
Copy link
Contributor Author

What would be the best way to clear the scan status upon a new upload?
perhaps adding logic here:

pimcore/models/Asset.php

Lines 595 to 599 in 83a8866

if ($this->getDataChanged()) {
if (in_array($this->getType(), ['image', 'video', 'document'])) {
$this->addToUpdateTaskQueue();
}
}

e.g.:

 if ($this->getDataChanged()) { 
     if ($this->getType() === 'document') {
        $this->setCustomSetting(
            self::CUSTOM_SETTING_PDF_SCAN_STATUS,
            null
        );
     }
     if (in_array($this->getType(), ['image', 'video', 'document'])) { 
         $this->addToUpdateTaskQueue(); 
     } 
 } 

@astapc astapc added the Bug label Aug 8, 2025
@robertSt7
Copy link
Contributor

What would be the best way to clear the scan status upon a new upload? perhaps adding logic here:

pimcore/models/Asset.php

Lines 595 to 599 in 83a8866

if ($this->getDataChanged()) {
if (in_array($this->getType(), ['image', 'video', 'document'])) {
$this->addToUpdateTaskQueue();
}
}

e.g.:

 if ($this->getDataChanged()) { 
     if ($this->getType() === 'document') {
        $this->setCustomSetting(
            self::CUSTOM_SETTING_PDF_SCAN_STATUS,
            null
        );
     }
     if (in_array($this->getType(), ['image', 'video', 'document'])) { 
         $this->addToUpdateTaskQueue(); 
     } 
 } 

@cancan101 Unfortunately that doesn't work, because in addToUpdateTaskQueue we only pass the id not the Asset. Due to this you need to set the scan status before saving the version, but then you have an endless loop, because it's re scaning and saving again. In my opinion we need an additional CustomSetting for Scanning Time, which we set after the scanning process before saving and then compare this with the actual Modification Time. What do you think?

@robertSt7 robertSt7 self-assigned this Aug 12, 2025
@cancan101
Copy link
Contributor Author

You could also call save and pass in a parameter?

// check here for updateScanStatus
if ($this->getDataChanged()) { 
     if ($this->getType() === 'document' && $this->getCustomSetting(self::CUSTOM_SETTING_PDF_SCAN_STATUS) != null {
        $this->setCustomSetting(
            self::CUSTOM_SETTING_PDF_SCAN_STATUS,
            null
        );
        $this->save([updateScanStatus => true]);
     }
     if (in_array($this->getType(), ['image', 'video', 'document'])) { 
         $this->addToUpdateTaskQueue(); 
     } 
 } 

@robertSt7
Copy link
Contributor

You could also call save and pass in a parameter?

// check here for updateScanStatus
if ($this->getDataChanged()) { 
     if ($this->getType() === 'document' && $this->getCustomSetting(self::CUSTOM_SETTING_PDF_SCAN_STATUS) != null {
        $this->setCustomSetting(
            self::CUSTOM_SETTING_PDF_SCAN_STATUS,
            null
        );
        $this->save([updateScanStatus => true]);
     }
     if (in_array($this->getType(), ['image', 'video', 'document'])) { 
         $this->addToUpdateTaskQueue(); 
     } 
 } 

@cancan101 Yes this is possible, but then you have 2 system saved versions in the history, which feels a little bit wrong

@cancan101
Copy link
Contributor Author

You could disable creating version

@robertSt7
Copy link
Contributor

You could disable creating version

@cancan101 Sounds good for me. Could you please implement this? Thank you in advance

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.

4 participants