11 years ago
Topic

I'm getting bit by this bug weekly it seems. You can self-reference an article. So if you have a type Product and you have an Article (Related) field pointing to a category containing Product content types, you can self-reference the exact article you're in with itself.


My solution is to make it is to add a check against the current article ID in the database query on line 200 of plugins/cck_field/joomla_article/joomla_article.php:


$opts2     =   JCckDatabase::loadObjectList( 'SELECT title AS text, id AS value FROM '.self::$table.' WHERE catid IN('.$options.') AND state = 1 ORDER BY title', 'value' );


I did not modify the line above, but I would add in AND value != '.$article->id.' (whatever is the id of the current article)


When articles can self-reference, you get infinite loops and out of memory errors.

Get a VIP membership
11 years ago
0
Level 1

I solved this by adding a few lines of code to the bottom of _prepare() in the plgContentCCK class in plugins/content/cck/cck.php:

    if (
       !(
         array_key_exists('cckRecursiveIds', $GLOBALS)
         && array_key_exists($cck->id, $GLOBALS['cckRecursiveIds'])
       )
     ) {
       $GLOBALS['cckRecursiveIds'][$cck->id] = true;
       $this->_render( $context, $article, $tpl, $contentType, $fields, $property, $client, $cck );
     }

Is it possible a developer could add this or something better to the codebase please?

Get a Book for SEBLOD