From 5bdc810b084cb733d76f4c40c86bf9ae35f1aec6 Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Tue, 2 Jun 2026 13:49:40 +0100 Subject: 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 --- plugins/mime.pdf.php | 12 ++++++++++-- 1 file 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'] )) ) { -- cgit v1.3