Skip to content

Commit 0bc385d

Browse files
wilsongerdeutz
authored andcommitted
Delete UCM content entries when Joomla articles are deleted (#13592)
1 parent 4477944 commit 0bc385d

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

libraries/cms/helper/tags.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,22 +362,37 @@ public function createTagsFromMetadata($metadata)
362362
* Method to delete the tag mappings and #__ucm_content record for for an item
363363
*
364364
* @param JTableInterface $table JTable object of content table where delete occurred
365-
* @param integer $contentItemId ID of the content item.
365+
* @param integer|array $contentItemId ID of the content item. Or an array of key/value pairs with array key
366+
* being a primary key name and value being the content item ID. Note
367+
* multiple primary keys are not supported
366368
*
367369
* @return boolean true on success, false on failure
368370
*
369371
* @since 3.1
372+
* @throws InvalidArgumentException
370373
*/
371374
public function deleteTagData(JTableInterface $table, $contentItemId)
372375
{
373-
$result = $this->unTagItem($contentItemId, $table);
376+
$key = $table->getKeyName();
374377

375-
/**
376-
* @var JTableCorecontent $ucmContentTable
377-
*/
378+
if (!is_array($contentItemId))
379+
{
380+
$contentItemId = array($key => $contentItemId);
381+
}
382+
383+
// If we have multiple items for the content item primary key we currently don't support this so
384+
// throw an InvalidArgumentException for now
385+
if (count($contentItemId) != 1)
386+
{
387+
throw new InvalidArgumentException('Multiple primary keys are not supported as a content item id');
388+
}
389+
390+
$result = $this->unTagItem($contentItemId[$key], $table);
391+
392+
/** @var JTableCorecontent $ucmContentTable */
378393
$ucmContentTable = JTable::getInstance('Corecontent');
379394

380-
return $result && $ucmContentTable->deleteByContentId($contentItemId, $this->typeAlias);
395+
return $result && $ucmContentTable->deleteByContentId($contentItemId[$key], $this->typeAlias);
381396
}
382397

383398
/**

0 commit comments

Comments
 (0)