catalyst / moodle-tool_crawler

A moodle link crawling robot, find broken, slow and oversized links
https://moodle.org/plugins/tool_crawler
10 stars 18 forks source link

Argument #1 ($string) must be of type string, array given #186

Open matthewhilton opened 1 day ago

matthewhilton commented 1 day ago

Got a site failing with this error:

Adhoc task failed: tool_crawler\task\adhoc_crawl_task,rawurlencode(): Argument #1 ($string) must be of type string, array given
Backtrace:
line 522 of /lib/weblib.php: call to rawurlencode()
line 618 of /lib/weblib.php: call to moodle_url->get_query_string()
line 338 of /admin/tool/crawler/classes/robot/crawler.php: call to moodle_url->raw_out()
line 897 of /admin/tool/crawler/classes/robot/crawler.php: call to tool_crawler\robot\crawler->mark_for_crawl()
line 867 of /admin/tool/crawler/classes/robot/crawler.php: call to tool_crawler\robot\crawler->link_from_node_to_url()
line 632 of /admin/tool/crawler/classes/robot/crawler.php: call to tool_crawler\robot\crawler->parse_html()
line 578 of /admin/tool/crawler/classes/robot/crawler.php: call to tool_crawler\robot\crawler->crawl()
line 81 of /admin/tool/crawler/lib.php: call to tool_crawler\robot\crawler->process_queue()
line 54 of /admin/tool/crawler/classes/task/adhoc_crawl_task.php: call to tool_crawler_crawl()
line 413 of /lib/cronlib.php: call to tool_crawler\task\adhoc_crawl_task->execute()
line 252 of /lib/cronlib.php: call to cron_run_inner_adhoc_task()
line 272 of /lib/cronlib.php: call to cron_run_adhoc_task()
line 155 of /admin/cli/adhoc_task.php: call to cron_run_failed_adhoc_tasks()

It seems like it is parsing a URL here https://github.com/catalyst/moodle-tool_crawler/blob/c7a50c06dcd83ed3e7d289cfdf1928d8caa5e6e7/classes/robot/crawler.php#L334 and interpreting some of the url params as arrays

Looking into the code a bit more, it does detect if the value is_array ; this makes me wonder if it is a double layer array ?

matthewhilton commented 1 day ago

Looks to be more of a core bug, where multi level array parameters with moodle_url are not supported properly - see https://tracker.moodle.org/browse/MDL-77293