pyrocms theme error drivers/Session_cookie.php - php

I'm new to PyroCMS and I'm currently working on a news website which requires the blog functionality. In order not to have my urls displaying "blog" I duplicated the blog module and renamed it "posts" which worked fine.
But now when I view a post I get the following error at the top of the page:
"A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/newerawe/public_html/addons/default/themes/era/theme.php:1)
Filename: drivers/Session_cookie.php
Line Number: 701"

Because you didn't mention the most crucial information of all, what php and pyro version you are using .. i have to assume you are using PHP 5.4 the PyroCMS 2.2.
There is something sent before a header, PyroCMS had some problems with this kind of stuff, because PHP has gotten a bit more strict and is throwing several warnings if for example you are trying to create a variable out of thin air:
This will issues an warning saying that $text hasn't been defined, and that happens before the headers, which causes the problem.
// Warning: "Creating default object from empty value" errors
$text->string = 'My text is fine';
You nead you need to either find and fix the problems, which is a long shot:
$text = new stdClass();
$text->string = 'My text is fine';
or try exclude E_WARNING from error_reporting, and you should be fine.
error_reporting(E_ERROR | E_PARSE | E_NOTICE);
Hope that it helps!

Related

Suppress warnings in mediawiki

Is there any way to suppress deprication warnings in mediawiki?
For e.g. I am getting this message at the top of some of the pages on my personal wiki site.
Deprecated: Use of MWNamespace::getSubject was deprecated in MediaWiki 1.34. [Called from Scribunto_LuaSiteLibrary::register in /var/www/html/w/extensions/Scribunto/includes/engines/LuaCommon/SiteLibrary.php at line 58] in /var/www/html/w/includes/debug/MWDebug.php on line 375
You can see an example here...
http://training.shantanuoak.com:8080/wiki/%E0%A4%AE%E0%A4%BE%E0%A4%B0%E0%A5%8D%E0%A4%95_%E0%A4%AC%E0%A5%87%E0%A4%A8%E0%A5%8D%E0%A4%B8%E0%A4%A8
I am not sure if this is php issue or mediawiki problem.
At the bottom of LocalSettings.php:
$wgShowDebug = false;
$wgDevelopmentWarnings = false;
If you want to keep debug messages around, just not the deprecation ones:
$wgDeprecationReleaseLimit = '1.0';
Also, upgrading MediaWiki and extensions helps with problems sometimesšŸ˜ƒ

Wordpress - The7 Template - On every page I have 4 Warnings and do not know how to disable it in menu or php site/content

I have a problem with my Wordpress site, more specifically, The7 template. On every page, including the main page at the bottom of page below footer I have 4 Warnings which are the same:
ā€œWarning: call_user_func_array() expects parameter 1 to be a valid callback, function ā€˜wp_filter_content_tagsā€™ not found or invalid function name in on lineā€
I do not know how to solve it/turn it off. Could you tell me which PHP page or what exactly cause this problem to appear? Itā€™s really annoying. Due to the fact that it is in the main body and not in any div/b/p/etc. tag I cannot hide it with CSS just for a while.
Kind regards
Peter
Hiding error reporting on prod
On prod you want to avoid showing errors, due to security and user experience reasons. To achieve this, in PHP you can run
error_reporting(0);
or, even better, in php.ini, you can have this line
error_reporting = off
What the error means
The error tells you that a function is to be called by name, but it does not exist. wp_filter_content_tags does not exist in your context.
Solution to the error
Even though you have hidden error reporting on prod, you still need to show errors on dev and that function might do something very useful. From the doc you can see that it's located in wp-includes/media.php. So, if you do not need to call this function, then search for its calls and remove them. If you need this function, then require or include it into your files. If, for some reason you cannot remove this function (for ex. you do not want to hack a template that might have some versions in the future), but the function/file is not helpful for you, then you can implement a function with the same name.
Thank you very much for answer. I used it to find solution and in my case there is a need to change wp-config.php a little bit. It means to add these specific lines to code:
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false)
In my case it worked and no more errors / warnings showed on every / main pages.
Kind Regards
Peter

Notice: Trying to get property of non-object in ../libraries/src/UCM/UCMType.php on line 169

