Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete UCM content entries when Joomla articles are deleted #13592

Merged
merged 1 commit into from
Jan 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions libraries/cms/helper/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,22 +362,37 @@ public function createTagsFromMetadata($metadata)
* Method to delete the tag mappings and #__ucm_content record for for an item
*
* @param JTableInterface $table JTable object of content table where delete occurred
* @param integer $contentItemId ID of the content item.
* @param integer|array $contentItemId ID of the content item. Or an array of key/value pairs with array key
* being a primary key name and value being the content item ID. Note
* multiple primary keys are not supported
*
* @return boolean true on success, false on failure
*
* @since 3.1
* @throws InvalidArgumentException
*/
public function deleteTagData(JTableInterface $table, $contentItemId)
{
$result = $this->unTagItem($contentItemId, $table);
$key = $table->getKeyName();

/**
* @var JTableCorecontent $ucmContentTable
*/
if (!is_array($contentItemId))
{
$contentItemId = array($key => $contentItemId);
}

// If we have multiple items for the content item primary key we currently don't support this so
// throw an InvalidArgumentException for now
if (count($contentItemId) != 1)
{
throw new InvalidArgumentException('Multiple primary keys are not supported as a content item id');
}

$result = $this->unTagItem($contentItemId[$key], $table);

/** @var JTableCorecontent $ucmContentTable */
$ucmContentTable = JTable::getInstance('Corecontent');

return $result && $ucmContentTable->deleteByContentId($contentItemId, $this->typeAlias);
return $result && $ucmContentTable->deleteByContentId($contentItemId[$key], $this->typeAlias);
}

/**
Expand Down