Skip to content
Snippets Groups Projects
Commit 45e8f99e authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix(migrations): ignore invalid utf8 chars for media files metadata + update transcript parser

check that transcript parser constants are defined before declaring them
parent d807ab97
No related branches found
No related tags found
2 merge requests!165fix(migrations): ignore invalid utf8 chars for media files metadata + update transcript parser,!160WIP:Feat/social interact
Pipeline #1261 passed
...@@ -88,7 +88,7 @@ class BaseMedia extends Entity ...@@ -88,7 +88,7 @@ class BaseMedia extends Entity
$this->attributes['type'] = $this->type; $this->attributes['type'] = $this->type;
$this->attributes['file_mimetype'] = $file->getMimeType(); $this->attributes['file_mimetype'] = $file->getMimeType();
$this->attributes['file_metadata'] = json_encode(lstat((string) $file)); $this->attributes['file_metadata'] = json_encode(lstat((string) $file), JSON_INVALID_UTF8_IGNORE);
$this->attributes['file_path'] = save_media( $this->attributes['file_path'] = save_media(
$file, $file,
$this->attributes['file_directory'], $this->attributes['file_directory'],
......
...@@ -61,7 +61,7 @@ class Image extends BaseMedia ...@@ -61,7 +61,7 @@ class Image extends BaseMedia
]; ];
} }
$this->attributes['file_metadata'] = json_encode($metadata); $this->attributes['file_metadata'] = json_encode($metadata, JSON_INVALID_UTF8_IGNORE);
$this->initFileProperties(); $this->initFileProperties();
$this->saveSizes(); $this->saveSizes();
......
...@@ -58,7 +58,7 @@ class Transcript extends BaseMedia ...@@ -58,7 +58,7 @@ class Transcript extends BaseMedia
$metadata['json_path'] = $jsonFilePath; $metadata['json_path'] = $jsonFilePath;
} }
$this->attributes['file_metadata'] = json_encode($metadata); $this->attributes['file_metadata'] = json_encode($metadata, JSON_INVALID_UTF8_IGNORE);
return $this; return $this;
} }
......
...@@ -30,10 +30,21 @@ class TranscriptParser ...@@ -30,10 +30,21 @@ class TranscriptParser
*/ */
public function parseSrt(): string | false public function parseSrt(): string | false
{ {
define('SRT_STATE_SUBNUMBER', 0); if (! defined('SRT_STATE_SUBNUMBER')) {
define('SRT_STATE_TIME', 1); define('SRT_STATE_SUBNUMBER', 0);
define('SRT_STATE_TEXT', 2); }
define('SRT_STATE_BLANK', 3);
if (! defined('SRT_STATE_TIME')) {
define('SRT_STATE_TIME', 1);
}
if (! defined('SRT_STATE_TEXT')) {
define('SRT_STATE_TEXT', 2);
}
if (! defined('SRT_STATE_BLANK')) {
define('SRT_STATE_BLANK', 3);
}
$subs = []; $subs = [];
$state = SRT_STATE_SUBNUMBER; $state = SRT_STATE_SUBNUMBER;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment