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

Unable to setup backpack connection - "Error writing to database"

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5, 2.6
    • Fix Version/s: 2.5.2
    • Component/s: Badges
    • Labels:

      Description

      When attempting to setup a backpack connection, an error occurs after clicking the Connect button: "Error writing to database".

      • Have tried in all major browsers.
      • Have tried connecting to different email addresses.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            ybozhko Yuliya Bozhko added a comment -

            Was able to reproduce only when I unplugged my computer from the Internet Need to make sure there is a proper error handling when no connection can be established.

            Show
            ybozhko Yuliya Bozhko added a comment - Was able to reproduce only when I unplugged my computer from the Internet Need to make sure there is a proper error handling when no connection can be established.
            Hide
            ybozhko Yuliya Bozhko added a comment -

            Are you by any chance behind firewall or going through proxy?

            Show
            ybozhko Yuliya Bozhko added a comment - Are you by any chance behind firewall or going through proxy?
            Hide
            mcwoods Michael Woods added a comment -

            Yes, going through proxy. But proxy details are entered, and can hit external repositories, for instance.

            Show
            mcwoods Michael Woods added a comment - Yes, going through proxy. But proxy details are entered, and can hit external repositories, for instance.
            Hide
            ybozhko Yuliya Bozhko added a comment -

            Moodle curl class is supposed to handle proxy (at least, that's what Dan Poltawski told me)... But I never actually tried it as we don't use proxy for Internet connection. Need to have a look at this issue. Anyway I should probably add a better message when a user backpack cannot be accessed.

            Show
            ybozhko Yuliya Bozhko added a comment - Moodle curl class is supposed to handle proxy (at least, that's what Dan Poltawski told me)... But I never actually tried it as we don't use proxy for Internet connection. Need to have a look at this issue. Anyway I should probably add a better message when a user backpack cannot be accessed.
            Hide
            poltawski Dan Poltawski added a comment -

            It definitely does support a proxy (the repositories use the same thing)

            Show
            poltawski Dan Poltawski added a comment - It definitely does support a proxy (the repositories use the same thing)
            Hide
            mcwoods Michael Woods added a comment -

            Hi,

            Just to bump this issue a bit, I've tried the same thing in the latest 2.6, and get the same error. I can confirm:
            1. I've entered proxy details
            2. I can retrieve external repository content, such as images in the 'URL Downloader' repository (which fails if no proxy details are configured)
            3. I still get the "Error writing to database" when attempting to setup a backpack connection.

            Has the curl class been used in exactly the same way as the repositories? It's really strange that it would work in one place, but not the other.

            Thanks for your help!
            Michael

            Show
            mcwoods Michael Woods added a comment - Hi, Just to bump this issue a bit, I've tried the same thing in the latest 2.6, and get the same error. I can confirm: 1. I've entered proxy details 2. I can retrieve external repository content, such as images in the 'URL Downloader' repository (which fails if no proxy details are configured) 3. I still get the "Error writing to database" when attempting to setup a backpack connection. Has the curl class been used in exactly the same way as the repositories? It's really strange that it would work in one place, but not the other. Thanks for your help! Michael
            Hide
            ybozhko Yuliya Bozhko added a comment -

            Hey Michael,

            Sorry haven't got around this issue yet. I will try to check sometimes soon.

            Yuliya

            Show
            ybozhko Yuliya Bozhko added a comment - Hey Michael, Sorry haven't got around this issue yet. I will try to check sometimes soon. Yuliya
            Hide
            ybozhko Yuliya Bozhko added a comment -

            Hi Michael,

            Is there any chance you can check if adding a proxy setting fixes a problem for you?

            /badges/lib/backpacklib.php L47

            $curl = new curl(array('proxy' => true));

            It might be that simple, but I have no way of testing this myself I will submit a patch if it resolves the issue.

            Thanks!

            Yuliya

            Show
            ybozhko Yuliya Bozhko added a comment - Hi Michael, Is there any chance you can check if adding a proxy setting fixes a problem for you? /badges/lib/backpacklib.php L47 $curl = new curl(array( 'proxy' => true )); It might be that simple, but I have no way of testing this myself I will submit a patch if it resolves the issue. Thanks! Yuliya
            Hide
            mcwoods Michael Woods added a comment -

            Hi Yuliya,

            Just tried it and still getting error. Error and stacktrace:
            Error writing to database

            More information about this error

            Debug info: Column 'backpackuid' cannot be null
            INSERT INTO mdl_badge_backpack (userid,email,backpackurl,backpackuid,autosync,password) VALUES(?,?,?,?,?,?)
            [array (
            0 => 2,
            1 => 'mcwoods1@gmail.com',
            2 => 'http://backpack.openbadges.org',
            3 => NULL,
            4 => 0,
            5 => '',
            )]
            Error code: dmlwriteexception
            Stack trace:
            line 426 of /lib/dml/moodle_database.php: dml_write_exception thrown
            line 1089 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
            line 1131 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
            line 124 of /badges/mybackpack.php: call to mysqli_native_moodle_database->insert_record()
            Output buffer: <br /> <b>Notice</b>: Trying to get property of non-object in <b>/mnt/moodle/moodle2e/badges/mybackpack.php</b> on line <b>121</b><br />

            Happy to try other things if you have suggestions!

            Regards,
            Michael

            Show
            mcwoods Michael Woods added a comment - Hi Yuliya, Just tried it and still getting error. Error and stacktrace: Error writing to database More information about this error Debug info: Column 'backpackuid' cannot be null INSERT INTO mdl_badge_backpack (userid,email,backpackurl,backpackuid,autosync,password) VALUES(?,?,?,?,?,?) [array ( 0 => 2, 1 => 'mcwoods1@gmail.com', 2 => 'http://backpack.openbadges.org', 3 => NULL, 4 => 0, 5 => '', )] Error code: dmlwriteexception Stack trace: line 426 of /lib/dml/moodle_database.php: dml_write_exception thrown line 1089 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end() line 1131 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw() line 124 of /badges/mybackpack.php: call to mysqli_native_moodle_database->insert_record() Output buffer: <br /> <b>Notice</b>: Trying to get property of non-object in <b>/mnt/moodle/moodle2e/badges/mybackpack.php</b> on line <b>121</b><br /> Happy to try other things if you have suggestions! Regards, Michael
            Hide
            ybozhko Yuliya Bozhko added a comment -

            Okay... that not good. Then I will ask you to do some debugging for me

            If you add at the end of L71 of the same backpacklib file:

            var_dump($out); var_dump($curl);

            it will disable automatic redirect and return lots of variable settings. Can you please copy all those and send them to me? You can email me at yuliya.bozhko@totaralms.com

            Thanks!

            Show
            ybozhko Yuliya Bozhko added a comment - Okay... that not good. Then I will ask you to do some debugging for me If you add at the end of L71 of the same backpacklib file: var_dump($out); var_dump($curl); it will disable automatic redirect and return lots of variable settings. Can you please copy all those and send them to me? You can email me at yuliya.bozhko@totaralms.com Thanks!
            Hide
            mcwoods Michael Woods added a comment -

            Okay, done, and email sent!

            Show
            mcwoods Michael Woods added a comment - Okay, done, and email sent!
            Hide
            poltawski Dan Poltawski added a comment -

            Hi Yuliya,

            Could you explain a ibt about this, have you found the problem?

            I don't think that proxy => true should be it (like I say, it should be the default behaviour)

            thanks,
            Dan

            Show
            poltawski Dan Poltawski added a comment - Hi Yuliya, Could you explain a ibt about this, have you found the problem? I don't think that proxy => true should be it (like I say, it should be the default behaviour) thanks, Dan
            Hide
            mcwoods Michael Woods added a comment -

            Hi guys, my testing found that only the HTTP_HEADER line (in the diff patch) made it work behind our squid proxy. The proxy => true didn't make a difference.

            Show
            mcwoods Michael Woods added a comment - Hi guys, my testing found that only the HTTP_HEADER line (in the diff patch) made it work behind our squid proxy. The proxy => true didn't make a difference.
            Hide
            ybozhko Yuliya Bozhko added a comment -

            Hi Dan,

            The problem is that Michael is using old Squid server which expects HTTP/1.0 response. Mozilla backpack sends HTTP/1.1 and as a result we get an error 417 that expectations are not met. Have a look here http://snowulf.com/2009/08/17/php-curl-expectation-failed/

            Yuliya

            Show
            ybozhko Yuliya Bozhko added a comment - Hi Dan, The problem is that Michael is using old Squid server which expects HTTP/1.0 response. Mozilla backpack sends HTTP/1.1 and as a result we get an error 417 that expectations are not met. Have a look here http://snowulf.com/2009/08/17/php-curl-expectation-failed/ Yuliya
            Hide
            poltawski Dan Poltawski added a comment -

            Makes sense, +1 for sending the fix to integration (without the proxy bit, as I don't think its necessary and adding more instances of it in the code just will confuse more people )

            Show
            poltawski Dan Poltawski added a comment - Makes sense, +1 for sending the fix to integration (without the proxy bit, as I don't think its necessary and adding more instances of it in the code just will confuse more people )
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Thanks guys - this has been integrated now

            Show
            samhemelryk Sam Hemelryk added a comment - Thanks guys - this has been integrated now
            Hide
            jerome Jérôme Mouneyrac added a comment -

            All good thanks guys.

            Show
            jerome Jérôme Mouneyrac added a comment - All good thanks guys.
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Against all probability we've achieved normality. You changes didn't break the tests I pretended to run and are now immortalised upstream. Good for you!

            "It was a programming technique that had been reverse-engineered from the sort of psychotic mental blocks that otherwise perfectly normal people had been observed invariably to develop when elected to high political office."
            Adams, D (1992) Mostly Harmless. London: William Heinemann.

            Show
            samhemelryk Sam Hemelryk added a comment - Against all probability we've achieved normality. You changes didn't break the tests I pretended to run and are now immortalised upstream. Good for you! "It was a programming technique that had been reverse-engineered from the sort of psychotic mental blocks that otherwise perfectly normal people had been observed invariably to develop when elected to high political office." Adams, D (1992) Mostly Harmless. London: William Heinemann.

              People

              • Votes:
                3 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Sep/13