mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 23:31:21 +02:00
Combine phpstan, cs-check, cs-fix into lint-php recipe; fix lint issues + test failures + duplicate detection bug
This commit is contained in:
@@ -278,12 +278,12 @@ class ThesisEditController
|
||||
error_log('[ThesisEdit] Step 5 OK — formats=' . json_encode($formatIds));
|
||||
|
||||
// ── 6. Tags ───────────────────────────────────────────────────────
|
||||
$normalizeTag = fn(string $t): string => strtolower(trim(preg_replace('/\s+/', ' ', $t)));
|
||||
$normalizeTag = fn (string $t): string => strtolower(trim(preg_replace('/\s+/', ' ', $t)));
|
||||
$keywords = [];
|
||||
if (isset($post['tag']) && is_array($post['tag'])) {
|
||||
$keywords = array_values(array_unique(array_map(
|
||||
$normalizeTag,
|
||||
array_map(fn($t) => (string)$t, $post['tag'])
|
||||
array_map(fn ($t) => (string)$t, $post['tag'])
|
||||
)));
|
||||
} else {
|
||||
$keywordsRaw = trim($post['tag'] ?? '');
|
||||
@@ -292,7 +292,7 @@ class ThesisEditController
|
||||
}
|
||||
}
|
||||
$keywords = array_values(array_unique($keywords));
|
||||
$keywords = array_filter($keywords, fn($t) => $t !== '');
|
||||
$keywords = array_filter($keywords, fn ($t) => $t !== '');
|
||||
$keywords = array_slice($keywords, 0, 10);
|
||||
if (count($keywords) < 1) {
|
||||
throw new Exception('Veuillez indiquer au moins 1 mot-clé.');
|
||||
@@ -587,67 +587,6 @@ class ThesisEditController
|
||||
return $members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload PeerTube video/audio files from FilePond queue.
|
||||
*
|
||||
* Files arrive via PHP's nested $_FILES structure from
|
||||
* <input name="queue_file[peertube_video][]">.
|
||||
*
|
||||
* @param int $thesisId Thesis to attach the results to.
|
||||
* @param string $title Title to use on PeerTube.
|
||||
* @param array|null $uploads Flat $_FILES-style array from extractFilesSubArray().
|
||||
* @param string $fileType 'video' or 'audio'.
|
||||
*/
|
||||
private function handlePeerTubeQueueFiles(int $thesisId, string $title, ?array $uploads, string $fileType, ?string $progressToken = null): void
|
||||
{
|
||||
if (!$uploads || !is_array($uploads['name'] ?? null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once APP_ROOT . '/src/PeerTubeService.php';
|
||||
if (!PeerTubeService::isEnabled($this->db)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$label = $fileType === 'video' ? 'Vidéo' : 'Audio';
|
||||
$count = count($uploads['name']);
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if (($uploads['error'][$i] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fileName = $uploads['name'][$i];
|
||||
if ($progressToken) {
|
||||
PeerTubeService::writeProgress($progressToken, 'peertube', 25 + (int)(($i / max($count, 1)) * 74), $label . ' : ' . $fileName);
|
||||
}
|
||||
|
||||
try {
|
||||
$result = PeerTubeService::upload(
|
||||
$this->db,
|
||||
$uploads['tmp_name'][$i],
|
||||
$fileName,
|
||||
$title,
|
||||
''
|
||||
);
|
||||
|
||||
$storedPath = 'peertube_ids:' . $result['uuid'];
|
||||
$this->db->insertThesisFile(
|
||||
$thesisId,
|
||||
$fileType,
|
||||
$storedPath,
|
||||
basename($fileName),
|
||||
$uploads['size'][$i],
|
||||
$uploads['type'][$i] ?? 'application/octet-stream',
|
||||
null,
|
||||
null
|
||||
);
|
||||
error_log("ThesisEditController: PeerTube upload OK → " . $result['watchUrl']);
|
||||
} catch (\Throwable $e) {
|
||||
error_log('ThesisEditController: PeerTube upload failed — ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or update a website URL thesis_file row.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user