Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-3029

Repeat views of the "Submission Inbox" gives DB error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • 2.1
    • Module: Turnitintool
    • None
    • Postgresql 9.0, Apache2, Moodle on master
    • Microsoft SQL
    • Hide

      Modify the if test to also check whether the array indexes have content.

      if (isset($_COOKIE["turnitintool_choice_user"]) && ! empty($_COOKIE["turnitintool_choice_user"]))

      { $userCookie=$_COOKIE["turnitintool_choice_user"]; $userCookieArray=explode("_",$userCookie); }


      if (isset($_COOKIE["turnitintool_choice_count"]) && ! empty($_COOKIE["turnitintool_choice_count"]))

      { $countCookie=$_COOKIE["turnitintool_choice_count"]; $countCookieArray=explode("_",$countCookie); }

      Show
      Modify the if test to also check whether the array indexes have content. if (isset($_COOKIE ["turnitintool_choice_user"] ) && ! empty($_COOKIE ["turnitintool_choice_user"] )) { $userCookie=$_COOKIE["turnitintool_choice_user"]; $userCookieArray=explode("_",$userCookie); } if (isset($_COOKIE ["turnitintool_choice_count"] ) && ! empty($_COOKIE ["turnitintool_choice_count"] )) { $countCookie=$_COOKIE["turnitintool_choice_count"]; $countCookieArray=explode("_",$countCookie); }
    • MOODLE_21_STABLE

      Navigating to the Submission Inbox (e.g. http://moodle.local/mod/turnitintool/view.php?id=2&do=allsubmissions), and then to any other page (e.g. http://moodle.local/mod/turnitintool/view.php?id=2&do=intro) returns a database error:

      Debug info: ERROR: invalid input syntax for integer: ""
      SELECT COUNT('x') FROM mdl_turnitintool_submissions WHERE userid = $1 AND turnitintoolid = $2
      [array (
      0 => '',
      1 => '1',
      )]
      Stack trace:
      line 391 of /lib/dml/moodle_database.php: dml_read_exception thrown
      line 232 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      line 678 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      line 1278 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_records_sql()
      line 1353 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
      line 1524 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
      line 1507 of /lib/dml/moodle_database.php: call to moodle_database->count_records_sql()
      line 1490 of /lib/dml/moodle_database.php: call to moodle_database->count_records_select()
      line 6225 of /mod/turnitintool/lib.php: call to moodle_database->count_records()
      line 4365 of /mod/turnitintool/lib.php: call to turnitintool_count_records()
      line 67 of /mod/turnitintool/view.php: call to turnitintool_update_choice_cookie()

      On further examination, it appears that lib.php::turnitintool_update_choice_cookie() sets the values of $newUserCookie and $newCountCookie without checking whether the cookie has any information.

      As a result, the explodes on lines 4354 and 4358 explode an empty string, which returns an array containing on empty string.
      When the plugin later (line 4360) loops through this array, it attempts to query the database for a userid which does not exist as it's an empty string.

            paul.dawson Paul Dawson (Inactive)
            dobedobedoh Andrew Lyons
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.