ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Reverse related entries & {if:else} Conditionals

March 24, 2011 2:18pm

Subscribe [3]
  • #1 / Mar 24, 2011 2:18pm

    Focus Lab Dev Team

    1129 posts

    Howdy

    I had a template shooting out a 404 page for some reason “out of the blue.” It was a page on a site that didn’t get a lot of traffic so when it was brought to my attention this morning I assumed it has been acting up for a little while. I know the page & code rendered properly when we launched.

    We launched the site in 1.6.8 and have since upgraded to 1.6.9 then 1.7.0.

    I narrowed down the problem to a conditional like this:

    {if a == b} something {if:else} something else {/if}

    When changing the code to this the 404 problem went away:

    {if a == b} something {/if}
    {if a != b} something else{/if}

    Not really a big deal or a hard change to make.

    I’m still curious, though, how this cropped up in a perfectly good and working template. I noticed the following from the 1.6.9 change log items:

    Optimized the weblog module’s parsing of reverse related entries to reduce memory consumption.

    Could this have played a role in my conditional parsing issue?

    Any insight is appreciated. Thanks!

  • #2 / Mar 25, 2011 6:59am

    John Henry Donovan

    12339 posts

    Erik,

    Can you give us a bit more detail for that template please?
    Are you using reverse related entries?
    Do you have a no_results conditional?
    Are you using a required entry parameter?
    Are you using a htaccess?

    What add-ons are you using?

  • #3 / Mar 29, 2011 1:14pm

    Focus Lab Dev Team

    1129 posts

    JH,

    Thanks for the reply. Problem solved.

    After further digging I narrowed it down to a template with the following code:

    {exp:weblog:entries weblog="my_weblog" limit="15"}
    
        <h2>{title}</h2><p> <br />
        <br />
        {reverse_related_entries sort="desc" orderby="title"} <br />
            {title}<br />
        {/reverse_related_entries}<br />
        <br />
    {/exp:weblog:entries}

    The site was choking on this code returning an HTTP response header of 500.

    I disabled all extensions in my config file and the page loaded fine. I then singled out the extensions using hooks on template processing and ended up finding that disabling FieldFrame made the page load successfully. I then began to disable fieldtypes one by one to see which was the culprit.

    The short of it is that I needed to hike up my PHP memory limit or come up with a better, more efficient way of building this page.

    The weblog_entries_tagdata hook alone was being called 568 times on this page load. Needless to say this was causing PHP to give up.

    I only go into detail hoping it may help someone else.

    Thanks,
    Erik

  • #4 / Mar 29, 2011 1:15pm

    Focus Lab Dev Team

    1129 posts

    Another note:

    The reason this happened “out of the blue” was due to the increase in entries being returned within my reverse related entries tag pair. Upon launch this was not a problem. About 100 new entries later it was.

  • #5 / Mar 30, 2011 5:25am

    Greg Salt

    3988 posts

    Hi Erik,

    Ah, okay. Thanks for the update and glad that you found the culprit.

    Cheers

    Greg

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases