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

ablauer

Joined: 2007-08-26
Posts: 39
Posted: Sat, 2007-09-01 21:20

Okay, so thanks to Mindless, I was able to log back in again!!! Once in...I installed the URL rewrite plugin that was on there...and the next thing I knew...any page I went to was blank! I had the "Plugins" page cached there so I went back and did "Uninstall" on the URL rewrite, but it didn't seem to fix the error. I turned on DEBUG mode and this is what I'm getting at any link I try to visit, including trying to get to /lib/support:

Fatal error: Call to a member function on a non-object in /home/hellokat/public_html/adam/gallery/modules/core/classes/Gallery.class on line 243

I opened Gallery.class, and it looks like line 243 is the bold one below:

/* It's possible for the session not to exist during bootstrap time */
$session =& $this->getSession();
if (isset($session)) {
$activeUserId = $session->getUserId();
if ($activeUserId != $user->getId()) {
$session->setUserId($user->getId());
$language = $user->getLanguage();
if (!empty($language)) {
$session->put('core.language', $language);

I deleted the cache folders: modules, themes, entity...and still no luck...


Gallery version (not just "2"): 2.2.3 nightly build from 8/30/07
PHP version (e.g. 5.1.6): 4.4.1
PHPInfo Link (see FAQ): http://adamblauer.com/gallery/phpinfo.php
Webserver (e.g. Apache 1.3.33): 1.3.33
Database (e.g. MySql 5.0.32): 4.0.16
Activated toolkits (e.g. NetPbm, GD): Imagemagick, NetPbm, GD...not sure what else
Operating system (e.g. Linux): Mac OS X
Browser (e.g. Firefox 2.0): Safari 3.0

 
ablauer

Joined: 2007-08-26
Posts: 39
Posted: Sat, 2007-09-01 21:32

I also tried running the upgrader again with no luck...and tried setting versions.dat back to 1.2.17 and running the upgrader again. No change...

 
ablauer

Joined: 2007-08-26
Posts: 39
Posted: Sat, 2007-09-01 21:55

I opened Gallery.class, and it looks like line 243 is bolded below:

/* It's possible for the session not to exist during bootstrap time */
$session =& $this->getSession();
if (isset($session)) {
$activeUserId = $session->getUserId();
if ($activeUserId != $user->getId()) {
$session->setUserId($user->getId());
$language = $user->getLanguage();
if (!empty($language)) {
$session->put('core.language', $language);

 
ablauer

Joined: 2007-08-26
Posts: 39
Posted: Sun, 2007-09-02 09:59

Okay, I did some searching and found this in the FAQ:

I enabled mod_rewrite, but it's not working, and now I can't get back to disable it - how else can I do this?

You have to modify the database manually. (You can use some web based tool do it, e.g. phpmyadmin) Login to your g2database, choose (g2_)PluginMap table. Here you have to modify the line of the rewrite module to deactivate it. To do this you can either: - manually select the line where g_pluginId is "rewrite", and turn the value of the g_active column into 0. or - run the following sql query:
UPDATE g2_PluginMap SET g_active=0 WHERE g_pluginId='rewrite';

That didn't get it working again...nor did anything from here:
http://codex.gallery2.org/Gallery2:FAQ#Images_don.27t_show_up_and_the_album_.2F_photo_links_don.27t_work.2C_what_can_I_do.3F
http://gallery.menalto.com/node/65720

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2007-09-02 12:25

line 243 of YOUR gallery.class file is:

    function getActiveUserId() {
	if (isset($this->_activeUser)) {
	    return (int) $this->_activeUser->getId();
	} else {
	    $session =& $this->getSession();
	    return (int) $session->getUserId();
	}
    }

$session isn't defined.

the session is initialized in main.php -> GalleryInitFirstPass()

please enable "immediate" debug mode. might help to debug the issue.
FAQ: How to set/use Gallery in debug mode?

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
ablauer

Joined: 2007-08-26
Posts: 39
Posted: Sun, 2007-09-02 17:35

Thanks Valiant,
I've turned on immediate and this is what I get:

file_exists(/home/hellokat/public_html/adam/gallery/g2data/cache/module/_all/0/0/GalleryFactoryHelper_loadRegistry.inc) file_exists(/home/hellokat/public_html/adam/gallery/modules/rewrite/classes/parsers/modrewrite/ModRewriteUrlGenerator.class) getParameter modrewrite.galleryLocation for rewrite plugin file_exists(/home/hellokat/public_html/adam/gallery/g2data/cache/module/rewrite/0/0/0.inc)


(mysqlt): SELECT g2_PluginParameterMap.g_itemId, g2_PluginParameterMap.g_parameterName, g2_PluginParameterMap.g_parameterValue FROM g2_PluginParameterMap WHERE g2_PluginParameterMap.g_pluginType = 'module' AND g2_PluginParameterMap.g_pluginId = 'rewrite' AND g2_PluginParameterMap.g_itemId = 0



(mysqlt): update g2_SequenceEventLog set id=LAST_INSERT_ID(id+1);


Fatal error: Call to a member function on a non-object in /home/hellokat/public_html/adam/gallery/modules/core/classes/Gallery.class on line 243

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2007-09-02 18:05

i suggest you add some debugging code to find out what's wrong.

before line 243, add
$error = GallerCoreApi::error(GALLERY_ERROR);
print $error->getAsHtml();

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
ablauer

Joined: 2007-08-26
Posts: 39
Posted: Sun, 2007-09-02 18:27

Okay, I added that right before line 243 and now I'm getting only this on any page I try to navigate to:

Fatal error: Cannot instantiate non-existent class: gallery in /home/hellokat/public_html/adam/gallery/bootstrap.inc on line 43

Line 43 of this is in bold:

$gallery =& new Gallery();
$GLOBALS['gallery'] =& $gallery;

if (!defined('GALLERY_CONFIG_DIR')) {
define('GALLERY_CONFIG_DIR', dirname(__FILE__));
}
@include(GALLERY_CONFIG_DIR . '/config.php');

/*
* Disable session.use_trans_sid to mitigate performance-penalty
* (do it before any output is started)
*/
if (!defined('SID')) {
@ini_set('session.use_trans_sid', 0);
}
?>

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2007-09-02 19:29

i guess your edit of the Gallery.class wasn't all that successful. please verify that the syntax is correct.

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
ablauer

Joined: 2007-08-26
Posts: 39
Posted: Sun, 2007-09-02 20:09

here is what the Gallery.class area looks like:
/**
* Set the id of the active user. The active user is the user who is logged on in this session.
*
* @param GalleryUser $user the current user
*/
function setActiveUser($user) {
$this->_activeUser = $user;
/* It's possible for the session not to exist during bootstrap time */
$session =& $this->getSession();
if (isset($session)) {
$activeUserId = $session->getUserId();
if ($activeUserId != $user->getId()) {
$error = GallerCoreApi::error(GALLERY_ERROR);
print $error->getAsHtml();
$session->setUserId($user->getId());
$language = $user->getLanguage();
if (!empty($language)) {
$session->put('core.language', $language);
}
}
}
}

And actually, it's giving me this message:

file_exists(/home/hellokat/public_html/adam/gallery/g2data/cache/module/_all/0/0/GalleryFactoryHelper_loadRegistry.inc) file_exists(/home/hellokat/public_html/adam/gallery/modules/rewrite/classes/parsers/modrewrite/ModRewriteUrlGenerator.class) getParameter modrewrite.galleryLocation for rewrite plugin file_exists(/home/hellokat/public_html/adam/gallery/g2data/cache/module/rewrite/0/0/0.inc)
(mysqlt): SELECT g2_PluginParameterMap.g_itemId, g2_PluginParameterMap.g_parameterName, g2_PluginParameterMap.g_parameterValue FROM g2_PluginParameterMap WHERE g2_PluginParameterMap.g_pluginType = 'module' AND g2_PluginParameterMap.g_pluginId = 'rewrite' AND g2_PluginParameterMap.g_itemId = 0
(mysqlt): update g2_SequenceEventLog set id=LAST_INSERT_ID(id+1);

Fatal error: Call to a member function on a non-object in /home/hellokat/public_html/adam/gallery/modules/core/classes/Gallery.class on line 244

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2007-09-02 21:47

1. you're changing the wrong code. i said just before line 243 and highlighted the line in my previous post.
2. there's a typo in the snippet. it should be:
$error = GalleryCoreApi::error(GALLERY_ERROR);
print $error->getAsHtml();

so what you should change is:
- revert your changes to Gallery.class

- find

    function getActiveUserId() {
	if (isset($this->_activeUser)) {
	    return (int) $this->_activeUser->getId();
	} else {
$error = GalleryCoreApi::error(GALLERY_ERROR);
print $error->getAsHtml();
	    $session =& $this->getSession();
	    return (int) $session->getUserId();
	}
    }

and replace it with

    function getActiveUserId() {
	if (isset($this->_activeUser)) {
	    return (int) $this->_activeUser->getId();
	} else {
	    $session =& $this->getSession();
	    return (int) $session->getUserId();
	}
    }

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
ablauer

Joined: 2007-08-26
Posts: 39
Posted: Mon, 2007-09-03 00:28

okay, i put it in the correct place:

file_exists(/home/hellokat/public_html/adam/gallery/g2data/cache/module/_all/0/0/GalleryFactoryHelper_loadRegistry.inc) file_exists(/home/hellokat/public_html/adam/gallery/modules/rewrite/classes/parsers/modrewrite/ModRewriteUrlGenerator.class) getParameter modrewrite.galleryLocation for rewrite plugin file_exists(/home/hellokat/public_html/adam/gallery/g2data/cache/module/rewrite/0/0/0.inc)

(mysqlt): SELECT g2_PluginParameterMap.g_itemId, g2_PluginParameterMap.g_parameterName, g2_PluginParameterMap.g_parameterValue FROM g2_PluginParameterMap WHERE g2_PluginParameterMap.g_pluginType = 'module' AND g2_PluginParameterMap.g_pluginId = 'rewrite' AND g2_PluginParameterMap.g_itemId = 0

(mysqlt): update g2_SequenceEventLog set id=LAST_INSERT_ID(id+1);

realpath(/home/hellokat/public_html/adam/gallery/modules/core/classes/../../../) realpath(/home/hellokat/public_html/adam/gallery/) Error (GALLERY_ERROR)

in modules/core/classes/Gallery.class at line 242 (gallerycoreapi::error)
in modules/core/classes/helpers/GalleryEventLogHelper_medium.class at line 62 (gallery::getactiveuserid)
in modules/core/classes/GalleryCoreApi.class at line 3213 (galleryeventloghelper_medium::addeventlogentry)
in main.php at line 720 (gallerycoreapi::addeventlogentry)
in ??? at line 0
in lib/adodb/adodb.inc.php at line 3129
in modules/core/classes/GalleryStorage.class at line 1501 (adorecordset_mysqlt::fetchrow)
in modules/core/classes/helpers/GalleryPluginHelper_simple.class at line 322 (gallerysearchresults::nextresult)
in modules/core/classes/helpers/GalleryPluginHelper_simple.class at line 222 (gallerypluginhelper_simple::_fetchallparameters)
in modules/core/classes/GalleryCoreApi.class at line 248 (gallerypluginhelper_simple::getparameter)
in modules/rewrite/classes/parsers/modrewrite/ModRewriteUrlGenerator.class at line 40 (gallerycoreapi::getpluginparameter)
in init.inc at line 108 (modrewriteurlgenerator::init)
in main.php at line 89

Fatal error: Call to a member function on a non-object in /home/hellokat/public_html/adam/gallery/modules/core/classes/Gallery.class on line 244

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2007-09-03 12:42

Ok, that's revealing, thanks!

so there's some database related error which triggers the error handling and because the error is very early in the bootstrapping process, the error handler fails too.
i've reopened a bug about the error handling.

for your case, let's focus on why the initial error happens.

please edit main.php

around line 716, find:

    GalleryCoreApi::addEventLogEntry(
	'PHP Error',
	sprintf("[%s] %s in file %s on line %d", $errorType[$errorNumber],
		$errorString, $file, $line),
	$errorString);

replace with:


    printf("PHP Error: [%s] %s in file %s on line %d", $errorType[$errorNumber],
		$errorString, $file, $line);
    GalleryCoreApi::addEventLogEntry(
	'PHP Error',
	sprintf("[%s] %s in file %s on line %d", $errorType[$errorNumber],
		$errorString, $file, $line),
	$errorString);

i guess something's wrong with your database. i guess we'll know more once we see this error-string.
it wouldn't hurt to check the status of your database tables though.

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
ablauer

Joined: 2007-08-26
Posts: 39
Posted: Mon, 2007-09-03 17:44

Okay, after changing those lines, it seems the only thing that changed was that the bolded line below was added. I know that has to do with the PHP accelerator which I don't think I can disable, and I had thought it doesn't really affect anything:

file_exists(/home/hellokat/public_html/adam/gallery/g2data/cache/module/_all/0/0/GalleryFactoryHelper_loadRegistry.inc) file_exists(/home/hellokat/public_html/adam/gallery/modules/rewrite/classes/parsers/modrewrite/ModRewriteUrlGenerator.class) getParameter modrewrite.galleryLocation for rewrite plugin file_exists(/home/hellokat/public_html/adam/gallery/g2data/cache/module/rewrite/0/0/0.inc)

(mysqlt): SELECT g2_PluginParameterMap.g_itemId, g2_PluginParameterMap.g_parameterName, g2_PluginParameterMap.g_parameterValue FROM g2_PluginParameterMap WHERE g2_PluginParameterMap.g_pluginType = 'module' AND g2_PluginParameterMap.g_pluginId = 'rewrite' AND g2_PluginParameterMap.g_itemId = 0

PHP Error: [Notice] Only variable references should be returned by reference in file /home/hellokat/public_html/adam/gallery/lib/adodb/adodb.inc.php on line 3129

(mysqlt): update g2_SequenceEventLog set id=LAST_INSERT_ID(id+1);

realpath(/home/hellokat/public_html/adam/gallery/modules/core/classes/../../../) realpath(/home/hellokat/public_html/adam/gallery/) Error (GALLERY_ERROR)
in modules/core/classes/Gallery.class at line 242 (gallerycoreapi::error)
in modules/core/classes/helpers/GalleryEventLogHelper_medium.class at line 62 (gallery::getactiveuserid)
in modules/core/classes/GalleryCoreApi.class at line 3213 (galleryeventloghelper_medium::addeventlogentry)
in main.php at line 722 (gallerycoreapi::addeventlogentry)
in ??? at line 0
in lib/adodb/adodb.inc.php at line 3129
in modules/core/classes/GalleryStorage.class at line 1501 (adorecordset_mysqlt::fetchrow)
in modules/core/classes/helpers/GalleryPluginHelper_simple.class at line 322 (gallerysearchresults::nextresult)
in modules/core/classes/helpers/GalleryPluginHelper_simple.class at line 222 (gallerypluginhelper_simple::_fetchallparameters)
in modules/core/classes/GalleryCoreApi.class at line 248 (gallerypluginhelper_simple::getparameter)
in modules/rewrite/classes/parsers/modrewrite/ModRewriteUrlGenerator.class at line 40 (gallerycoreapi::getpluginparameter)
in init.inc at line 108 (modrewriteurlgenerator::init)
in main.php at line 89

Fatal error: Call to a member function on a non-object in /home/hellokat/public_html/adam/gallery/modules/core/classes/Gallery.class on line 244

If I try to go to /lib/support, the end of the error message is this:
file_exists(/home/hellokat/public_html/adam/gallery/g2data/cache/module/_all/0/0/GalleryFactoryHelper_loadRegistry.inc) file_exists(/home/hellokat/public_html/adam/gallery/modules/rewrite/classes/parsers/modrewrite/ModRewriteUrlGenerator.class) getParameter modrewrite.embeddedLocation for rewrite plugin file_exists(/home/hellokat/public_html/adam/gallery/g2data/cache/module/rewrite/0/0/0.inc)

(mysqlt): SELECT g2_PluginParameterMap.g_itemId, g2_PluginParameterMap.g_parameterName, g2_PluginParameterMap.g_parameterValue FROM g2_PluginParameterMap WHERE g2_PluginParameterMap.g_pluginType = 'module' AND g2_PluginParameterMap.g_pluginId = 'rewrite' AND g2_PluginParameterMap.g_itemId = 0

PHP Error: [Notice] Only variable references should be returned by reference in file /home/hellokat/public_html/adam/gallery/lib/adodb/adodb.inc.php on line 3129

(mysqlt): update g2_SequenceEventLog set id=LAST_INSERT_ID(id+1);

realpath(/home/hellokat/public_html/adam/gallery/modules/core/classes/../../../) realpath(/home/hellokat/public_html/adam/gallery/) Error (GALLERY_ERROR)
in modules/core/classes/Gallery.class at line 242 (gallerycoreapi::error)
in modules/core/classes/helpers/GalleryEventLogHelper_medium.class at line 62 (gallery::getactiveuserid)
in modules/core/classes/GalleryCoreApi.class at line 3213 (galleryeventloghelper_medium::addeventlogentry)
in main.php at line 722 (gallerycoreapi::addeventlogentry)
in ??? at line 0
in lib/adodb/adodb.inc.php at line 3129
in modules/core/classes/GalleryStorage.class at line 1501 (adorecordset_mysqlt::fetchrow)
in modules/core/classes/helpers/GalleryPluginHelper_simple.class at line 322 (gallerysearchresults::nextresult)
in modules/core/classes/helpers/GalleryPluginHelper_simple.class at line 222 (gallerypluginhelper_simple::_fetchallparameters)
in modules/core/classes/GalleryCoreApi.class at line 248 (gallerypluginhelper_simple::getparameter)
in modules/rewrite/classes/parsers/modrewrite/ModRewriteUrlGenerator.class at line 40 (gallerycoreapi::getpluginparameter)
in init.inc at line 108 (modrewriteurlgenerator::init)
in modules/core/classes/GalleryEmbed.class at line 100
in lib/support/GallerySetupUtilities.class at line 113 (galleryembed::init)
in lib/support/security.inc at line 56 (gallerysetuputilities::getloginattempts)
in lib/support/index.php at line 3

Fatal error: Call to a member function on a non-object in /home/hellokat/public_html/adam/gallery/modules/core/classes/Gallery.class on line 244

I ran "check tables" on the database from myPHPadmin and everything turned up saying "OK" except for these two messages:
Problems with indexes of table `g2_AccessMap`
PRIMARY and INDEX keys should not both be set for column `g_accessListId`

Problems with indexes of table `g2_PluginParameterMap`
UNIQUE and INDEX keys should not both be set for column `g_pluginType`
More than one INDEX key was created for column `g_pluginType`

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2007-09-03 19:17

> Zend Optimizer v2.5.10,

see:
FAQ: I get "Notice: Only variable references should be returned by reference in ", what's wrong?

please ask your webhost to fix their buggy php installation.
all they need to do is update their buggy, old version of Zend Optimizer. Which is free.

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
ablauer

Joined: 2007-08-26
Posts: 39
Posted: Tue, 2007-09-04 01:08

Thanks...
I called garbagelogic and they said that because I'm on a shared server, they will not update the Zend Optimizer. They also said they plan to upgrade to PHP5 at some point but weren't sure when. I think I should be looking for some new web hosting...

The tech said that I can modify my php.ini by way of a .htaccess file in my main directory, but said he could not tell me how. I searched online and tried this through my command line but it kept coming back with invalid command when I tried to execute the script:
http://drupal.org/node/113220

Also, the .htaccess in my /gallery folder shows this:

# BEGIN Url Rewrite section
# (Automatically generated. Do not edit this section)
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /gallery/

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
RewriteCond %{REQUEST_URI} !/gallery/main\.php$
RewriteRule . - [L]

RewriteCond %{THE_REQUEST} /gallery/d/([0-9]+)-([0-9]+)/([^/?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/gallery/main\.php$
RewriteRule . /gallery/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3 [QSA,L]
RewriteCond %{THE_REQUEST} /gallery/v/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/gallery/main\.php$
RewriteRule . /gallery/main.php?g2_path=%1 [QSA,L]
</IfModule>

# END Url Rewrite section

Deleting the file does nothing to solve the problem. I tried adding this to my .htaccess file in /gallery, as well as creating a .htaccess file in /public_html with just this info:
<IfModule mod_php4.c>
php_value zend_optimizer.optimization_level 14
</IfModule>
# PHP 4, Apache 2
<IfModule sapi_apache2.c>
php_value zend_optimizer.optimization_level 14
</IfModule>
# PHP 5, Apache 1 and 2
<IfModule mod_php5.c>
php_value zend_optimizer.optimization_level 14
</IfModule>

That didn't change anything either...

This probably doesn't mean anything...but I can't connect to the gallery using Gallery Remote either.
It says:
Error: Server contacted, but gallery not found at this address.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2007-09-04 10:15

> I called garbagelogic and they said that because I'm on a shared server, they will not update the Zend Optimizer.

that's a lousy excuse from them. they've got a buggy php installation and won't do anything about it. how much sense does that make?

please ask them to be more specific about the .htaccess approach to override php.ini.

@.htaccess:
please leave the <IfModule ...> stuff away and just add this single line to your .htaccess in the g2 folder:
php_value zend_optimizer.optimization_level 0
and put a phpinfo.php page into your gallery2 folder too to see if the changes take effect.
phpinfo is explained here: FAQ: What information is required when I ask for help in the forums?

@Gallery remote:
sure doesn't work since all GR is doing is the same as your browser. it requests main.php which doesn't work.

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
ablauer

Joined: 2007-08-26
Posts: 39
Posted: Tue, 2007-09-04 17:32

I added that line before the Mod_rewrite.c module and it doesn't look like it affected anything. http://adamblauer.com/gallery/phpinfo.php shows:
Zend Optimizer

Optimization Pass 1 enabled
Optimization Pass 2 enabled
Optimization Pass 3 enabled
Optimization Pass 4 enabled
Optimization Pass 9 disabled
Zend Loader enabled
License Path no value

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2007-09-04 17:44

right. ok, please ask your webhost.

> please ask them to be more specific about the .htaccess approach to override php.ini.

 
spi245

Joined: 2010-10-22
Posts: 1
Posted: Fri, 2010-10-22 18:41

hi... im getting an error in the line
$infinite_key_array = $facebook->api_client->auth_getSession("auth_token");
after passing the 5 token key..
I am getting this error
Fatal error: Call to a member function auth_getSession() on a non-object in D:\xampp\htdocs\test.php on line 9
Can someone help me with this