From 90c7516f96adf984e10ef464cdf2dd3b2eecbd96 Mon Sep 17 00:00:00 2001 From: sreeshanth-soma1 Date: Thu, 19 Mar 2026 08:09:29 +0530 Subject: [PATCH 1/2] fix: patch upload.php and media_model.php for k6 load testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Temporary fixes to make the upload/media save pipeline work while the 5.5 refactor is in progress: - upload.php: OBFController → OpenBroadcaster\Base\Controller - upload.php: OB_UPLOADS → OB_MEDIA_UPLOADS (5 occurrences) - media_model.php: OB_UPLOADS → OB_MEDIA_UPLOADS (lines 1935, 2178) - media_model.php: add recursive flag to mkdir() (line 2806) --- core/models/Media.php | 6 +++--- public/upload.php | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/core/models/Media.php b/core/models/Media.php index ee676046..c30e8704 100644 --- a/core/models/Media.php +++ b/core/models/Media.php @@ -1932,7 +1932,7 @@ public function save($args = []) } // move our file to its home - $file_src = OB_UPLOADS . '/' . $file_id; + $file_src = OB_MEDIA_UPLOADS . '/' . $file_id; if ($item['is_approved'] == 0) { $file_dest = OB_MEDIA_UNAPPROVED . $media_location . $filename; @@ -2175,7 +2175,7 @@ public function version_add($args = []) } // move file - if (!rename(OB_UPLOADS . '/' . $file_id, $dst_file)) { + if (!rename(OB_MEDIA_UPLOADS . '/' . $file_id, $dst_file)) { return [false, 'Error adding new version.']; } @@ -2803,7 +2803,7 @@ public function rand_file_location($args = []) foreach ($requiredDirs as $checkDir) { if (!file_exists($checkDir)) { - mkdir($checkDir); + mkdir($checkDir, 0755, true); } } diff --git a/public/upload.php b/public/upload.php index ee44b6a5..3335c652 100644 --- a/public/upload.php +++ b/public/upload.php @@ -5,6 +5,8 @@ require_once(__DIR__ . '/../core/init.php'); +use OpenBroadcaster\Base\Controller; + // COMPLETE AUTHENTICATION, usually handled by api.php $user = OBFUser::get_instance(); @@ -35,7 +37,7 @@ } // define our class, create instance, handle upload. -class Upload extends OBFController +class Upload extends Controller { // used by handle_upload() to get some important information about the uploaded media private function media_info($filename) @@ -57,14 +59,14 @@ public function handle_upload() $id = $this->db->insert('uploads', ['key' => $key, 'expiry' => strtotime('+24 hours')]); $input = fopen("php://input", "r"); - $target = fopen(OB_UPLOADS . '/' . $id, "w"); + $target = fopen(OB_MEDIA_UPLOADS . '/' . $id, "w"); $realSize = stream_copy_to_stream($input, $target); fclose($input); fclose($target); if ($realSize != (int) $_SERVER["CONTENT_LENGTH"]) { echo json_encode(['error' => 'File upload was not successful. Please try again.']); - unlink(OB_UPLOADS . '/' . $id); + unlink(OB_MEDIA_UPLOADS . '/' . $id); return; } @@ -75,7 +77,7 @@ public function handle_upload() } else { echo json_encode(['error' => 'File too large (max size ' . OB_MEDIA_FILESIZE_LIMIT . 'MB).']); } - unlink(OB_UPLOADS . '/' . $id); + unlink(OB_MEDIA_UPLOADS . '/' . $id); return; } @@ -83,7 +85,7 @@ public function handle_upload() $result['file_key'] = $key; // get ID3 data. - $id3_data = $models->media('getid3', ['filename' => OB_UPLOADS . '/' . $id]); + $id3_data = $models->media('getid3', ['filename' => OB_MEDIA_UPLOADS . '/' . $id]); if (count($id3_data) > 0) { $result['info'] = ['comments' => $id3_data]; } else { @@ -91,7 +93,7 @@ public function handle_upload() } // get some useful media information, insert it into the db with our file id/key. - $media_info = $this->media_info(OB_UPLOADS . '/' . $id); + $media_info = $this->media_info(OB_MEDIA_UPLOADS . '/' . $id); $this->db->where('id', $id); $this->db->update('uploads', ['format' => $media_info['format'], 'type' => $media_info['type'], 'duration' => $media_info['duration']]); From 2c9816099976ee69bf193e6b51fbb61224a1b561 Mon Sep 17 00:00:00 2001 From: sreeshanth-soma1 Date: Thu, 19 Mar 2026 14:01:24 +0530 Subject: [PATCH 2/2] chore: ignore media_data directory and .DS_Store files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index cd4b2e60..e6186d3b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ vendor node_modules .php-cs-fixer.cache bundles +media_data/ +.DS_Store