Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-55660

False debugging message "found more than one record"

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0.5, 3.1.1, 3.2
    • 3.0.6, 3.1.2
    • Libraries

    Description

      The table_sql class has a feature that if the table columns are not explicitly defined, the out() method first reads a record from the database and sets the columns according to that. The problem is that the feature currently throws a warning like

      Error: mdb->get_record() found more than one record!
      line 1539 of /lib/dml/moodle_database.php: call to debugging()
      line 1601 of /lib/tablelib.php: call to moodle_database->get_record_sql()
      line XX of /your/own/script.php: call to table_sql->out()
      

      even if the table's SQL query is defined correctly.

      This feature is not typically used (if ever) as the normal usage expects the table class is subclassed. So this has not been discovered in production. But developers could hit it while using the table_sql and it could confuse them. Again, not very likely but still.

      Reproduce

      Put the following code (copied from moodle dev docs for the tablelib) as a script test.php into your dirroot and visit it from the browser:

      <?php
       
      require(__DIR__.'/config.php');
      require_once($CFG->libdir.'/tablelib.php');
       
      $PAGE->set_context(context_system::instance());
      $PAGE->set_url('/test.php');
      $PAGE->set_title('Testing table class');
      $PAGE->set_heading($PAGE->title);
       
      echo $OUTPUT->header();
       
      $table = new table_sql('mytest');
      $table->set_sql('id,firstname,lastname,email', '{user}', '1=1');
      $table->define_baseurl($PAGE->url);
       
      $table->out(20, true);
       
      echo $OUTPUT->footer();
      

      Attachments

        Issue Links

          Activity

            People

              mudrd8mz David Mudrák (@mudrd8mz)
              mudrd8mz David Mudrák (@mudrd8mz)
              Simey Lameze Simey Lameze
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                12/Sep/16