From 1634782e80dbdff8a1c0ae118a3d9fccc9892b07 Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Mon, 1 Jun 2026 20:18:40 +0100 Subject: Guard null pFileHash type in preg_match/preg_split calls — PHP 8.x deprecation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- includes/liberty_lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/liberty_lib.php b/includes/liberty_lib.php index 810fdd0..0dcdb79 100755 --- a/includes/liberty_lib.php +++ b/includes/liberty_lib.php @@ -703,7 +703,7 @@ function liberty_generate_thumbnails( $pFileHash ) { : [ 'extra-large','large', 'medium', 'small', 'avatar', 'icon' ]; } - if( ( !preg_match( '#image/(gif|jpe?g|png)#i', $pFileHash['type'] ) && $gBitSystem->isFeatureActive( 'liberty_jpeg_originals' )) || in_array( 'original', $pFileHash['thumbnail_sizes'] ) ) { + if( ( !preg_match( '#image/(gif|jpe?g|png)#i', $pFileHash['type'] ?? '' ) && $gBitSystem->isFeatureActive( 'liberty_jpeg_originals' )) || in_array( 'original', $pFileHash['thumbnail_sizes'] ) ) { // jpeg version of original if( preg_match( '/pdf/i', $pFileHash['type'] ) ) { // has a customer pdf rasterization function been defined? @@ -747,10 +747,10 @@ function liberty_generate_thumbnails( $pFileHash ) { if( $gBitSystem->isFeatureActive( 'liberty_thumbnail_format' )) { $mimeExt = $gBitSystem->getConfig( 'liberty_thumbnail_format' ); } else { - list( $type, $mimeExt ) = preg_split( '#/#', strtolower( $pFileHash['type'] )); + list( $type, $mimeExt ) = preg_split( '#/#', strtolower( $pFileHash['type'] ?? '' )); } - $destExt = preg_match( "!(png|gif)!", $mimeExt ) ? '.'.$mimeExt : '.jpg'; + $destExt = preg_match( "!(png|gif)!", $mimeExt ?? '' ) ? '.'.$mimeExt : '.jpg'; $initialDestPath = $pFileHash['dest_branch']; foreach( $pFileHash['thumbnail_sizes'] as $thumbSize ) { -- cgit v1.3