Quantcast
Channel: Backup and restore
Viewing all articles
Browse latest Browse all 6586

import_course call error: Invalid parameter value detected: Only arrays accepted.

$
0
0
by Alan Zaitchik.  

I posted this in the General Developer forum but got no relies, so I am reposting here.

I am experimenting developing a script hoping to use the core_course_external::import_course function to import blocks and activities from a template course into others. I am getting an exception on the 4th parameter ($options) that this method expects, which is an array of import options. (I traced the execution to the generic parameter checking in the validate_parameters method in /lib/externallib.php. The error message is detailed in the var_dump of the exception (See attached.) What I find baffling is that

(1) I am clearly passing in an array, as follows!

$importfrom = 23;
$importto = 15;
$deletecontent=1;
$options = array(
    "activities" => 1,
    "blocks" => 1  ,
    "filters" => 1
);

...
try {
    $newcourse = core_course_external::import_course($importfrom,
        $importto,
        $deletecontent,
        $options); 

catch (exception $e) {
    var_dump($e);
}

In fact I added print_r($params); to the code in /lib/externallib.php just to see what it is getting, and I see

Array ( [importfrom] => 23 [importto] => 15 [deletecontent] => 0 [options] => Array ( [activities] => 1 [blocks] => 1 [filters] => 1 ) )

(2) When I comment out the array initialization and just do

$options=array();

and pass that, I get no complaints and the code functions just as I want it to, i.e. copying activities, blocks, and filters!

So I must be missing something obvious. If anyone can help I will surely be grateful!

Alan

I am attaching the var_dump in case anyone can take a look.


Viewing all articles
Browse latest Browse all 6586

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>