This error appears to me in allot different places
Fatal error: Call to undefined method stdClass::get_name() in .../sites/all/modules/i18n/i18n_string/i18n_string.inc on line 583

I was doing a new website and just enabled i18n for page content type and it started apear again.

I dont know what's wrong. I tought it should be some mistake i made, but now in a new website it happens again!

CommentFileSizeAuthor
#11 fetchAll_002.patch1015 bytesnicorac
#9 fetchAll_001.patch1.01 KBnicorac

Comments

porfirio’s picture

Adding, changing and removing content types also give-me this error

This is getting annoying

I think i might have to stop using Drupal :(

nicorac’s picture

Status: Active » Closed (duplicate)

I'm experiencing the same bug.

After a long debug I found the bug and sent a fix here.

The bug is into Drupal core (database), not i18n module as it seems at first sight.
Closing this and marking as a duplicate of the new issue...

nicorac’s picture

Status: Closed (duplicate) » Needs review

Reopened because I need someone helping me completing the missing steps over there.

jose reyero’s picture

Priority: Critical » Normal
Status: Needs review » Closed (duplicate)

Duplicating issues won't help anyone.

nicorac’s picture

Status: Closed (duplicate) » Needs work

I'm not really sure this is a duplicate:
- the bug is into core (DatabaseStatement.fetchAll() method), but it was "silent" till now because nobody used fetchAll(PDO::FETCH_CLASS, ...) till now; also there's no test created for it
- the bug effects was shown by i18n_string module

i18n_string module contains a function (i18n_string_load_multiple) that needs to be fixed, until my (or other's) patch the core files were accepted (and backported to 7.x), otherwise node deletion is impossible.

porfirio’s picture

The problem might only occur when using SQLITE as database

In this website
http://www.sitepoint.com/forums/showthread.php?528019-PDO-FETCH_CLASS-we...

They found the same problem.

I changed i18n_string.module on line 456

return $query->execute()->fetchAll(PDO::FETCH_CLASS, 'i18n_string_object');
to:
$stmt=$query->execute();
$stmt->setFetchMode(PDO::FETCH_CLASS, 'i18n_string_object');
$result=array();
foreach($stmt as $o) {
array_push($result,$o);
}
return $result;

Might not be the best way, but it is working, at least for now...

nicorac’s picture

@porfirio:
you're doing what fetchAll() function is supposed to do when called with the first parameter=PDO::FETCH_CLASS, so it's not so bad.
That's why we have 2 issues:
- core, needs a fix
- i18n_string needs a workaround (like yours) till core is fixed

jose reyero’s picture

Title: Error in i18n » Error in i18n_string when using SQLite: Call to undefined method stdClass::get_name()
Status: Needs work » Postponed

Ok. Fixing title.

Nothing to do on our side, though you can post a patch here as a temporary fix.

nicorac’s picture

Title: Error in i18n_string when using SQLite: Call to undefined method stdClass::get_name() » Error in i18n_string: Call to undefined method stdClass::get_name()
Status: Postponed » Needs review
StatusFileSize
new1.01 KB

Linked page in #6 was not completely related.
Our bug is in core file includes/database/prefetch.inc, which is used by all the database drivers.

On my side I have the same bug with both SQLite and MySQL, so I'll put the title back as before.

Attached is a patch with a workaround till core fix will be applied.

Status: Needs review » Needs work

The last submitted patch, fetchAll_001.patch, failed testing.

nicorac’s picture

Status: Needs work » Needs review
StatusFileSize
new1015 bytes

Fixed line endings (log says "invalid format, no more dateils...)

Elvar’s picture

Nicorac, works like a charm, thank you. Out of curiosity could you tell what the issue was with the first one, seems identical :)..

nicorac’s picture

I only changed line endings format, DOS --> UNIX.

steinmb’s picture

Status: Needs review » Reviewed & tested by the community

Jumped up and bit me too during site-install in my sandbox. The patch looks good to me. Let's go ahead and commit this. The official core fix if found at #1567216: DatabaseStatementPrefetch.fetchAll() implementation does not work when $fetch_style parameter is PDO::FETCH_CLASS and need reviewers.

boobaa’s picture

Patch in #11 works for me, too.

jose reyero’s picture

Status: Reviewed & tested by the community » Fixed

Ok, committed.

Status: Fixed » Closed (fixed)

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