danmarsden/moodle-plagiarism_turnitin — pull request #8 by jonof (2011-11-15 06:38:53+00:00)
Title: Turnitin XML response elements give SQL errors when written to an Oracle database

Queries fail with an exception like shown below. The most obvious symptom of the issue is papers being created repeatedly in Turnitin at each run of the cron job. The problem is the Oracle PHP driver does not appear to implicitly take the string value of a SimpleXMLElement object that's being bound to a parameter. I added casts to string on the objects being used as parameters for database operations and this solves the issue.

Error writing to database
* line 268 of /lib/dml/oci_native_moodle_database.php: call to moodle_database->query_end()
* line 1236 of /lib/dml/oci_native_moodle_database.php: call to oci_native_moodle_database->query_end()
* line 1279 of /lib/dml/oci_native_moodle_database.php: call to oci_native_moodle_database->insert_record_raw()
* line 1177 of /plagiarism/turnitin/lib.php: call to oci_native_moodle_database->insert_record()
* line 464 of /plagiarism/turnitin/lib.php: call to turnitin_update_assignment()
* line 1468 of /plagiarism/turnitin/lib.php: call to plagiarism_plugin_turnitin->event_handler()
* line ? of unknownfile: call to turnitin_event_mod_created()
* line 296 of /lib/eventslib.php: call to call_user_func()
* line 340 of /lib/eventslib.php: call to events_dispatch()
* line 448 of /lib/eventslib.php: call to events_process_queued_handler()
* line 165 of /lib/cronlib.php: call to events_cron()
* line 61 of /admin/cli/cron.php: call to cron_run()
ORA-01008: not all variables bound
INSERT INTO z_turnitin_config (cm,name,value) VALUES (:cm,:name,:value) RETURNING id INTO :oracle_id
[array (
\'cm\' => \'150\',
\'name\' => \'turnitin_assignid\',
\'value\' =>
SimpleXMLElement::__set_state(array(
0 => \'13789861\',
)),
)]