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

site registration - Error reading from database

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.3.1
    • Fix Version/s: 2.3.2
    • Component/s: Administration
    • Labels:

      Description

      Cannot register site. Site is in subdirectory, when I click on registration I am taken to Wordpress installation in main directory. When I click the "site not registered" button I get the following debugging details:

      More information about this error
       
      Debug info: Every derived table must have its own alias
      SELECT COUNT(*) FROM (
      SELECT DISTINCT ue.userid, e.courseid
      FROM mdl_user_enrolments ue, mdl_enrol e, mdl_course c
      WHERE ue.enrolid = e.id
      AND e.courseid <> ?
      AND c.id = e.courseid
      AND c.visible = 1)
      [array (
      0 => '1',
      )]
      Error code: dmlreadexception
      Stack trace:
      line 407 of /lib/dml/moodle_database.php: dml_read_exception thrown
      line 944 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      line 1346 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
      line 1419 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
      line 1590 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
      line 4044 of /course/lib.php: call to moodle_database->count_records_sql()
      line 373 of /admin/registration/forms.php: call to average_number_of_participants()
      line 194 of /lib/formslib.php: call to site_registration_form->definition()
      line 61 of /admin/registration/register.php: call to moodleform->moodleform()

        Gliffy Diagrams

          Issue Links

            Activity

            Show
            woolardfa@appstate.edu Fred Woolard added a comment - See MDL-34072 http://moodle.org/mod/forum/discuss.php?d=207476#p904371
            Hide
            danmarsden Dan Marsden added a comment -

            crazy.... - have linked the bug that caused this - thanks Fred for the pointer.

            Show
            danmarsden Dan Marsden added a comment - crazy.... - have linked the bug that caused this - thanks Fred for the pointer.
            Hide
            salvetore Michael de Raadt added a comment -

            Darn!

            I should have kept my mouth shut.

            Show
            salvetore Michael de Raadt added a comment - Darn! I should have kept my mouth shut.
            Hide
            salvetore Michael de Raadt added a comment -

            And I should have tested this across all DBs.

            Show
            salvetore Michael de Raadt added a comment - And I should have tested this across all DBs.
            Hide
            woolardfa@appstate.edu Fred Woolard added a comment -
            Show
            woolardfa@appstate.edu Fred Woolard added a comment - The diff link for the branch, based off of MOODLE_23_STABLE: https://github.com/appalachianstate/moodle/compare/moodle:MOODLE_23_STABLE...appalachianstate:MDL-34440
            Hide
            woolardfa@appstate.edu Fred Woolard added a comment -

            Michael,
            Plenty of mea culpa to go around. On the second edit, it just seemed faster to validate the query against the db engines with their respective clients, rather than through Moodle--but I would've missed it anyway as I was using a config file with plain ol' mysql, a la 1.9.
            Regards

            Show
            woolardfa@appstate.edu Fred Woolard added a comment - Michael, Plenty of mea culpa to go around. On the second edit, it just seemed faster to validate the query against the db engines with their respective clients, rather than through Moodle--but I would've missed it anyway as I was using a config file with plain ol' mysql, a la 1.9. Regards
            Hide
            kmentor Kenneth Mentor added a comment -

            Thank you gentlemen - This may be a site configuration issue, perhaps due to installing in a directory with WordPress at the root?

            That said, I made the suggested changes and can now access the registration page. However, when I submit the registration (or attempt to go to registration directly rather than through notifications), I am taken to the WP installation in main folder. Here is the url that results from clicking "registration," although it justs takes me back to Wordpress.

            http://****.com/classroom/admin/registration/register.php/?huburl=http%3A%2F%2Fhub.moodle.org&hubname=Moodle.org

            Show
            kmentor Kenneth Mentor added a comment - Thank you gentlemen - This may be a site configuration issue, perhaps due to installing in a directory with WordPress at the root? That said, I made the suggested changes and can now access the registration page. However, when I submit the registration (or attempt to go to registration directly rather than through notifications), I am taken to the WP installation in main folder. Here is the url that results from clicking "registration," although it justs takes me back to Wordpress. http://****.com/classroom/admin/registration/register.php/?huburl=http%3A%2F%2Fhub.moodle.org&hubname=Moodle.org
            Hide
            woolardfa@appstate.edu Fred Woolard added a comment -

            Kenneth,

            While you are encountering a problem with the WP environment, it is, I believe, an entirely different issue from the originally reported problem--the SQL error. It's that the two problems are juxtaposed and encountered so it appears to be one. I think you are correct that it (the second WP problem) is a configuration issue. If this is an Apache install, likely culprit is an alias or rewrite.

            The registration page submission does a redirect to the hub, and appends to the query string the name/value pair url={$CFG->wwwroot}. The hub supposedly, after collecting registration data, should redirect you back to $CFG->wwwroot, whatever that is--set in your config.php, guessing that you would know all that already.

            Regards,FW

            Show
            woolardfa@appstate.edu Fred Woolard added a comment - Kenneth, While you are encountering a problem with the WP environment, it is, I believe, an entirely different issue from the originally reported problem--the SQL error. It's that the two problems are juxtaposed and encountered so it appears to be one. I think you are correct that it (the second WP problem) is a configuration issue. If this is an Apache install, likely culprit is an alias or rewrite. The registration page submission does a redirect to the hub, and appends to the query string the name/value pair url={$CFG->wwwroot}. The hub supposedly, after collecting registration data, should redirect you back to $CFG->wwwroot, whatever that is--set in your config.php, guessing that you would know all that already. Regards,FW
            Hide
            kmentor Kenneth Mentor added a comment -

            Hi Fred - and greetings from the other side of NC.

            Problem solved! Thanks for the hints. wwwroot wss set correctly, with the URL properly pointing to the "classroom" folder, but I was being redirected to WP in the top folder (rather than the registration verification in moodle).

            My hosting company (hostgator) indicated "there was a mod security issue, [the support agent] had to whitelist the rule it was hitting." Although this appears to be unique to my hosting configuration, I will post this reply in case others experience the same problem.

            Ken

            Show
            kmentor Kenneth Mentor added a comment - Hi Fred - and greetings from the other side of NC. Problem solved! Thanks for the hints. wwwroot wss set correctly, with the URL properly pointing to the "classroom" folder, but I was being redirected to WP in the top folder (rather than the registration verification in moodle). My hosting company (hostgator) indicated "there was a mod security issue, [the support agent] had to whitelist the rule it was hitting." Although this appears to be unique to my hosting configuration, I will post this reply in case others experience the same problem. Ken
            Hide
            mudrd8mz David Mudrak added a comment -

            This also affects cron and is really crucial regression on stable branch.

            Default exception handler: Chyba čtení z databáze Debug: ERROR:  subquery in FROM must have an alias
            LINE 1: SELECT COUNT(*) FROM (
                                         ^
            HINT:  For example, FROM (SELECT ...) [AS] foo.
            SELECT COUNT(*) FROM (
                    SELECT DISTINCT ue.userid, e.courseid
                    FROM mdl_user_enrolments ue, mdl_enrol e, mdl_course c
                    WHERE ue.enrolid = e.id
                        AND e.courseid <> $1
                        AND c.id = e.courseid
                        AND c.visible = 1)
            [array (
              0 => '1',
            )]
            Error code: dmlreadexception
            * line 407 of /lib/dml/moodle_database.php: dml_read_exception thrown
            * line 239 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
            * line 708 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
            * line 1346 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_records_sql()
            * line 1419 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
            * line 1590 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
            * line 4044 of /course/lib.php: call to moodle_database->count_records_sql()
            * line 255 of /admin/registration/lib.php: call to average_number_of_participants()
            * line 66 of /admin/registration/lib.php: call to registration_manager->get_site_info()
            * line 380 of /lib/cronlib.php: call to registration_manager->cron()
            * line 61 of /admin/cli/cron.php: call to cron_run()

            Show
            mudrd8mz David Mudrak added a comment - This also affects cron and is really crucial regression on stable branch. Default exception handler: Chyba čtení z databáze Debug: ERROR: subquery in FROM must have an alias LINE 1: SELECT COUNT(*) FROM ( ^ HINT: For example, FROM (SELECT ...) [AS] foo. SELECT COUNT(*) FROM ( SELECT DISTINCT ue.userid, e.courseid FROM mdl_user_enrolments ue, mdl_enrol e, mdl_course c WHERE ue.enrolid = e.id AND e.courseid <> $1 AND c.id = e.courseid AND c.visible = 1) [array ( 0 => '1', )] Error code: dmlreadexception * line 407 of /lib/dml/moodle_database.php: dml_read_exception thrown * line 239 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end() * line 708 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end() * line 1346 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_records_sql() * line 1419 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql() * line 1590 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql() * line 4044 of /course/lib.php: call to moodle_database->count_records_sql() * line 255 of /admin/registration/lib.php: call to average_number_of_participants() * line 66 of /admin/registration/lib.php: call to registration_manager->get_site_info() * line 380 of /lib/cronlib.php: call to registration_manager->cron() * line 61 of /admin/cli/cron.php: call to cron_run()
            Hide
            danmarsden Dan Marsden added a comment -

            hadn't realised I'd been assigned to this one until David gave me a poke - sorry bout that - pushing fixes now.

            Show
            danmarsden Dan Marsden added a comment - hadn't realised I'd been assigned to this one until David gave me a poke - sorry bout that - pushing fixes now.
            Hide
            danmarsden Dan Marsden added a comment -

            bouncing this back up for integration - skipping peer review as this probably needs to be taken care of asap.

            Show
            danmarsden Dan Marsden added a comment - bouncing this back up for integration - skipping peer review as this probably needs to be taken care of asap.
            Hide
            mudrd8mz David Mudrak added a comment -

            Not a proper peer-review but I can just confirm that the submitted patch unblocks the cron execution. Thanks Fred and Dan.

            Show
            mudrd8mz David Mudrak added a comment - Not a proper peer-review but I can just confirm that the submitted patch unblocks the cron execution. Thanks Fred and Dan.
            Hide
            poltawski Dan Poltawski added a comment -

            Pulling into this weeks integration to get this fixed quickly

            Show
            poltawski Dan Poltawski added a comment - Pulling into this weeks integration to get this fixed quickly
            Hide
            poltawski Dan Poltawski added a comment -

            Thanks Dan and Ken, i've integrated this now.

            I tested 2.3 during integration:

            Oracle: Working before and after
            MSSQL: Broken before, working after
            MySQL: Broken before, working after
            PgSQL: Broken before, working after

            So looks good!

            Show
            poltawski Dan Poltawski added a comment - Thanks Dan and Ken, i've integrated this now. I tested 2.3 during integration: Oracle: Working before and after MSSQL: Broken before, working after MySQL: Broken before, working after PgSQL: Broken before, working after So looks good!
            Hide
            salvetore Michael de Raadt added a comment -

            Thanks, Dan.

            Show
            salvetore Michael de Raadt added a comment - Thanks, Dan.
            Hide
            salvetore Michael de Raadt added a comment -

            Test result: Success

            Tested in master and 2.3 with MySQL, MSSQL, PostgreSQL and Oracle.

            Show
            salvetore Michael de Raadt added a comment - Test result: Success Tested in master and 2.3 with MySQL, MSSQL, PostgreSQL and Oracle.
            Hide
            salvetore Michael de Raadt added a comment -

            The code that led to this regression was only in circulation for about two weeks and this issue has been duplicated seven times.

            Show
            salvetore Michael de Raadt added a comment - The code that led to this regression was only in circulation for about two weeks and this issue has been duplicated seven times.
            Hide
            woolardfa@appstate.edu Fred Woolard added a comment -

            Regrets. At the moot in L.A. Getting the overwhelming impression that Oracle not a good choice, but then the immediate comment after the downside is, "you'd be doing the community a service [by finding the problems]..."

            Show
            woolardfa@appstate.edu Fred Woolard added a comment - Regrets. At the moot in L.A. Getting the overwhelming impression that Oracle not a good choice, but then the immediate comment after the downside is, "you'd be doing the community a service [by finding the problems] ..."
            Hide
            poltawski Dan Poltawski added a comment -

            asko, Дзякуй, ধন্যবাদ, Благодаря, Gràcies, 感谢, 謝謝, Hvala, Díky, Tak, Bedankt, Tänan, متشکریم, Salamat, Kiitokset, Merci, Grazas, Danke, Ευχαριστώ, આભાર, תודה, धन्यवाद, Köszönjük, Takk fyrir, Terima Kasih, Grazie, ありがとうございます, Рахмет, សូមអរគុណ, 감사합니다, gratiās, Pateicamies, Ačiū, Благодарам, Tēnā koa, Kia Ora Rawa Atu, आभारी आहोत, Талархал, Takk, Dziękuję, Obrigado, Mulţumesc, Engraziel, Спасибо, Fa'afetai, Хвала, Hvala, ස්තූතියි, Vďaka, Hvala, Mahadsanid, Thanks, Gracias, Tack, Salamat, நன்றி, నెనరులు, ขอบคุณค่ะ!

            Your work has made it into this weeks Moodle release! There are no gold medals available this week - but millions around the world will benefit. Thank you!

            Show
            poltawski Dan Poltawski added a comment - asko, Дзякуй, ধন্যবাদ, Благодаря, Gràcies, 感谢, 謝謝, Hvala, Díky, Tak, Bedankt, Tänan, متشکریم, Salamat, Kiitokset, Merci, Grazas, Danke, Ευχαριστώ, આભાર, תודה, धन्यवाद, Köszönjük, Takk fyrir, Terima Kasih, Grazie, ありがとうございます, Рахмет, សូមអរគុណ, 감사합니다, gratiās, Pateicamies, Ačiū, Благодарам, Tēnā koa, Kia Ora Rawa Atu, आभारी आहोत, Талархал, Takk, Dziękuję, Obrigado, Mulţumesc, Engraziel, Спасибо, Fa'afetai, Хвала, Hvala, ස්තූතියි, Vďaka, Hvala, Mahadsanid, Thanks, Gracias, Tack, Salamat, நன்றி, నెనరులు, ขอบคุณค่ะ! Your work has made it into this weeks Moodle release! There are no gold medals available this week - but millions around the world will benefit. Thank you!
            Hide
            salvetore Michael de Raadt added a comment -

            We may have a challenger for most duplicated issue. It's still early days, but...

            Gee I wish people would search for issues before reporting.

            Show
            salvetore Michael de Raadt added a comment - We may have a challenger for most duplicated issue. It's still early days, but... Gee I wish people would search for issues before reporting.
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            Note: I'm backporting the final solution (take rid of the AS keyword) @ MDL-30514. Not sure why both MDL-34072 and MDL-34440 were not backported... but the problem remains there.

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - Note: I'm backporting the final solution (take rid of the AS keyword) @ MDL-30514 . Not sure why both MDL-34072 and MDL-34440 were not backported... but the problem remains there.
            Hide
            ajnabiz AjnabiZ added a comment - - edited

            The issue exists in 2.4.1

            Show
            ajnabiz AjnabiZ added a comment - - edited The issue exists in 2.4.1
            Hide
            salvetore Michael de Raadt added a comment -

            Hi, Ajbabiz.

            Your unedited comment suggested you were getting a database error during installation, which is different to the error reported here.

            I suspect the error you are facing is related to how you have set up your database.

            I suggest you seek help in the Installation forum: http://moodle.org/mod/forum/view.php?id=28

            Show
            salvetore Michael de Raadt added a comment - Hi, Ajbabiz. Your unedited comment suggested you were getting a database error during installation, which is different to the error reported here. I suspect the error you are facing is related to how you have set up your database. I suggest you seek help in the Installation forum: http://moodle.org/mod/forum/view.php?id=28

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Sep/12