Forums | Mahara Community

Developers /
Auth Plugin


anonymous profile picture
Account deleted
Posts: 7

14 September 2009, 18:28

Hi, i'm developing a new auth method. This method connect to my personal database. But when i connect to mine, mahara show this error:

Fatal error: Exception thrown without a stack frame in Unknown on line 0

Who the think is whit the mysql_connec().

Here's the code of de auth:

<?php

...

 public function authenticate_user_account($user, $password) {
        $this->must_be_ready();
        $username = $user->username;
               
        $Midid = mysql_connect('localhost', 'root', '137952');
        mysql_select_db('mid', $Midid);
        $Midquery = mysql_query("SELECT username, password FROM user WHERE username = '$username'", $Midid);
    $result = mysql_fetch_row($Midquery);
    if($result['1'] == $password) return true;
         
    }

...

?>

Sorry for the ortography, i'm from spain.

Very thanks!!!

anonymous profile picture
Account deleted
Posts: 1643

14 September 2009, 19:13

Hi - have a look in the apache error log for your Mahara install. It will probably have more information about the error. If you can find the log and paste it here, we might be able to help Smile

Failing that, try commenting out some lines and see when the error stops, so you know what line it's happening on. 

anonymous profile picture
Account deleted
Posts: 7

15 September 2009, 17:26

Thanks for the help. The error_log of apache is:

...more errors...

[Wed Sep 16 00:19:11 2009] [error] [client ::1] [WAR] 9e (lib/errors.php:663) Command was: SELECT * FROM "artefact_installed" WHERE "active" = ?  and values was (1), referer: http://localhost/mahara/
[Wed Sep 16 00:19:11 2009] [error] [client ::1] Call stack (most recent first):, referer: http://localhost/mahara/
[Wed Sep 16 00:19:11 2009] [error] [client ::1]   * log_message("Failed to get a recordset: mysql error: [1146: Tab...", 8, true, true) at /var/www/mahara/lib/errors.php:90, referer: http://localhost/mahara/
[Wed Sep 16 00:19:11 2009] [error] [client ::1]   * log_warn("Failed to get a recordset: mysql error: [1146: Tab...") at /var/www/mahara/lib/errors.php:663, referer: http://localhost/mahara/
[Wed Sep 16 00:19:11 2009] [error] [client ::1]   * SQLException->__construct("Failed to get a recordset: mysql error: [1146: Tab...") at /var/www/mahara/lib/dml.php:469, referer: http://localhost/mahara/
[Wed Sep 16 00:19:11 2009] [error] [client ::1]   * get_recordset_sql("SELECT * FROM "artefact_installed" WHERE "active" ...", array(size 1)) at /var/www/mahara/lib/dml.php:405, referer: http://localhost/mahara/
[Wed Sep 16 00:19:11 2009] [error] [client ::1]   * get_recordset_select("artefact_installed", ""active" = ?", array(size 1), "", "*", "", "") at /var/www/mahara/lib/dml.php:369, referer: http://localhost/mahara/
[Wed Sep 16 00:19:11 2009] [error] [client ::1]   * get_recordset("artefact_installed", "active", 1, "", "*", "", "") at /var/www/mahara/lib/dml.php:576, referer: http://localhost/mahara/
[Wed Sep 16 00:19:11 2009] [error] [client ::1]   * get_records_array("artefact_installed", "active", 1) at /var/www/mahara/lib/web.php:1771, referer: http://localhost/mahara/
[Wed Sep 16 00:19:11 2009] [error] [client ::1]   * mahara_standard_nav() at /var/www/mahara/lib/web.php:1798, referer: http://localhost/mahara/
[Wed Sep 16 00:19:11 2009] [error] [client ::1]   * main_nav() at /var/www/mahara/lib/web.php:368, referer: http://localhost/mahara/
[Wed Sep 16 00:19:11 2009] [error] [client ::1]   * smarty() at /var/www/mahara/lib/errors.php:501, referer: http://localhost/mahara/
[Wed Sep 16 00:19:11 2009] [error] [client ::1]   * MaharaException->handle_exception() at /var/www/mahara/lib/errors.php:404, referer: http://localhost/mahara/
[Wed Sep 16 00:19:11 2009] [error] [client ::1]   * exception(object(SQLException)) at Unknown:0, referer: http://localhost/mahara/

