MDL-62233 portfolio: check caller parent class

This commit is contained in:
Marina Glancy 2018-05-07 12:53:40 +08:00 committed by Jun Pataleta
parent ce3f804683
commit 2d83a76ed7
2 changed files with 8 additions and 5 deletions

View File

@ -117,9 +117,9 @@ class portfolio_exporter {
* @param portfolio_caller_base $caller portfolio caller (passed by reference)
* @param string $callercomponent the name of the callercomponent
*/
public function __construct(&$instance, &$caller, $callercomponent) {
$this->instance =& $instance;
$this->caller =& $caller;
public function __construct($instance, portfolio_caller_base $caller, $callercomponent) {
$this->instance = $instance;
$this->caller = $caller;
if ($instance) {
$this->instancefile = 'portfolio/' . $instance->get('plugin') . '/lib.php';
$this->instance->set('exporter', $this);

View File

@ -1358,8 +1358,11 @@ function portfolio_include_callback_file($component, $class = null) {
throw new portfolio_button_exception('nocallbackfile', 'portfolio', '', $component);
}
if (!is_null($class) && !class_exists($class)) {
throw new portfolio_button_exception('nocallbackclass', 'portfolio', '', $class);
if (!is_null($class)) {
// If class is specified, check it exists and extends portfolio_caller_base.
if (!class_exists($class) || !is_subclass_of($class, 'portfolio_caller_base')) {
throw new portfolio_button_exception('nocallbackclass', 'portfolio', '', $class);
}
}
}