summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-02 13:49:40 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-02 13:49:40 +0100
commit5bdc810b084cb733d76f4c40c86bf9ae35f1aec6 (patch)
treec41a2af1f30d0118b614069bdd5ba0fce9583015 /plugins
parente24698d986bf3e145fa753f13c50704249f964d3 (diff)
downloadliberty-5bdc810b084cb733d76f4c40c86bf9ae35f1aec6.tar.gz
liberty-5bdc810b084cb733d76f4c40c86bf9ae35f1aec6.tar.bz2
liberty-5bdc810b084cb733d76f4c40c86bf9ae35f1aec6.zip
mime_pdf_update: add reload_pdf branch for non-upload text re-extraction
When source_file is already in pStoreRow (e.g. called from a non-fisheye context with reload_pdf set), re-extract the text layer without replacing the stored file. Fisheye handles this via edit_image.php directly; this branch covers other call sites. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mime.pdf.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/plugins/mime.pdf.php b/plugins/mime.pdf.php
index d2cbe77..031c39f 100644
--- a/plugins/mime.pdf.php
+++ b/plugins/mime.pdf.php
@@ -106,15 +106,23 @@ function mime_pdf_update( &$pStoreRow, $pParams = null ) {
// this will set the correct pluign guid, even if we let default handle the store process
$pStoreRow['attachment_plugin_guid'] = PLUGIN_MIME_GUID_PDF;
- // We process the pdf to extract the text layer to include with the save.
if( !empty( $pStoreRow['upload'] ) ) {
+ // New file uploaded — extract text and replace stored file
if( mime_pdf_text_extract( $pStoreRow ) ) {
$ret = mime_default_update( $pStoreRow );
} else {
- // if it all goes tits up, we'll know why
$pStoreRow['errors'] = $pStoreRow['log'];
$ret = false;
}
+ } elseif( !empty( $pStoreRow['reload_pdf'] ) && !empty( $pStoreRow['source_file'] ) ) {
+ // Re-extract text from existing file on disk without re-uploading
+ $pStoreRow['upload'] = ['source_file' => $pStoreRow['source_file']];
+ mime_pdf_text_extract( $pStoreRow );
+ unset( $pStoreRow['upload'] );
+ if( !empty( $pStoreRow['data'] ) ) {
+ $sql = "UPDATE `".BIT_DB_PREFIX."liberty_content` SET `data` = ? WHERE `content_id` = ?";
+ $gBitSystem->mDb->query( $sql, [$pStoreRow['data'], $pStoreRow['content_id']] );
+ }
}
if( $gBitSystem->getConfig( 'pdf_thumbnails', 'y' ) == 'y' && (!empty( $pStoreRow['source_file'] ) || !empty( $pStoreRow['upload'] )) ) {