Skip to content
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
87 changes: 0 additions & 87 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -886,96 +886,9 @@ public function postflight($action, $installer)
return true;
}

// Update UCM content types.
$this->updateContentTypes();

return true;
}

/**
* Updates content type table classes.
*
* @return void
*
* @since 4.0.0
*/
private function updateContentTypes(): void
{
// Content types to update.
$contentTypes = [
'com_content.article',
'com_contact.contact',
'com_newsfeeds.newsfeed',
'com_tags.tag',
'com_banners.banner',
'com_banners.client',
'com_users.note',
'com_content.category',
'com_contact.category',
'com_newsfeeds.category',
'com_banners.category',
'com_users.category',
'com_users.user',
];

// Get table definitions.
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select(
[
$db->quoteName('type_alias'),
$db->quoteName('table'),
]
)
->from($db->quoteName('#__content_types'))
->whereIn($db->quoteName('type_alias'), $contentTypes, ParameterType::STRING);

$db->setQuery($query);
$contentTypes = $db->loadObjectList();

// Prepare the update query.
$query = $db->getQuery(true)
->update($db->quoteName('#__content_types'))
->set($db->quoteName('table') . ' = :table')
->where($db->quoteName('type_alias') . ' = :typeAlias')
->bind(':table', $table)
->bind(':typeAlias', $typeAlias);

$db->setQuery($query);

foreach ($contentTypes as $contentType) {
list($component, $tableType) = explode('.', $contentType->type_alias);

// Special case for core table classes.
if ($contentType->type_alias === 'com_users.users' || $tableType === 'category') {
$tablePrefix = 'Joomla\\CMS\Table\\';
$tableType = ucfirst($tableType);
} else {
$tablePrefix = 'Joomla\\Component\\' . ucfirst(substr($component, 4)) . '\\Administrator\\Table\\';
$tableType = ucfirst($tableType) . 'Table';
}

// Bind type alias.
$typeAlias = $contentType->type_alias;

$table = json_decode($contentType->table);

// Update table definitions.
$table->special->type = $tableType;
$table->special->prefix = $tablePrefix;

// Some content types don't have this property.
if (!empty($table->common->prefix)) {
$table->common->prefix = 'Joomla\\CMS\\Table\\';
}

$table = json_encode($table);

// Execute the query.
$db->execute();
}
}

/**
* Renames or removes incorrectly cased files.
*
Expand Down