diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-06-01 20:18:40 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-06-01 20:18:40 +0100 |
| commit | 1634782e80dbdff8a1c0ae118a3d9fccc9892b07 (patch) | |
| tree | caf0c24052ae9e3d73bf384413a6836a22816882 | |
| parent | ea5b0aa39b86d8a7c474d357616d76298477ed5e (diff) | |
| download | liberty-1634782e80dbdff8a1c0ae118a3d9fccc9892b07.tar.gz liberty-1634782e80dbdff8a1c0ae118a3d9fccc9892b07.tar.bz2 liberty-1634782e80dbdff8a1c0ae118a3d9fccc9892b07.zip | |
Guard null pFileHash type in preg_match/preg_split calls — PHP 8.x deprecation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rwxr-xr-x | includes/liberty_lib.php | 6 |
1 files 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 ) { |
