I tried installing automated logout onto my drupal 7 site; I got an error when it installed although I didn't think to write it down. I logged out, and when I try to login again, I get:

Fatal error: Call to undefined function db_fetch_object() in /../../public_html/example.com/drupal7/sites/all/modules/autologout/autologout.module on line 563

I'm very new at drupal, so if this is in the wrong place, please let me know.

Comments

Anonymous’s picture

I'm getting exactly the same error on login.

Fatal error: Call to undefined function db_fetch_object() in D:\My Documents\Drupal 7\sites\all\modules\autologout\autologout.module on line 563

Regards

justintime’s picture

Priority: Normal » Critical

db_fetch_object() doesn't exist now, nor will it ever exist in D7. Removing it was part of the DBTNG rewrite. This tells me that the 7.x-2.x branch isn't even being used by the developers, because this would've been caught right away.

The really shitty thing is that simply installing this module will completely break a D7 site, and you have to manually remove the module in order to be able to login again. In order to restore your site, open up the autologout.module file mentioned in your error, and find the lines that say this:

    while ($row = db_fetch_object($result)) {
	      $user_settings[$row->uid] = $row->setting;
	    }

Delete those 3 lines. You can now go in and disable+uninstall the module via the UI.

Marking as a critical bug report because any D7 site using this will immediately break. Yes, I understand it's a dev snapshot, but if the branch is this broken, please remove the release.

Anonymous’s picture

It's working for me now, even with the code quoted by justintime remaining in place.

UPDATE: Spoke too soon. Error still occurring.

ellen.davis’s picture

A user posted a fix for Custom Permissions issue queue for this same problem - db_fetch_object undefined.
See http://drupal.org/node/1097558

Basically the suggestion was to replace the while with a foreach.
Replace

    while ($row = db_fetch_object($result)) { 
      $user_settings[$row->uid] = $row->setting;
    }

With

    foreach ($result as $row) {
      $user_settings[$row->uid] = $row->setting;
    }

This seems to work for me, at least I don't get the error anymore.

Anonymous’s picture

I also don't get the error message anymore.

Instead I get:

Notice: Undefined index: authenticated user in _autologout_by_role() (line 526 of path/sites/all/modules/autologout/autologout.module).

Also, the UI for the module seems to have gone missing.

Is this module still being maintained? There doesn't seem to have been any activity for months.

daften’s picture

subscribe

NROTC_Webmaster’s picture

sub

webengr’s picture

subscribe

kmasood’s picture

Tried that, but it does not log the user out. Does it function for you otherwise?

iansears’s picture

subscribe

ryantollefson’s picture

#4 fixed the error for me. I haven't verified if it is actually working or not though.

jlyon’s picture

#4 works for me as well.

Jesuscares’s picture

After applying the change in #4, I also get that error mentioned in #5!

Specifically I get this showing at the top of the user UI now:
Notice: Undefined index: authenticated user in _autologout_by_role() (line 526 of /home/foobarsite/public_html/sites/all/modules/autologout/autologout.module).

Any fix for that?

BenK’s picture

Subscribing

Jesuscares’s picture

I'm going to try out the persistent Login module (there's a Drupal 7 dev release) until the Automated Login module is working for Drupal 7

Update 2011-09-30: The "Persistent Login" module didn't work for me either. It sure would be great if someone could fix "Automated Login" for Drupal 7. I have a security risk without this module because many of my users are novice internet users and Drupal 7 allows their session to stay logged in on a public terminal if they don't take the time to logout.

This is such a large issue that I've been counseled by a very experienced Drupal developer to revert back to Drupal 6. That would be unfortunate because this Logout issue is the only issue I have with Drupal 7 at this time.

kmasood’s picture

I have a working copy of autologout on D7 (see note here: http://drupal.org/node/1117706#comment-4897540 ). What is the best way to post it? Attach it to this thread?

Jesuscares’s picture

@kmasood (Re: #16) Thanks! I'm not certain, but that link to where you have a "patch" is something I'm going to try! thanks!

I tried it and still received an error while trying to login:

Fatal error: Call to undefined function db_result() in /home/ogcmwil4/public_html/sites/all/modules/autologout/autologout.module on line 696

Here's the code around line 696 (I've labeled line 696):

function _autologout_invalidate_other_sessions($account) {
// check to see if the user is already logged in somewhere else
// if so deactivate that login and let the user know that the
// other session has been deactivated
$sql = "SELECT COUNT(*) as count FROM {sessions} WHERE uid = '%s' AND sid <> '%s'";
696: $result = db_result(db_query($sql, $account->uid, session_id()));
//drupal_set_message('session counts = '. $result);
if ($result != 0) {

jlyon’s picture

@kmasood; Could you post your working version as a patch of the current 7.x-dev branch or a tarball? Thanks!

kmasood’s picture

StatusFileSize
new17.21 KB

Tar ball attached. Please give credit to A. Riberi of chapterthree.com.

domesticat’s picture

Status: Active » Needs review

Marking "needs review" to help nudge others into testing.

ryantollefson’s picture

#19 works pretty well for me; however, I'm getting a little bit of strange behavior. It seems that when viewing an overlay page, it will redirect to the /user/# page shortly before the timeout is reached (and the timer is reset). When disabling the module, this action stops.

Great progress so far though. :)

ryantollefson’s picture

Another thing I am noticing is that the timer is not reset when using overlay pages - it keeps going from before that page was opened.

kmasood’s picture

We've disabled overlays because of the performance overhead (and in my personal opinion, some UI overhead as well), and not seeing #s 21 & 22 when overlay is disabled.

remyarose’s picture

#19:- Thanks..this one works for me....

grayaj88’s picture

#19:- working for me as well. Thanks for this update.

netourish’s picture

Thank You all!, @nitmd for posting this and @kmasood for the solution. It worked for me.

trrroy’s picture

StatusFileSize
new36.58 KB

Yes, works for me. I used @kmasood files from #19 and created the attached patch file. Thanks @kmasood and A. Riberi of chapterthree.com

jrglasgow’s picture

Status: Needs review » Fixed

@trrroy - I applied the patch and committed it. There was one error with the patch, next time please create the patch against the git branch instead of the dev build

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

subhojit777’s picture

thank you soooo much

sayantanlaha’s picture

Priority: Critical » Normal

I have got the same error when I am trying to fetch my custom module data.......but now it got fixed.

  • Commit b445f86 on 7.x-2.x, 7.x-5.x, 7.x-4.0, 8.x-1.x by jrglasgow:
    Issue #1034288 by trrroy, kmasood, A. Riberi: Fatal error: Call to...
vishnu9609’s picture

Issue summary: View changes

#4 works for me.. Thanks..

vishnu9609’s picture