PHP Fatal-Error: Call to a member function append_output() - php

I use codeigniter in my blog and since a while I get this error
PHP Fatal error: Call to a member function append_output() on a non-object in /var/www/site/blog/system/core/Loader.php on line 862
I don't know what change caused this and why it appears. The site gets rendered and send to browser completely, from views header.php, index.php to footer.php everything is there and after that this error appears. Search with google showed another site, that has this error at the very bottom of their site...
I now supressed the error with error_reporting(0) as the whole site works fine, but that's not a solution I want to stay with.
It happens on all pages, I have one Controler (blog.php) and several methods like index(), article(), archive() in it. The methods do what they are supposed to do, but when CI finished rendering the page, the error appears, with all controler methods.
What can I do to trace where this problem appears?

https://github.com/EllisLab/CodeIgniter/blob/develop/system/core/Loader.php#L938
If the error is occurring on the value returned from get_instance, here will be your problem. Although you may have to look at the version you are using to get the right line number.
Additionally:
https://github.com/EllisLab/CodeIgniter/blob/develop/system/core/Controller.php#L75
This appears to be the singleton class that function leads to, it is returning self::$instance which is created in the constructor.
To me this means the CI_Controller singleton has not been instantiated at the time that error has occurred.
Hope that helps you debug your problem.

I had the same problem. I'd overwritten the output class ($this->output) in my controller.

Related

How is it possible for the application to throw a redeclaration error on deleted and unexisting function?

I declared getLesediSimilarPropertyOnShow() function. When I run the application, I get this error below:
Fatal error: Cannot redeclare
GautengPropertyDB::getLesediSimilarPropertyOnShow() in
C:\xampp\htdocs\workspace\ajax-live-search\libs\GautengPropertyDB.php on line 4704
I deleted this entire function thinking about the duplication.
But when I tried to check if the function getLesediSimilarPropertyOnShow() exists by pressing CTRL+F, The Find and Replace Dialog Box displays Not Found in the current document. Meaning the function does not exist. But when I tried to reload the page, the same message persits and the line 4704 is located on comment lines outside of all functions that has nothing to do with the code. I thought may be it was previous error loaded in the cache memory and I cleaned the cache but the same error stands still. But the function does not exist in the file. I don't understand this phenomenon. Can someone please explain this?
At first use IDE like PHPStorm, that show for you where function declared.
Use http://php.net/manual/en/function.function-exists.php for check if function already declared

Can't load main website or the Magento /admin page. Just loads as a blank page! Error log provided

Our site has been down since I tried doing a backup of our Magento site. This was the last thing I did that could have triggered something. I had made other changes throughout the day, but only playing with some extensions, and this was a couple hours prior to the error. Below is the last entry to the error log:
[16-Jun-2015 18:42:56 UTC] PHP Fatal error: Call to a member function
setLayer() on a non-object in
**public_html/app/code/core/Mage/Catalog/Block/Layer/View.php on line 134
Got into the line its calling to but have no idea what to do with it! Not even sure if this is the direct cause of this issue. I feel something should still load.
Could it be something simple I'm missing like a Maintenance flag?
Any other reasons why the site could be behaving like this? Quite frustrating that I cant even reach the admin page. All our other subdomain site work too.
It would appear to me that somewhere in your coding of some extensions you broke something. This error happens when you have what you think is an object but is actually not and you call a method on it.
for instance if you have something like the following
<?php
$obj = function_to_get_object('name');
$obj->getName();
if the function_to_get_object does not return an object but rather returns NULL or false then calling the method getName will fail because the variable is not an object rather NULL or FALSE.
I could not see this happening with a Magento install (without custom code) unless maybe you deleted a file or something and the base install cannot find the file to include or instantiate the object.

Jomsocial error - Notice: JFactory::getUser(): The script tried to execute a method or access a property of an incomplete object

Im getting 2 errors. I saw that Jomsocial had the problem with their own site and fixed it but never posted how. Happens when you go to post an update in jomsocial and it locks up. You refresh the page and get
Error
Sorry, User ID not found.
with the following errors. Then you go login and check the profile and the update was posted fine.
Notice: JFactory::getUser(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "CUser" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in /home/xxxxxxx/public_html/libraries/joomla/factory.php on line 244
Notice: CUser::CUser(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "CUser" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in /home/xxxxxx/public_html/components/com_community/libraries/user.php on line 52
What version of JomSocial do you use? This issue shouldn't happen

PHP-Yii: Using Yiis logger when a request is not completed due to php level error

This is probably a yii specific question, even though I wouldn't surprised if experienced non-Yii we developers will be also able to contribute.
I often encounter the following situation:
My application fails due to a fatal error on the php level. Something like $var->property when $var==null
I want to understand how $var came to be ==null.
I'd use logs for this, however, problem is that no logs are left when a request is ended due to php error.
edit: this only happens for fatal errors. For other php errors I have my logs back
An example:
For
$nonExistingVar->someProperty;
I do have my logs recorded, as it yields PHP Error Undefined variable: nonExistingVar
However, if I do define the variable and set it to null,
$tmp = null;
$tmp->prop;
Then I loose the logs, as it results in "Fatal error: Call to a member function hasErrors() on a non-object"
Does anybody understand why does it happen? And how can the logger be anyway used in this situations? I tried setting autoFlush=1, doesn't help
Thanks
Gidi
The below allowed me to have my logs even on fatal errors:
function yiiCorrectShutdown()
{
Yii::app()->end();
//the following line will work as well
//Yii::app()->log->processLogs(null);
}
register_shutdown_function('yiiCorrectShutdown');
I wrote an extension class that logs in real-time thus avoiding any need to modify flow paths. I posted it here on the Yii Wiki

Go around cannot redeclare error in PHP

I am trying to integrate WordPress and MyBB forums. Specifically, I just want to add WordPress's navbar (the new menu) to my MyBB website. Following the CODEX example, I've added the following to my header.php of my MyBB installation:
require('/home/linuxdis/public_html/wp-blog-header.php');
However, I get 500 error when navigating to the forum. Examining error_log revealed this:
PHP Fatal error: Cannot redeclare is_super_admin() (previously declared in /home/linuxdis/public_html/forum/inc/functions.php:5484) in /home/linuxdis/public_html/wp-includes/capabilities.php on line 1213
Bummer, the functions are named the same. Other than renaming one of the functions and probably breaking absolutely everything, is there a way to go around this? :/
User require_once() instead of require() and it will make sure it will only include that file once per page.
Although not ideal in this case, you could wrap each function in a function_exists() check:
if(!function_exists('myfunc') {
function myfunc() {....}
}
This might be your only option if there are direct clashes with WP/MyBB, you're stuck if they both need is_super_admin() though.

Categories