When I tried to install the Joomla! extension JCH, I came up with the title message above after finished installing.
I asked the developer and he replied that I don't have to worry about the extension as this is a Joomla! issue that it will not affect the way the extension works.
The line 169 of UCMType.php is the following:
$tableNameFromType = $tableFromType->special->prefix . $tableFromType->special->type;
And the specific part of the UCMType.php that includes line 169:
public function getTypeByTable($tableName)
{
$query = $this->db->getQuery(true);
$query->select('ct.*');
$query->from($this->db->quoteName('#__content_types', 'ct'));
// $query->where($this->db->quoteName('ct.type_alias') . ' = ' . (int) $typeAlias);
$this->db->setQuery($query);
$types = $this->db->loadObjectList();
foreach ($types as $type)
{
$tableFromType = json_decode($type->table);
$tableNameFromType = $tableFromType->special->prefix . $tableFromType->special->type;
if ($tableNameFromType === $tableName)
{
return $type;
}
}
return false;
}
You really do not have to give too much attention for this issue, so the third party extension developer was right in this. This is more like a small bug (thus the Notice is there), not a serious Error. Your site will operate without a problem.
As you see in this Notice, in the foreach(){} loop a variable is tried to be defined from another variable which is not an Object, so it is just getting back a NULL value or another TYPE most probably, which does not have an Object property what is expected there.
In this particular case this whole thing happens in a relatively new Joomla core class and interface (UCM and UCMType). In this class they want to define a content type by table and this part of the code has to be modified, improved by core Joomla developers.
What should you do?
1. If you want to help the development of Joomla and yourself a bit then please report this issue here: https://developer.joomla.org/tracker.html , and they will check and repair this most probably.
2. This PHP (error) Notice is usually for developers, so if your site is a live site you should not see this Notice basically. If you see this on live site, that could mean that either your Joomla error reporting is set incorrectly, or your server error reporting default is set incorrectly.
In your Joomla admin at System->Global Configuration->Server->Error reporting has to be set to System Default or to None. Thus these not relevant notices will not appear for users, visitors of your site. Other settings only recommended if your site is not a live site and you develop that further in a staging copy for example.
And please if you have Joomla questions, visit the Joomla Stack Exchange here: https://joomla.stackexchange.com/questions and please ask your questions regarding Joomla there.
I hope the above cleared the issue for you.

Find the root cause of already sent headers in php when entire class is referenced

fellow members and visitors.
Please imbue me of your knowledge and allow me to be enlightened by your expertise by answering this question or providing me a path of exploration.
My simple mind cannot has exhausted the possibilities it was aware and would really like to begin to understand what to do in such a situation should it arise again.
Everything begins with a :
Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at
/path/to/site/wp-content/themes/theme_name/inc/general/class-Upbootwp_Walker_Nav_Menu.php:125)
in
/path/to/site/wp-content/plugins/wp-php-console/includes/class-wp-php-console.php
on line 142
Here is the exact ubootwp_Walker_Nav_menu.php class for reference.
I am used to having a precise line number in these kind of error but this time, I get no such indicator (I just get the last line, but there's nothing there except the end of the class.
From my understanding, something in that class instantiate a session and when the Worpdress php console plugin try to do it, it crashes as headers were already sent by that class.
I did add the following
error_reporting(E_ALL);
ini_set('display_errors', 'On');
to get the error statement, as I would previously only get a 'error 500'.
I cannot see anything wrong with that class (no obvious echo, print, ob_start).
Does some of you have any clue on how I would go in trying to find the root cause of it ?
Any insight will be appreciated.
edit:
ubootwp_Walker_Nav_menu.php is a UTF-8 file (No BOM)
No hidden characters or anything before php opening tag.
No php closing tag at the end of the file
No echo,ob_start,print or anything obvious that I can see that would initiate a session.
Thoughts:
The error message explicitly states that the error occurs in the php console plugin (which effectively wants to start a session) because the ubootwp_Walker_Nav_menu.php has created the session. Is it possible that the error message is not accurate or does that unequivocaly means that this class is the error ?
Edit 2:
Actually, I thought it was not relevant but I had another notice before the header sent which was:
Strict Standards: Declaration of Upbootwp_Walker_Nav_Menu::start_lvl() should be compatible with Walker_Nav_Menu::start_lvl(&$output, $depth = 0, $args = Array) in /home3/i8h1o2r7/public_html/dev/wp-content/themes/axial/inc/general/class-Upbootwp_Walker_Nav_Menu.php on line 130
This was very relevant to the problem as this was the cause of the "header sent". I fixed the declaration from the class which was not causing an issue before and it fixed the PHP console plugin "session already created" issue from the initial message.
The session has to start before ANY html has been sent to the browser. You can turn on output buffering but, it's going to cause problems if run on a server without output buffering enabled ... Doesn't WP start a session anyway?
I found the solution to this problem from Magnus comment reference to another similar question. In my particular case, the header were sent by another notice that was caused by a signature mismatch and outputting headers early.
Strict Standards: Declaration of Upbootwp_Walker_Nav_Menu::start_lvl()
should be compatible with Walker_Nav_Menu::start_lvl(&$output, $depth
= 0, $args = Array) in /home3/i8h1o2r7/public_html/dev/wp-content/themes/axial/inc/general/class-Upbootwp_Walker_Nav_Menu.php
on line 130
Once that specific error was fixed, headers were not outputted anymore and the second error (initial question) vanished completely.

error in /modules/mod_feed/helper.php

I am getting a warning after PHP update
Warning: Creating default object from empty value in /modules/mod_feed/helper.php on line 42
I had faced this issue before and at that time I have used $v=new stdclass();. But the issue was not in a Joomla site. Now the same issue with a joomla site. My code link is here
What I should change in this file? Any thoughts?
You also need
$feed->image = new stdclass;
before line 42. This is an E_STRICT level warning. These are designed to alert you to code smells (like auto-creating arrays / objects).

Categories