fix: remove remaining @ suppression, check Folder::create() returns
- Remove @getimagesize() suppression in ImageHelper, ImageGenerator, MokoOG — let PHP report warnings for corrupt/unreadable images - Add Log::add() when ImageHelper::resize() cannot read image dimensions - Check Folder::create() return value in ImageGenerator and ImageHelper, return graceful fallback if directory creation fails
This commit is contained in:
@@ -686,7 +686,7 @@ final class MokoOG extends CMSPlugin implements SubscriberInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
$info = @getimagesize($absPath);
|
||||
$info = getimagesize($absPath);
|
||||
|
||||
if (!$info) {
|
||||
return null;
|
||||
|
||||
@@ -63,8 +63,10 @@ class ImageGenerator
|
||||
|
||||
$outputDir = JPATH_ROOT . '/' . self::OUTPUT_DIR;
|
||||
|
||||
if (!is_dir($outputDir)) {
|
||||
Folder::create($outputDir);
|
||||
if (!is_dir($outputDir) && !Folder::create($outputDir)) {
|
||||
Log::add('MokoOG ImageGenerator: Cannot create output directory: ' . self::OUTPUT_DIR, Log::WARNING, 'mokoog');
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
$hash = md5($title . $templateImage . $fontSize);
|
||||
@@ -78,7 +80,7 @@ class ImageGenerator
|
||||
}
|
||||
|
||||
// Load template image
|
||||
$imageInfo = @getimagesize($templateAbs);
|
||||
$imageInfo = getimagesize($templateAbs);
|
||||
|
||||
if (!$imageInfo) {
|
||||
Log::add('MokoOG ImageGenerator: Cannot read image dimensions: ' . $templateImage, Log::WARNING, 'mokoog');
|
||||
|
||||
@@ -64,9 +64,11 @@ class ImageHelper
|
||||
return $imagePath;
|
||||
}
|
||||
|
||||
$imageInfo = @getimagesize($absPath);
|
||||
$imageInfo = getimagesize($absPath);
|
||||
|
||||
if (!$imageInfo) {
|
||||
Log::add('MokoOG ImageHelper: Cannot read image dimensions: ' . basename($absPath), Log::WARNING, 'mokoog');
|
||||
|
||||
return $imagePath;
|
||||
}
|
||||
|
||||
@@ -80,8 +82,10 @@ class ImageHelper
|
||||
// Ensure output directory exists
|
||||
$outputDir = JPATH_ROOT . '/' . self::OUTPUT_DIR;
|
||||
|
||||
if (!is_dir($outputDir)) {
|
||||
Folder::create($outputDir);
|
||||
if (!is_dir($outputDir) && !Folder::create($outputDir)) {
|
||||
Log::add('MokoOG ImageHelper: Cannot create output directory: ' . self::OUTPUT_DIR, Log::WARNING, 'mokoog');
|
||||
|
||||
return $imagePath;
|
||||
}
|
||||
|
||||
// Generate output filename based on source hash + dimensions
|
||||
@@ -180,7 +184,7 @@ class ImageHelper
|
||||
return ['valid' => false, 'width' => 0, 'height' => 0, 'message' => 'File not found'];
|
||||
}
|
||||
|
||||
$imageInfo = @getimagesize($absPath);
|
||||
$imageInfo = getimagesize($absPath);
|
||||
|
||||
if (!$imageInfo) {
|
||||
return ['valid' => false, 'width' => 0, 'height' => 0, 'message' => 'Not a valid image'];
|
||||
|
||||
Reference in New Issue
Block a user