...more errors...

Awaiting yours answers, Cristian D.

anonymous profile picture
Account deleted
Posts: 1643

15 September 2009, 21:11

Hm. MySQL error 1146 is "table does not exist", but surely you have an artefact_installed table. Is there one in your database?

On an unrelated note, can you go into Site Administration, Manage Extensions, then have a look under the Auth header, and see if your plugin is showing up as installed? 

anonymous profile picture
Account deleted
Posts: 7

16 September 2009, 8:49

The tables exists on Mahara DataBase and the plugin is installed. I think the problem is the connection to other data base.

Thanks

anonymous profile picture
Account deleted
Posts: 7

17 September 2009, 6:19

I think there is a conflict with the class that connects to MySQL to create a new connection.
Please i need a solution!!!
anonymous profile picture
Account deleted
Posts: 7

21 September 2009, 18:19

Hm, I was looking for the errors when I dont know for where I go. Now the error is:

Fatal error: Uncaught exception 'SQLException' with message 'Failed to get a recordset: mysql error: [: ] in EXECUTE("SELECT activity,method FROM "usr_activity_preference" WHERE "usr" = '3' ") Command was: SELECT activity,method FROM "usr_activity_preference" WHERE "usr" = ? and values was (3)' in /var/www/mahara/lib/dml.php:469 Stack trace: #0 /var/www/mahara/lib/dml.php(405): get_recordset_sql('SELECT activity...', Array) #1 /var/www/mahara/lib/dml.php(369): get_recordset_select('usr_activity_pr...', '"usr" = ?', Array, '', 'activity,method', '', '') #2 /var/www/mahara/lib/dml.php(552): get_recordset('usr_activity_pr...', 'usr', '3', '', 'activity,method', '', '') #3 /var/www/mahara/lib/user.php(40): get_records_assoc('usr_activity_pr...', 'usr', '3', '', 'activity,method') #4 /var/www/mahara/auth/user.php(893): load_activity_preferences('3') #5 /var/www/mahara/auth/user.php(802): LiveUser->authenticate(Object(stdClass), '4') #6 /var/www/mahara/auth/lib.php(1114): LiveUser->login('pepito', '137952') #7 [internal functi in /var/www/mahara/lib/dml.php on line 469

This happend when i login to mahara and do the query to my table but I reload the page and login me!, so, I put the incorrect password and user and i doesn't logging me but I put the correct login and show, I reload the page and it all OK.

Please help me, even to hide the error.

Thanks.

 

anonymous profile picture
Account deleted
Posts: 228

22 September 2009, 0:50

What happens if you paste that directly into your database?

SELECT activity,method FROM "usr_activity_preference" WHERE "usr" = '3' "

You're querying an external database for authentication information, right? Is it possible that you're overriding the database information in $db or $CFG or something, and then afterwards not setting it back to what it was, so Mahara is trying to connect to the wrong database to query its own tables?

anonymous profile picture
Account deleted
Posts: 7

22 September 2009, 15:43

I don't touch $db or $CFG. I sure this is the error but I can't see it in the code and I can't resolve them.

When I do the query with SQL directly on my database, this return me the correct information so I copy the entire table fron mahara and paste on my own.

Can see the code:

    public function authenticate_user_account($user, $password) {
        $this->must_be_ready();
        $username = $user->username;
       
        // empty username or password is not allowed.
        /*if (empty($username) or empty($password)) {   
            return false;
        }*/
        $Midid = mysql_connect('localhost', 'root', '137952');
        mysql_select_db('mid', $Midid);
        $Midquery = mysql_query("SELECT * FROM user WHERE username = '$username'", $Midid);
    $result = mysql_fetch_row($Midquery);
    //echo("<script>alert('".$result['1']."')</script>");
    if($result[2] == $password){
        mysql_close($Midid);
        return true;
    }
    else return false;
      
    }

 This is in lib.php inside the plugin auth folder.

Thanks

anonymous profile picture
Account deleted
Posts: 7

22 September 2009, 16:19

How can I do to stop it crossing the two databases or how can I do to hide the error.

I trying to hide the error but it's impossible or I can't do it. The other solution is stop the crossing. If you see y close the connection in the login (mysql_close) but the error persists.

14 results