Undefined index: recentBlogs error

Undefined index: recentBlogs error

Postby knkk on Mon Oct 18, 2010 2:47 am

I recently upgraded to MySLQ 5.1.51 and PHP 5.3. Ever since, I am seeing this error:

Undefined index: recentBlogs in /blogs/tmp/summary/%%FD^FD8^FD8C114A%%index.template.php on line 141

The page is:

http://www.fullhyderabad.com/blogs/

Can someone kindly help? I cleaned cache, checked that error_reporting was set to 0. Thank you,
London, New York, Chicago local guides
knkk
 
Posts: 104
Joined: Fri Oct 26, 2007 6:16 am
LifeType Version: 1.2.5

Re: Undefined index: recentBlogs error

Postby raciloni on Mon Oct 18, 2010 8:57 am

The reason you get this error message is that you made a modification in the index.template :
<!-- if $recentBlogs BELOW MOVED UP BY FULLHYD.COM FROM AFTER </h2> -->

the problem is that $recentBlogs variable isn't declared when you call it in if statment.
Code: Select all
 
   <!-- if $recentBlogs BELOW MOVED UP BY FULLHYD.COM FROM AFTER </h2> -->
    {if $recentBlogs} // $recentBlogs is not yet declared
        {assign var=recentBlogs value=$summaryStats->getRecentBlogs()} //it's declared here
    <h2>{$locale->tr("summary_newest_blogs")}
      <a href="{$url->getRssUrl()}?summary=1&amp;type=newestblogs">
        <img src="{$url->getUrl("/imgs/rss_logo_mini.gif")}"
           alt="RSS" /></a>   
    </h2>
     
      <ul class="itemList" style="margin: 0 0 0 1em; padding: 0">
        {foreach from=$recentBlogs item=blog}
          {assign var="url" value=$blog->getBlogRequestGenerator()}
        {** remove this if you're having problems with blogs in encondings other than iso-8859-1 **}
          <li class="item"><a href="http://{$blog->getFullhydSubDomain()}.fullhydblogs.com/">{$blog->getBlog()|strip_tags|truncate:60}</a></li>
        {/foreach}
      </ul>
    {/if}


to fix the problem just replace the code you modified by the orginal :

Code: Select all
 
        {assign var=recentBlogs value=$summaryStats->getRecentBlogs()}
    <h2>{$locale->tr("summary_newest_blogs")}
      <a href="{$url->getRssUrl()}?summary=1&amp;type=newestblogs">
        <img src="{$url->getUrl("/imgs/rss_logo_mini.gif")}"
           alt="RSS" /></a>   
    </h2>
         {if $recentBlogs}
      <ul class="itemList" style="margin: 0 0 0 1em; padding: 0">
        {foreach from=$recentBlogs item=blog}
          {assign var="url" value=$blog->getBlogRequestGenerator()}
        {** remove this if you're having problems with blogs in encondings other than iso-8859-1 **}
          <li class="item"><a href="http://{$blog->getFullhydSubDomain()}.fullhydblogs.com/">{$blog->getBlog()|strip_tags|truncate:60}</a></li>
        {/foreach}
      </ul>
    {/if}


(sorry for my bad english)
raciloni
 
Posts: 7
Joined: Sun Dec 13, 2009 3:22 pm
LifeType Version: lifetype-1.2.11_r711

Re: Undefined index: recentBlogs error

Postby knkk on Mon Oct 18, 2010 10:24 am

Thanks, raciloni - that was intelligent. The issue however is still that (1) it is just a notice, and I would not like notices appearing, and (2) this was all working fine for 2 years until last week I upgraded to PHP5 and MySQL5 as I mentioned above. There should be some error notification setting somewhere - am I missing it?

In the meantime, I just thought I'll share something. I figured out that I needed to do this to get rid of a clutch of those "notice" errors in the control panel (admin area).

Code: Select all
        function _nodePath( $node, $nodeId, $stack = Array())
        {
            error_reporting(0); //LINE ADDED AFTER UPGRADE TO PHP 5.3
            //print("node = $node->name<br/>");
            if( $node->name == $nodeId ) {


That is in the file class/template/menu/menu.class.php, around line 100.
London, New York, Chicago local guides
knkk
 
Posts: 104
Joined: Fri Oct 26, 2007 6:16 am
LifeType Version: 1.2.5

Re: Undefined index: recentBlogs error

Postby jondaley on Mon Oct 18, 2010 10:47 am

I agree that it is good to get rid of all PHP Notices (and I'd even like it to not have any E_STRICT warnings either, if at all possible). The trouble with the 1.2.x releases is that we are still supporting PHP4, and that makes it quite tricky (or actually, impossible) to remove all of them. The 2.0 release is way overdue, but we are lacking on development time, so it will be a while yet. I do make some money from LifeType, but not enough to put a whole lot of time into it.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: Undefined index: recentBlogs error

Postby knkk on Tue Oct 19, 2010 12:15 am

Thank you, Jon. I also get the following line a huge number of times at the top when I try to disable a blog:

Warning: get_class() expects parameter 1 to be object, string given in /home/fullhyd/fullhyd.com/fullhyd/blogs/class/dao/model.class.php on line 396

Would you know what to do about it?
London, New York, Chicago local guides
knkk
 
Posts: 104
Joined: Fri Oct 26, 2007 6:16 am
LifeType Version: 1.2.5

Re: Undefined index: recentBlogs error

Postby jondaley on Tue Oct 19, 2010 7:31 am

Yes, I think that one I looked up recently, and I think for now you can just add an @ before "get_class", and you'll be okay for now. Versions of PHP prior to 5.3 allowed a string to be used.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: Undefined index: recentBlogs error

Postby knkk on Wed Oct 20, 2010 8:36 am

Thanks, Jon. That worked.

However, I am simply unable to get rid of the Notice errors on the page that I mentioned in my first post on this thread (the summary page). No matter where I put error_reporting(0), that message will not go away. I even went deep inside smarty functions.

And new blogs creations are also getting affected - an "Undefined index..." string is getting added to the title of any new blog.

Can you give me any pointers? This is kinda important since my site is live. Thank you.
London, New York, Chicago local guides
knkk
 
Posts: 104
Joined: Fri Oct 26, 2007 6:16 am
LifeType Version: 1.2.5

Re: Undefined index: recentBlogs error

Postby knkk on Wed Oct 20, 2010 10:57 am

Guess I've tried everything (over some 2 man-days now). Even changed the error_reporting settings in php.ini to 0. Nothing works. Hurts to have taken so much time to fix something and failed completely :).

What I've noticed is that in the tmp folder, a file looking like tmp/summary/%%FD^FD8^FD8C114A%%index.template.php gets created (template compiling by smarty), and I'm guessing smarty executes this file as a PHP script to create another file named something like 72dad900033cf1b286335f1fad0601e0^%%FD^FD8^FD8C114A%%index.template.

So when tmp/summary/%%FD^FD8^FD8C114A%%index.template.php is included in some script and executed as a PHP file, the error_reporting seems to cause creation of a notice error.

Hoping Jon or one of the other brains here can do something. Thank you,
London, New York, Chicago local guides
knkk
 
Posts: 104
Joined: Fri Oct 26, 2007 6:16 am
LifeType Version: 1.2.5

Re: Undefined index: recentBlogs error

Postby jondaley on Wed Oct 20, 2010 11:12 am

Your guesses are correct about the funny-named files in tmp.

It is weird that you can't disable the errors in php.ini. There must be something overriding it somewhere - perhaps an additional conf.d directory (I use Debian, and so I don't ever modify php.ini directly, but simply put files in /etc/php5/conf.d/ and those settings override the php.ini settings.

How about a setting in .htaccess? LifeType doesn't ship with an error_reporting command, but maybe you were debugging something at some point and turned it on?

Maybe your host could help you get the error reporting turned completely off.

Did you add the @ to the get_class call?

I do now have some servers running 5.3 myself (though I also just noticed the security issues in 5.3 less than 5.3.3, so I'm not sure it is really ready for prime time yet), so I will try out lifetype 1.2.x on php 5.3.2 in the next week or so, and see if I can duplicate any of your troubles.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: Undefined index: recentBlogs error

Postby knkk on Thu Oct 21, 2010 12:58 am

I did add the @ to the get_class call, and it worked. Thanks for that.

As for the notice problem, after setting error_reporting to 0, I kept printing its value at various places across the path that the script was following to execute - starting from summary.php, going through controller.class.php, summaryaction.class.php, summarydefaultaction.class.php, summarycachedview.class.php etc., right down to the smarty file core.read_cache_file.php. it prints 0 *everywhere*, but still the notices finally show up (and like I said, I was cleaning up the cache every time).

But maybe I haven't gotten right down to the actual trouble spot. It would help if you could tell me where exactly which segment of the code actually is printing that notice - I could print the value of error_reporting there and see where it is getting reset and why. I could start the debugging from there.

Yes, I would be quite glad if you could test this yourself once (as soon as you get time), since my guess is more people would by now have PHP5 rather than PHP4 installed. Thank you for your time.
London, New York, Chicago local guides
knkk
 
Posts: 104
Joined: Fri Oct 26, 2007 6:16 am
LifeType Version: 1.2.5

Re: Undefined index: recentBlogs error

Postby jondaley on Thu Oct 21, 2010 10:36 am

The issue isn't php5, but php5.3. I run lifetype 5.2.6 for my own blog and everything is fine. 5.3 was a significant upgrade.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: Undefined index: recentBlogs error

Postby knkk on Thu Oct 21, 2010 11:29 am

In the file class/summary/view/summarycachedview.class.php, in function sendUncachedOutput(), the last line "print $this->_template->fetch( $this->_viewId );" is where the files in the tmp folder are getting created.

That line calls the function fetch() in class/template/cachedtemplate.class.php, which is:

Code: Select all
        function fetch( $cacheId )
        {
           return Smarty::fetch( $this->getTemplateFile(), $cacheId );
        }


which is just calls smarty thereon.

I am adding a line error_reporting(0) just before that "return Smarty::fetch..." line, but am still unable to get rid of the notice error.

After that, it is just entering smarty code. In any case, I added a line error_reporting(0); to the beginning of the smarty.class.php fetch function anyway, but the notice error still persists.
London, New York, Chicago local guides
knkk
 
Posts: 104
Joined: Fri Oct 26, 2007 6:16 am
LifeType Version: 1.2.5

Re: Undefined index: recentBlogs error

Postby jondaley on Fri Oct 22, 2010 2:39 pm

I don't think you need to try adding that call to error_reporting all over the place. Just once is sufficient.
Maybe your host doesn't allow you to call that function? Though I'd expect it to generate an error in that case.

You don't have smarty debugging turned on in class/template/smarty/Smarty.class.php do you?

Actually - what files have you modified? You can see that if you go to administration->miscellaneous->versions->file check

If your host enables this feature you could put: ini_set('display_errors', 0); in index.php (I assume we are talking about the problem being the errors displayed to the user, and not filling up the log files - which is a legitimate complaint as well)
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: Undefined index: recentBlogs error

Postby knkk on Sat Oct 23, 2010 4:54 am

Well, I cannot believe it - ini_set("display_errors", 0); worked. It's like a miracle. Thank you!

I've currently added this line to my main site's configuration file (and not any lifetype file). Which would be the best lifetype file to add this line to?

Would there be any undesirable side-effects of using ini_set("display_errors", 0);? Also, why did this work when error_reporting(0) did not work? And why did this problem crop up with PHP 5.3?

Thank you for your time!
London, New York, Chicago local guides
knkk
 
Posts: 104
Joined: Fri Oct 26, 2007 6:16 am
LifeType Version: 1.2.5

Re: Undefined index: recentBlogs error

Postby jondaley on Sat Oct 23, 2010 11:56 pm

The errors are presumably still being written to the error log. As long as your logs are rotated, or your site isn't too busy, you probably won't run into problems there - you should check to see how big that file is, and erase it occasionally if it isn't automatically rotated.

The problem came up in 5.3 because there were bigger changes than you might guess in a "minor" release number, where lifetype is doing stuff in the php4 way, and so php5 doesn't support, or is on its way to not supporting, those methods.

I'm not sure why the error_reporting didn't work for you.
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch


Return to Configuration and Installation

cron