Jake Vanderwerf
2026-09-18 a6413da67a4579866f0fd0323ddb23a7b6b9654a
inc/managers/UploadManager.php
@@ -2,6 +2,7 @@
namespace JVBase\managers;
use JVBase\base\Site;
use JVBase\inc\managers\ErrorHelper;
use JVBase\Instance;
use Exception;
use Imagick;
@@ -41,7 +42,7 @@
 */
class UploadManager
{
   use Instance;
   use Instance, ErrorHelper;
   protected array $allowedTypes = [
      // Images
      'image/jpeg'    => 'image',
@@ -310,7 +311,7 @@
            'stored_at'    => current_time('mysql')
         ];
      } catch (Exception $e) {
         Errors::getInstance()->log('UploadManager','Failed to store uploaded file: ' . print_r($e->getMessage(), true));
         $this->logError('Failed to store uploaded file', 'secureUploadedFile', ['error' => $e->getMessage()]);
         return [];
      }
   }
@@ -350,11 +351,7 @@
         };
      } catch (Exception $e) {
         Errors::getInstance()->log(
            '[UploadManager]:processUpload',
            $e->getMessage(),
            ['temp_path' => $temp_path, 'context' => $context]
         );
         $this->logError($e->getMessage(), 'processUpload');
         return new WP_Error('upload_failed', $e->getMessage());
      }
@@ -548,7 +545,7 @@
            );
         } catch (Exception $e) {
            Errors::getInstance()->log('Uploader', 'Image conversion failed: ' . print_r($e->getMessage(), true));
            $this->logError($e->getMessage(), 'processImage');
            // Fallback to original
            $ext = pathinfo($original_path, PATHINFO_EXTENSION);
            $final_path = "{$full_dir}/{$filename}.{$ext}";
@@ -604,7 +601,7 @@
      try {
         $attachment_id = $this->createAttachment($final_path, $filename, $context, $post_id);
      } catch (Exception $e) {
         Errors::getInstance()->log('Uploader', 'Attachment creation failed: '.print_r($e->getMessage(), true));
         $this->logError($e->getMessage(), 'processVideo');
         return ['success' => false];
      }
@@ -642,7 +639,7 @@
      try {
         $attachment_id = $this->createAttachment($final_path, $filename, $context, $post_id);
      } catch (Exception $e) {
         Errors::getInstance()->log('Uploader','Conversion failed: '.print_r($e->getMessage(), true));
         $this->logError($e->getMessage(), 'processDocument');
         return ['success' => false];
      }