On Thu, Nov 6, 2008 at 2:20 PM, Sebastian Goebel wrote:
> Hi,
>
> I found this bug, which happens under some circumstances
> http://code.campware.org/projects/campsite/ticket/2644
>
> The reason that it appears is explained here:
>
> http://www.bigroom.co.uk/blog/php-nesting-level-too-deep-recursive-dependency
>
>
> Here an code example where it happens (from CampContext.php line 912):
> private function setArticleHandler(MetaArticle $p_oldArticle,
> MetaArticle $p_newArticle)
> {
> static $articleHandlerRunning = false;
> if ($articleHandlerRunning || $p_newArticle == $p_oldArticle) {
> return;
> }
> (...)
> }
>
> I am not sure if we can solve it be just changing the comparision operator
> to the strict one (====). In this case similar MetaArticle objects (same
> properties, but created twice) will not be found as identical. The article
> is clear about that:
> *If, however, we use strict comparison (===), PHP will check whether the
> two objects are exactly the same object, not just objects with the same
> properties.
> *
> Additionally I tested it by setting an breakpoint to the return
> statement in line 916. Changing the comparision operator to ===, it will be
> reached just in an very special case. Check the ticket for the template code
> which paste identical objects to the method.
>
> In deep, I believe the m_contentCache is problematic. It stores article
> fields, which themself having key m_parent to reference the MetaArticle
> object again. There it seems is the circular reference. See the attachment.
>
> Two solutions I see:
> 1. The __create method of metaobjects have to take care if an identical
> object was requested, and just return an reference to that, not creating it
> again. This would be good for performance too, but I don't know if this
> causes problems. AFIK MetaObjects are just readable and will not be
> modified.
> 2. The comparisions does not compare the whole object, instead just the
> keys which identify 2 objects as beeing unique. E.g. for article number and
> language id.
>
> Btw, comparing the whole objects key by key sounds ineffective.
>
>
>
> So, let our scientists speak up.
>
> Sebastian
>
>
>