Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not support Moodle for MS SQL Server database #112

Open
agogo123 opened this issue Jan 24, 2020 · 2 comments
Open

Does not support Moodle for MS SQL Server database #112

agogo123 opened this issue Jan 24, 2020 · 2 comments
Labels

Comments

@agogo123
Copy link

I have found that this plugin does not support SQL Server database. I've take some time to correct this on my test environment, and I found the following helped to get it running.

The following modifications were made:

  • Renamed the field "external" to "externalurl"
    • in the table "mdl_tool_crawler_url" as "external" is a keyword in SQL Server
    • crawler.php
    • install.xml
    • robot_cleanup_test.php
    • rebot_crawler_test.php
    • url.php
  • Modified query to meet SQL Server syntax
    • crawler.php (removed "LIMIT 1" and replaced with "TOP 1")
@agogo123
Copy link
Author

agogo123 commented Mar 4, 2020

Here are more details from a previously created issue log.

I've recently downloaded this tool and found myself stuck with the error "Scheduled task failed: Link crawler robot (tool_crawler\task\crawl_task),Error reading from database". My environment runs moodle on Windows Server 2012 R2 with the database server being SQL Server 2012 R2.

I've put my moodle into developer debugger mode and found that there is a SQL error that is specific to SQL Server.

Here is the information:
Link crawler robot
Execute scheduled task: Link crawler robot (tool_crawler\task\crawl_task)
... started 15:05:27. Current memory use 6.4MB.
... used 3 dbqueries
... used 0.057562828063965 seconds
Scheduled task failed: Link crawler robot (tool_crawler\task\crawl_task),Error reading from database
Debug info:
SQLState: 42000

Error Code: 102

Message: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near 'LIMIT'.

SELECT *
FROM mdl_tool_crawler_url
WHERE lastcrawled IS NULL
OR lastcrawled < needscrawl
ORDER BY needscrawl ASC, id ASC
LIMIT 1

[array (
)]
Backtrace:

line 324 of \lib\dml\sqlsrv_native_moodle_database.php: call to moodle_database->query_end()
line 431 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->query_end()
line 896 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->do_query()
line 972 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->get_recordset_sql()
line 1571 of \lib\dml\moodle_database.php: call to sqlsrv_native_moodle_database->get_records_sql()
line 485 of \admin\tool\crawler\classes\robot\crawler.php: call to moodle_database->get_record_sql()
line 102 of \admin\tool\crawler\lib.php: call to tool_crawler\robot\crawler->process_queue()
line 52 of \admin\tool\crawler\classes\task\crawl_task.php: call to tool_crawler_crawl()
line 105 of \lib\cronlib.php: call to tool_crawler\task\crawl_task->execute()
line 297 of \lib\cronlib.php: call to cron_run_inner_scheduled_task()
line 91 of \admin\tool\task\schedule_task.php: call to cron_run_single_task()
For SQL Server, the SQL should be:

SELECT top 1 *
FROM mdl_tool_crawler_url
WHERE lastcrawled IS NULL
OR lastcrawled < needscrawl
ORDER BY needscrawl ASC, id ASC

@agogo123
Copy link
Author

agogo123 commented Mar 4, 2020

Has this plugin ever worked with a MS SQL Server DB?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants