Skip to content

Commit

Permalink
MDL-54629 webservice: Change required parameters in external_format_text
Browse files Browse the repository at this point in the history
component, filearea and itemid are now optional parameters.
In some contexts those parameteres are not necessary because is not
required to do a file rewrite via file_rewrite_pluginfile_urls
  • Loading branch information
jleyva committed Jun 21, 2016
1 parent 49619ce commit 833be5e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2722,7 +2722,7 @@ public function format_external_text() {
if ($this->properties->eventtype != 'user' && $this->properties->eventtype != 'course'
&& $this->properties->eventtype != 'site' && $this->properties->eventtype != 'group') {
// We don't have a context here, do a normal format_text.
return array(format_text($this->properties->description, $this->properties->format), $this->properties->format);
return external_format_text($this->properties->description, $this->properties->format, $this->editorcontext->id);
}
}

Expand Down
6 changes: 4 additions & 2 deletions lib/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -915,14 +915,16 @@ function external_format_string($str, $contextid, $striplinks = true, $options =
* @param object/array $options text formatting options
* @return array text + textformat
* @since Moodle 2.3
* @since Moodle 3.2 component, filearea and itemid are optional parameters
*/
function external_format_text($text, $textformat, $contextid, $component, $filearea, $itemid, $options = null) {
function external_format_text($text, $textformat, $contextid, $component = null, $filearea = null, $itemid = null,
$options = null) {
global $CFG;

// Get settings (singleton).
$settings = external_settings::get_instance();

if ($settings->get_fileurl()) {
if ($component and $filearea and $settings->get_fileurl()) {
require_once($CFG->libdir . "/filelib.php");
$text = file_rewrite_pluginfile_urls($text, $settings->get_file(), $contextid, $component, $filearea, $itemid);
}
Expand Down
6 changes: 6 additions & 0 deletions webservice/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ information provided here is intended especially for developers.

This information is intended for authors of webservices, not people writing webservice clients.

=== 3.2 ===

* external_format_text function: component, filearea and itemid are now optional parameters.
In some contexts those parameteres are not necessary because is not required to do a file rewrite via
file_rewrite_pluginfile_urls.

=== 3.1 ===

* The xmlrpc backend has changed, Zend_XmlRpc has been dropped and there might be slight differences in
Expand Down

0 comments on commit 833be5e

Please sign in to comment.