Skip to content

Commit

Permalink
get rid of some php warnings and catch some unwanted exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
tgloeggl committed Nov 5, 2024
1 parent 958ff1b commit 7d653bb
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 19 deletions.
4 changes: 2 additions & 2 deletions cronjobs/opencast_worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public function execute($last_result, $parameters = array())
$video->duration = $event->duration;

$video->created = date('Y-m-d H:i:s', strtotime($event->created));
$video->presenters = implode(', ', $event->presenter);
$video->contributors = implode(', ', $event->contributor);
$video->presenters = implode(', ', (array)$event->presenter);
$video->contributors = implode(', ', (array)$event->contributor);

$video->store();

Expand Down
2 changes: 1 addition & 1 deletion lib/Helpers/PlaylistMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static function getOcPlaylistData($playlist, $playlist_videos) {
return [
'title' => $playlist->title,
'description' => '',
'creator' => implode(', ', $owner_names),
'creator' => implode(', ', (array)$owner_names),
'entries' => $entries,
'accessControlEntries' => [],
];
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function updateEndpoints()

$message = [
'type' => 'success',
'text' => implode('<br>', $success_message)
'text' => implode('<br>', (array)$success_message)
];
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/Models/LTI/LtiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public static function getLtiLinks($config_id)
$url = parse_url($endpoint['service_url']);

$lti_url = $url['scheme'] . '://'. $url['host']
. ($url['port'] ? ':' . $url['port'] : '') . '/lti';
. (isset($url['port']) ? ':' . $url['port'] : '') . '/lti';

if (!$links[$lti_url]) {
if (empty($links[$lti_url])) {
$links[$lti_url] = [
'link' => new LtiLink(
$lti_url,
Expand Down
10 changes: 7 additions & 3 deletions lib/Models/LTI/LtiLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,14 @@ public function getBasicLaunchData()
*/
public function getLaunchSignature($launch_params)
{
list($launch_url, $fragment) = explode('#', $this->launch_url);
list($launch_url, $query) = explode('?', $launch_url);
$launch_url = $this->launch_url;

if (isset($query)) {
if (strpos($this->launch_url, '#') !== false) {
list($launch_url, $fragment) = @explode('#', $this->launch_url);
}

if (strpos($this->launch_url, '?') !== false) {
list($launch_url, $query) = @explode('?', $launch_url);
parse_str($query, $query_params);
$launch_params += $query_params;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Models/Playlists.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,13 +619,13 @@ public function setEntries(Array $entries)
$playlist_video = PlaylistVideos::create([
'video_id' => $db_video->id,
'playlist_id' => $this->id,
'service_entry_id' => $entry->id,
'service_entry_id' => isset($entry->id) ?: null,
]);
}

if (!is_null($playlist_video)) {
// Always update entry id and order
$playlist_video->service_entry_id = $entry->id;
$playlist_video->service_entry_id = isset($entry->id) ?: null;
$playlist_video->order = $key;
$playlist_video->store();
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Models/ScheduleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public static function createScheduleEventXML($course_id, $resource_id, $termin_
} else $issue_titles = my_substr($issue->getTitle(), 0 ,80 );
}
if(is_array($issue_titles)){
$issue_titles = _("Themen: ") . my_substr(implode(', ', $issue_titles), 0 ,80 );
$issue_titles = _("Themen: ") . my_substr(implode(', ', (array)$issue_titles), 0 ,80 );
}
}

Expand Down Expand Up @@ -509,7 +509,7 @@ private static function createEventMetadata($course_id, $resource_id, $config_id
}

if (is_array($issue_titles)) {
$issue_titles = _("Themen: ") . my_substr(implode(', ', $issue_titles), 0, 80);
$issue_titles = _("Themen: ") . my_substr(implode(', ', (array)$issue_titles), 0, 80);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Routes/Course/CourseListPlaylist.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __invoke(Request $request, Response $response, $args)

$params = $request->getQueryParams();

if (!$params['cid']) {
if (empty($params['cid'])) {
$params['cid'] = $course_id;
}

Expand Down
8 changes: 5 additions & 3 deletions lib/Routes/Playlist/PlaylistAddVideos.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ public function __invoke(Request $request, Response $response, $args)
'playlist_id' => $playlist->id,
'video_id' => $video->id
]);
$playlist->videos[] = $plvideo;

try {
$playlist->videos[] = $plvideo;
} catch (\InvalidArgumentException $e) {
}
}

$playlist->videos->store();
Expand All @@ -49,8 +53,6 @@ public function __invoke(Request $request, Response $response, $args)
$playlist_client = ApiPlaylistsClient::getInstance($playlist->config_id);
$oc_playlist = $playlist_client->getPlaylist($playlist->service_playlist_id);

// var_dump($playlist);die;

if (!$oc_playlist) {
// something went wrong with playlist creation, try again
$oc_playlist = $playlist_client->createPlaylist([
Expand Down
2 changes: 1 addition & 1 deletion vueapp/components/Videos/VideosAddFromContents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default {
this.selectedVideos = [];
this.$store.dispatch('addMessage', {
type: 'success',
text: this.$gettext('Die Videos wurden der Wiedergabeliste hinzugefügt.')
text: this.$gettext('Die Videos wurden der Wiedergabeliste hinzugefügt. Videos, die bereits in der Wiedergabeliste enthalten sind, wurden nicht erneut hinzugefügt.')
});
this.$store.commit('setVideosReload', true);
this.$emit('done');
Expand Down
2 changes: 1 addition & 1 deletion vueapp/components/Videos/VideosAddFromCourses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default {
this.selectedVideos = [];
this.$store.dispatch('addMessage', {
type: 'success',
text: this.$gettext('Die Videos wurden der Wiedergabeliste hinzugefügt.')
text: this.$gettext('Die Videos wurden der Wiedergabeliste hinzugefügt. Videos, die bereits in der Wiedergabeliste enthalten sind, wurden nicht erneut hinzugefügt.')
});
this.$store.commit('setVideosReload', true);
this.$emit('done');
Expand Down

0 comments on commit 7d653bb

Please sign in to comment.