From 7e7d8ea61540367d97dadc9cd7ee8037f66ad2f2 Mon Sep 17 00:00:00 2001 From: Mihai Sucan Date: Fri, 20 Nov 2009 14:01:20 +0200 Subject: [PATCH] Fix a possible race condition in the PaintWeb DML code. Thanks to Martin Langhoff for the code review. --- lib/dmllib.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/dmllib.php b/lib/dmllib.php index acfe0d61334..7a051a9442c 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -2684,7 +2684,11 @@ function paintweb_db_insert($table, &$dataobject, $usecache = true) { // http://docs.moodle.org/en/Development:Paint_tool_integration#Results:_Moodle_1.9_integration // http://docs.moodle.org/en/Development:Paint_tool - if (empty($dataobject->id)) { + $pwtable = 'paintweb_images'; + + // Avoid running this function if the data object has no id field, or if the + // table is paintweb_images. + if (empty($dataobject->id) || $pwtable == $table) { return false; } @@ -2694,7 +2698,7 @@ function paintweb_db_insert($table, &$dataobject, $usecache = true) { $pattern = '~' . preg_quote($CFG->wwwroot, '~') . '/lib/paintweb/ext/moodle/imageview19.php\?img=([a-f0-9]+\.[a-z]+)~S'; - $pwtable = 'paintweb_images'; + $dataarray = (array)$dataobject; // Init and delete metadata cache -- 2.11.4.GIT