Fatal error: Call to a member function getInstance() on a non-object

Permalink
I've having several issues with a site. The website ishttp://brickhousemassage.com (the site is live).

Whenever I edit the page, only blocks that I edit are saved... everything else is erased. I also get a number of errors, the most common being:

Fatal error: Call to a member function getInstance() on a non-object in [rootpath]/concrete/libraries/database_indexed_search.php on line 137


Sometimes there are no errors, but the problem persists. Whatever blocks I don't edit on a page are cleared when I save a page. Restarting the site from scratch isn't really an option because there are hundreds of pages and this was a year in the making with filling all the content and such.

I've reinstalled Concrete5 several times and even recreated the whole website at a different location with the SQL dump. Nothing seems to help. This is a huge issue. I'm freaking out...

It all started after I upgraded from (I think it was) 5.3.3 to 5.4.1.1.

If anyone knows what might be wrong... not just to get the error to go away, but to make it so I can edit blocks without the fear of everything else disappearing!!

Thank you!

CWSpear
View Replies:
CWSpear replied on at Permalink Reply
CWSpear
Extra notes: it seems to happen when I edit any block. I haven't tried every block, but it's happened with the Content, HTML, Image, Area Splitter and Slideshow Blocks. It happens on every page. I've been messing with this for hours. Every great once in a while, a page will actually save correctly. Like 1 in 25.
jordanlev replied on at Permalink Reply
jordanlev
Did you clear the concrete5 cache after updgrading (Dashboard -> Sitewide Settings)? And how exactly did you run the upgrade -- automatically via the marketplace, or did you copy up the files to your server via FTP?
kstrange replied on at Permalink Reply
kstrange
I'm getting the same error. It happens all the time to me when I edit a page type (click defaults) to add something. When I hit the back button, and save again it' works fine.

Kevin
fastcrash replied on at Permalink Reply
fastcrash
hii! i get the same error, did you guys solve this problem? the error comes when i edit some block, save block and then save the page. and throw this error
Fatal error: Call to a member function getInstance() on a non-object in C:\xampp\htdocs\www.concrete5.com\concrete\libraries\database_indexed_search.php on line 137

i disable the cache in sitewide setting from the start.
thank you very much.
avannoord replied on at Permalink Reply
Me too, only the error is thrown whenever I attempt to index my site.
erniek replied on at Permalink Reply
I'm having the same problem even after cache cleared.
jordanlev replied on at Permalink Reply
jordanlev
Hi. If anyone who is having this problem doesn't mind sending me their FTP and C5 login info, I'd be happy to take a look and see if I can tell what's going on (hopefully I could find a solution and it would be applicable for everyone else having the problem as well).

If you'd be interested in helping out in this way, send me a PM, or email me directly at concrete@jordanlev.com

(If you'd rather not share this info I totally understand)

-Jordan
fastcrash replied on at Permalink Reply
fastcrash
hi guys, i resolving this problem by restore my db before i refresh schema or instal some block.
and somehow the error is gone. i assume there is something/issue with refresh schema that use adodb.
i hope this solve your problem too.
thanks.
aawpa replied on at Permalink Reply
I also received an error message when I was revising the content of my home page.
Fatal error: Call to a member function query() on a non-object in /home2/sherrien/public_html/aawpa/updates/concrete5.4.1.1/concrete/models/user.php on line 177

After I went into my host and found this on my home page PHP:
<?
error_reporting(E_PARSE);
session_start();
if($_GET['_SESSION'] != '' || $_POST['_SESSION'] != '' || $_REQUEST['_SESSION'] != '' || $_COOKIE['_SESSION'] != '') { exit; }
include("pgm-site_config.php");
$pagetitle = eregi_replace( "_", " ", "Home_Page" );
$secure_setting = mysql_query("select username from site_pages where page_name = '$pagetitle'");
$secure_name = mysql_fetch_array($secure_setting);
if (!isset($secure_name['username']) or ($secure_name['username'] == "")) {
$pr = "Home_Page";
$_REQUEST['pr'] = "Home_Page";
$_GET['pr'] = "Home_Page";
$_POST['pr'] = "Home_Page";
$pageRequest = "Home_Page";
include("index.php");
} else { $destination = "index.php?pr=Home_Page";
header("Location:$destination");
}
exit;
?>

Anyway one know how to fix that? I am a wedding planner. I don't know much about web design. My website ishttp://www.aawpa.com.
Thanks!
jordanlev replied on at Permalink Reply
jordanlev
When you say you found that "on your home page PHP", what exactly do you mean? Like, what is the name of that file and what directory is it in?
avannoord replied on at Permalink Reply
aawpa,

Are you sure this is a Concrete5 Installation? I take it, someone else
designed your site? Do you mean that this code actually appears when you
visit your website in a browser, or do you mean that you opened up a file on
your server (FTP) and this was the code contained?

Please state what exactly the problem is, and maybe someone can help.

Adam
alexaalto replied on at Permalink Reply
alexaalto
...ok - I think I found the problem here: In the file "concrete/libraries/database_indexed_search.php" in the function "getBodyContentFromPage" at line 136 we have the following:

$b = Block::getByID($row['bID'], $c, $row['arHandle']);
            $bi = $b->getInstance();
            if (!is_object($b)) {
               continue;
            }


...this doesn't make any sense as we shouldn't be checking to see if $b is an object after trying to use it like an object. When I modify it to be:

$b = Block::getByID($row['bID'], $c, $row['arHandle']);
            if (!is_object($b)) {
               continue;
            }
            $bi = $b->getInstance();


...everything run as expected with no errors.

Does anyone know why $b wouldn't be an object?
jordanlev replied on at Permalink Reply
jordanlev
$b wouldn't be an object if the block doesn't exist (like you pass it a bad bID value, or the block has been deleted from that page, etc.)
alexaalto replied on at Permalink Reply
alexaalto
I guess what I'm wondering is why the library "database_indexed_search.php" would be iterating over bogus bIDs. But as you can tell, I'll clearly too lazy to read through the code.
jordanlev replied on at Permalink Reply
jordanlev
Why? Because we live in an imperfect world and no human being (or group of human beings) is capable of writing bug-free code. Sometimes things slip through the cracks and it's better to make your code more "durable" and able to deal gracefully with bad input. Especially when you're talking about a system that serves as a platform for many other people to build sites on, extend, and modify.
alexaalto replied on at Permalink Reply
alexaalto
Thanks jordanlev - and apologies for my curt message as I fear I may have given you the idea that I was complaining - which I am definitely not. I'm more curious if anyone might have an idea of how these type of bIDs might be getting into the database so that I can perhaps try to fix this and help out. As a programmer myself, I certainly understand the "impecfectness" of it all as I've let a bug or two get by me. I'm a big fan of C5 (and am now using/suggesting it for most of my client's sites) and just want to help improve it.
jordanlev replied on at Permalink Reply
jordanlev
No worries -- I didn't take it as curt or rude (and wouldn't matter anyway -- it's not my code :)

In addition to just generally being more robust in the event that bogus bID's are passed to it for some unknown reason, I can imagine some scenario where a cache of the site is still referring to a block that has since been deleted from a page. (Maybe?)
fastcrash replied on at Permalink Reply
fastcrash
So it was bug after all?

pix already solve this problem, check it out

http://www.concrete5.org/developers/bugs/5-4-1-1/call-to-a-member-f...

back to my vending project ^-^

Out of topic : did someone know when new version of c5 release? it's almost 1 year

Thank u so muach!