Skip to content

Commit

Permalink
MDL-73724 mod_bigbluebuttonbn: Error when joining meeting
Browse files Browse the repository at this point in the history
* When pre-uploaded presentation is uploaded, the meeting refuses to start and
and error is thrown.
  • Loading branch information
laurentdavid committed Feb 17, 2022
1 parent d24a4ab commit c25c134
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 75 deletions.
4 changes: 3 additions & 1 deletion mod/bigbluebuttonbn/classes/external/end_meeting.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ public static function execute_parameters(): external_function_parameters {
* @param int $bigbluebuttonbnid the bigbluebuttonbn instance id
* @param int $groupid the groupid (either 0 or the groupid)
* @return array (empty array for now)
* @throws \restricted_context_exception
* @throws \invalid_parameter_exception
* @throws \moodle_exception
* @throws restricted_context_exception
*/
public static function execute(
int $bigbluebuttonbnid,
Expand Down
3 changes: 2 additions & 1 deletion mod/bigbluebuttonbn/classes/external/get_recordings.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public static function execute_parameters(): external_function_parameters {
* @param string|null $tools
* @param int|null $groupid
* @return array of warnings and status result
* @throws \webservice_access_exception
* @throws \invalid_parameter_exception
* @throws restricted_context_exception
*/
public static function execute(
int $bigbluebuttonbnid = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ public static function execute_parameters(): external_function_parameters {
* Get a list of recordings
*
* @param int $destinationinstanceid the bigbluebuttonbn instance id where recordings have been already imported.
* @param int $sourcebigbluebuttonbnid the bigbluebuttonbn instance id to which the recordings are referred.
* @param int $sourcecourseid the source courseid to filter by
* @param int|null $sourcebigbluebuttonbnid the bigbluebuttonbn instance id to which the recordings are referred.
* @param int|null $sourcecourseid the source courseid to filter by
* @param string|null $tools
* @param int|null $groupid
* @return array of warnings and status result
* @throws \webservice_access_exception
* @throws \invalid_parameter_exception
* @throws \restricted_context_exception
*/
public static function execute(
int $destinationinstanceid,
Expand Down
1 change: 0 additions & 1 deletion mod/bigbluebuttonbn/classes/external/update_recording.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class update_recording extends external_api {
* @param string $action
* @param string|null $additionaloptions
* @return array (empty array for now)
* @throws coding_exception
*/
public static function execute(
int $bigbluebuttonbnid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class recording_data {
* @param instance|null $instance
* @param int $courseid
* @return array
* @throws \coding_exception
*/
public static function get_recording_table(array $recordings, array $tools, instance $instance = null,
int $courseid = 0): array {
Expand Down
19 changes: 11 additions & 8 deletions mod/bigbluebuttonbn/classes/local/helpers/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ public static function pluginfile_valid(stdClass $context, string $filearea): ?b
/**
* Helper for getting pluginfile.
*
* @param stdClass $course course object
* @param \cm_info $cm course module object
* @param stdClass|null $course course object
* @param stdClass|null $cm course module object
* @param context $context context object
* @param string $filearea file area
* @param array $args extra arguments
*
* @return \stored_file|bool
*/
public static function pluginfile_file(stdClass $course, \cm_info $cm, context $context, string $filearea, array $args) {
public static function pluginfile_file(?stdClass $course, ?stdClass $cm, context $context, string $filearea, array $args) {
$filename = self::get_plugin_filename($course, $cm, $context, $args);
if (!$filename) {
return false;
Expand Down Expand Up @@ -213,14 +213,14 @@ public static function get_presentation(context $context, string $presentation,
/**
* Helper for getting pluginfile name.
*
* @param stdClass $course course object
* @param \cm_info $cm course module object
* @param stdClass|null $course course object
* @param stdClass|null $cm course module object
* @param context $context context object
* @param array $args extra arguments
*
* @return string|null
*/
public static function get_plugin_filename(stdClass $course, \cm_info $cm, context $context, array $args): ?string {
public static function get_plugin_filename(?stdClass $course, ?stdClass $cm, context $context, array $args): ?string {
global $DB;
if ($context->contextlevel != CONTEXT_SYSTEM) {
// Plugin has a file to use as default in general setting.
Expand All @@ -245,7 +245,11 @@ public static function get_plugin_filename(stdClass $course, \cm_info $cm, conte
return ($args['0'] == $actualnonce) ? $args['1'] : null;

}
require_course_login($course, true, $cm, true, true);
if (!empty($course)) {
require_course_login($course, true, $cm, true, true);
} else {
require_login(null, true, $cm, true, true);
}
if (!has_capability('mod/bigbluebuttonbn:join', $context)) {
return null;
}
Expand All @@ -257,7 +261,6 @@ public static function get_plugin_filename(stdClass $course, \cm_info $cm, conte
*
* @param int $id
* @return int
* @throws \coding_exception
*/
protected static function get_nonce(int $id): int {
$cache = static::get_nonce_cache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ public static function get_server_not_available_url(instance $instance): string
* @param string|null $presentationurl
* @return array
* @throws bigbluebutton_exception
* @throws server_not_available_exception
*/
public static function create_meeting(
array $data,
Expand Down
23 changes: 12 additions & 11 deletions mod/bigbluebuttonbn/classes/local/proxy/curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,24 @@ public function set_content_type(string $type): self {
* @param string $url
* @param array|string $params
* @param array $options
* @return bool
* @return null|SimpleXMLElement Null on error
*/
public function post($url, $params = '', $options = []) {
if (!is_string($params)) {
debugging('Only string paramaters are supported', DEBUG_DEVELOPER);
$params = '';
}

$options = [
'CURLOPT_HTTPHEADER' => [
'Content-Type: ' . $this->get_content_type(),
'Content-Length: ' . strlen($params),
'Content-Language: en-US',
],
];

return !empty($this->handle_response(parent::post($url, $params, $options)));
$options = array_merge($options,
[
'CURLOPT_HTTPHEADER' => [
'Content-Type: ' . $this->get_content_type(),
'Content-Length: ' . strlen($params),
'Content-Language: en-US',
],
]
);

return $this->handle_response(parent::post($url, $params, $options));
}

/**
Expand Down
9 changes: 0 additions & 9 deletions mod/bigbluebuttonbn/classes/logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ class logger {
* @param array|null $filters
* @param int|null $timestart
* @return array
* @throws \coding_exception
* @throws \dml_exception
*/
public static function get_user_completion_logs(
instance $instance,
Expand All @@ -102,8 +100,6 @@ public static function get_user_completion_logs(
* @param array|null $filters
* @param int|null $timestart
* @return array
* @throws \coding_exception
* @throws \dml_exception
*/
public static function get_user_completion_logs_with_userfields(
instance $instance,
Expand Down Expand Up @@ -138,8 +134,6 @@ public static function get_user_completion_logs_with_userfields(
* @param array|null $filters
* @param int|null $timestart
* @return int
* @throws \coding_exception
* @throws \dml_exception
*/
public static function get_user_completion_logs_max_timestamp(
instance $instance,
Expand All @@ -164,8 +158,6 @@ public static function get_user_completion_logs_max_timestamp(
* @param int|null $timestart
* @param string|null $logtablealias
* @return array
* @throws \coding_exception
* @throws \dml_exception
*/
protected static function get_user_completion_sql_params(instance $instance, ?int $userid, ?array $filters, ?int $timestart,
?string $logtablealias = null) {
Expand Down Expand Up @@ -371,7 +363,6 @@ protected static function log(instance $instance, string $event, array $override
* @param array $overrides
* @param string|null $meta
* @return bool
* @throws \dml_exception
*/
protected static function raw_log(
string $event,
Expand Down
7 changes: 0 additions & 7 deletions mod/bigbluebuttonbn/classes/meeting.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public function __construct(instance $instance) {
* @param int $origin
* @return string
* @throws meeting_join_exception this is sent if we cannot join (meeting full, user needs to wait...)
* @throws server_not_available_exception
*/
public static function join_meeting(instance $instance, $origin = logger::ORIGIN_BASE): string {
// See if the session is in progress.
Expand All @@ -80,7 +79,6 @@ public static function join_meeting(instance $instance, $origin = logger::ORIGIN
* Get currently stored meeting info
*
* @return mixed|stdClass
* @throws \coding_exception
*/
public function get_meeting_info() {
if (!$this->meetinginfo) {
Expand Down Expand Up @@ -162,8 +160,6 @@ public function get_participant_count() {
* Creates a bigbluebutton meeting, send the message to BBB and returns the response in an array.
*
* @return array
* @throws bigbluebutton_exception
* @throws server_not_available_exception
*/
public function create_meeting() {
$data = $this->create_meeting_data();
Expand Down Expand Up @@ -196,7 +192,6 @@ public function end_meeting() {
* Get meeting join URL
*
* @return string
* @throws \coding_exception
*/
public function get_join_url() {
return bigbluebutton_proxy::get_join_url(
Expand Down Expand Up @@ -301,8 +296,6 @@ protected function do_get_meeting_info(bool $updatecache = false): stdClass {
* @param bool $updatecache
*
* @return array
* @throws \coding_exception
* @throws bigbluebutton_exception
*/
protected static function retrieve_cached_meeting_info($meetingid, $updatecache = false) {
$cachettl = (int) config::get('waitformoderator_cache_ttl');
Expand Down
1 change: 0 additions & 1 deletion mod/bigbluebuttonbn/classes/output/recording_editable.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ abstract class recording_editable extends \core\output\inplace_editable {
* @param instance $instance
* @param string $edithint
* @param string $editlabel
* @throws moodle_exception
*/
public function __construct(recording $rec, instance $instance, string $edithint, string $editlabel) {
$this->instance = $instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class recording_name_editable extends recording_editable {
*
* @param recording $rec
* @param instance $instance
* @throws \coding_exception
*/
public function __construct(recording $rec, instance $instance) {
parent::__construct($rec, $instance,
Expand Down
7 changes: 0 additions & 7 deletions mod/bigbluebuttonbn/classes/recording.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,6 @@ protected function before_update() {
*
* @param instance $targetinstance
* @return recording
* @throws \coding_exception
* @throws \core\invalid_persistent_exception
*/
public function create_imported_recording(instance $targetinstance) {
$recordingrec = $this->to_record();
Expand Down Expand Up @@ -611,7 +609,6 @@ public function get_remote_playback_url(string $type): ?string {
* Is protected. Return null if protected is not implemented.
*
* @return bool|null
* @throws \coding_exception
*/
protected function get_protected() {
$protectedtext = $this->metadata_get('protected');
Expand All @@ -622,7 +619,6 @@ protected function get_protected() {
* Start time
*
* @return mixed|null
* @throws \coding_exception
*/
protected function get_starttime() {
return $this->metadata_get('starttime');
Expand All @@ -632,7 +628,6 @@ protected function get_starttime() {
* Start time
*
* @return mixed|null
* @throws \coding_exception
*/
protected function get_endtime() {
return $this->metadata_get('endtime');
Expand All @@ -642,7 +637,6 @@ protected function get_endtime() {
* Is published
*
* @return bool
* @throws \coding_exception
*/
protected function get_published() {
$publishedtext = $this->metadata_get('published');
Expand All @@ -654,7 +648,6 @@ protected function get_published() {
*
* @param string $fieldname
* @param mixed $value
* @throws \coding_exception
*/
protected function metadata_set($fieldname, $value) {
// Can we can change the metadata on the imported record ?
Expand Down
3 changes: 0 additions & 3 deletions mod/bigbluebuttonbn/classes/test/testcase_helper_trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ protected function initialise_mock_server(): void {
* @param instance $instance
* @param array $recordingdata array of recording information
* @return array
* @throws \coding_exception
*/
protected function create_recordings_for_instance(instance $instance, array $recordingdata = []): array {
$recordings = [];
Expand Down Expand Up @@ -215,8 +214,6 @@ protected function create_activity_with_recordings(stdClass $course, int $type,
*
* @param array $dataset
* @return mixed
* @throws \coding_exception
* @throws \dml_exception
*/
protected function create_from_dataset(array $dataset) {
list('type' => $type, 'recordingsdata' => $recordingsdata, 'groups' => $groups,
Expand Down
3 changes: 2 additions & 1 deletion mod/bigbluebuttonbn/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ function bigbluebuttonbn_view($bigbluebuttonbn, $course, $cm, $context) {
];

$event = \mod_bigbluebuttonbn\event\course_module_viewed::create($params); // Fix event name.
$event->add_record_snapshot('course_modules', $cm->get_course_module_record());
$cmrecord = $cm->get_course_module_record();
$event->add_record_snapshot('course_modules', $cmrecord);
$event->add_record_snapshot('course', $course);
$event->add_record_snapshot('bigbluebuttonbn', $bigbluebuttonbn);
$event->trigger();
Expand Down
1 change: 0 additions & 1 deletion mod/bigbluebuttonbn/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@ private function bigbluebuttonbn_mform_add_block_schedule(MoodleQuickForm &$mfor
* @param array|null $options
* @param array|null $rule
* @return void
* @throws coding_exception
*/
private function bigbluebuttonbn_mform_add_element(MoodleQuickForm &$mform, string $type, string $name, ?string $datatype,
?string $descriptionkey = "", $defaultvalue = null, ?array $options = null, ?array $rule = null): void {
Expand Down
2 changes: 0 additions & 2 deletions mod/bigbluebuttonbn/tests/behat/behat_mod_bigbluebuttonbn.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public static function get_exact_named_selectors(): array {
* @param string $endpoint
* @param array $params
* @return moodle_url
* @throws moodle_exception
*/
public static function get_mocked_server_url(string $endpoint = '', array $params = []): moodle_url {
return new moodle_url(TEST_MOD_BIGBLUEBUTTONBN_MOCK_SERVER . '/' . $endpoint, $params);
Expand Down Expand Up @@ -149,7 +148,6 @@ protected function resolve_page_instance_url(string $type, string $identifier):
*
* @param string $identifier
* @return int
* @throws dml_exception
*/
protected function get_course_id(string $identifier): int {
global $DB;
Expand Down
2 changes: 0 additions & 2 deletions mod/bigbluebuttonbn/tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ public function create_recording(array $data): stdClass {
* @param stdClass $recordingdata
* @param array $data
* @return string
* @throws moodle_exception
*/
protected function create_mockserver_recording(instance $instance, stdClass $recordingdata, array $data): string {
$mockdata = array_merge((array) $recordingdata, [
Expand Down Expand Up @@ -341,7 +340,6 @@ protected function get_mocked_server_url(string $endpoint = '', array $params =
* @param array $params
* @param array $mockdata
* @return SimpleXMLElement
* @throws coding_exception
*/
protected function send_mock_request(string $endpoint, array $params = [], array $mockdata = []): SimpleXMLElement {
$url = $this->get_mocked_server_url($endpoint, $params);
Expand Down
1 change: 0 additions & 1 deletion mod/bigbluebuttonbn/tests/lib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ function($e) {
* @param int $user
* @param int $group
* @return array|void
* @throws \moodle_exception
*/
protected function prepare_for_recent_activity_array($date, $user, $group) {
// Same algorithm as in cource/recent.php, but stops at the first bbb activity.
Expand Down
Loading

0 comments on commit c25c134

Please sign in to comment.