Skip to content

Commit

Permalink
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into workflow-v3
Browse files Browse the repository at this point in the history
# Conflicts:
#	plugins/content/joomla/joomla.php
  • Loading branch information
bembelimen committed May 25, 2020
2 parents c72060b + e47d3ec commit 13e44cc
Show file tree
Hide file tree
Showing 173 changed files with 1,588 additions and 1,742 deletions.
62 changes: 7 additions & 55 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,6 @@ steps:
commands:
- npm ci --unsafe-perm

- name: publish-diff
image: joomlaprojects/docker-images:patchtester
depends_on: [ npm ]
environment:
CMP_ARCHIVE_NAME: "build"
CMP_MASTER_FOLDER: "/reference"
CMP_SLAVE_FOLDER: "." # The directory the current repo is in
FTP_USERNAME:
from_secret: ftpusername
FTP_PASSWORD:
from_secret: ftppassword
FTP_HOSTNAME: ci.joomla.org
FTP_PORT: "21"
FTP_DEST_DIR: /artifacts
FTP_VERIFY: "false"
FTP_SECURE: "true"
BRANCH_NAME: "4.0-dev" # Current branch to check against (from repo joomla/joomla-cms)
DRONE_PULL_REQUEST: DRONE_PULL_REQUEST
commands:
- export PULL_ID=$DRONE_PULL_REQUEST
- /bin/compare.sh
volumes:
- name: reference
path: /reference
when:
branch:
- 4.0-dev

- name: rebuild-cache
image: drillster/drone-volume-cache
depends_on: [ npm ]
Expand Down Expand Up @@ -241,32 +213,6 @@ steps:
status:
- failure

- name: packager
image: joomlaprojects/docker-images:packager
environment:
FTP_USERNAME:
from_secret: ftpusername
FTP_PASSWORD:
from_secret: ftppassword
FTP_HOSTNAME: ci.joomla.org
FTP_PORT: "21"
FTP_DEST_DIR: /artifacts
FTP_VERIFY: "false"
FTP_SECURE: "true"
HTTP_ROOT: "https://ci.joomla.org/artifacts"
DRONE_PULL_REQUEST: DRONE_PULL_REQUEST
DRONE_COMMIT: DRONE_COMMIT
GITHUB_TOKEN:
from_secret: github_token
commands:
- /bin/drone_build.sh
volumes:
- name: reference
path: /reference
when:
branch:
- 4.0-dev

- name: analysis4x
image: rips/rips-cli:3.2.2
depends_on: [ api-tests ]
Expand Down Expand Up @@ -354,10 +300,16 @@ steps:
commands:
- if [ $DRONE_REPO_NAME != 'joomla-cms' ]; then echo "The packager only runs on the joomla/joomla-cms repo"; exit 0; fi
- /bin/drone_build.sh
volumes:
- name: reference
path: /reference
when:
branch:
- 4.0-dev


---
kind: signature
hmac: a0026c26e94c1443cb0de99edcd5c81a83981c99ea43e5254542c2e4214abe4e
hmac: 9bb74c784835b3ef017189b6f407cf7750d3f38464d42006da76999b62b41277

...
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,27 @@
</caption>
<thead>
<tr>
<td width="1%" class="text-center">
<td class="w-1 text-center">
<?php echo HTMLHelper::_('grid.checkall'); ?>
</td>
<th scope="col" class="d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_ACTIONLOGS_ACTION', 'a.message', $listDirn, $listOrder); ?>
</th>
<th scope="col" width="15%" class="d-none d-md-table-cell">
<th scope="col" class="w-15 d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_ACTIONLOGS_EXTENSION', 'a.extension', $listDirn, $listOrder); ?>
</th>
<th scope="col" width="15%" class="d-none d-md-table-cell">
<th scope="col" class="w-15 d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_ACTIONLOGS_DATE', 'a.log_date', $listDirn, $listOrder); ?>
</th>
<th scope="col" width="10%" class="d-md-table-cell">
<th scope="col" class="w-10 d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_ACTIONLOGS_NAME', 'a.user_id', $listDirn, $listOrder); ?>
</th>
<?php if ($this->showIpColumn) : ?>
<th scope="col" width="10%" class="d-none d-md-table-cell">
<th scope="col" class="w-10 d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_ACTIONLOGS_IP_ADDRESS', 'a.ip_address', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<th scope="col" width="1%" class="d-none d-md-table-cell">
<th scope="col" class="w-1 d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
Expand All @@ -72,7 +72,7 @@
$extension = strtok($item->extension, '.');
ActionlogsHelper::loadTranslationFiles($extension); ?>
<tr>
<td class="center">
<td class="text-center">
<?php echo HTMLHelper::_('grid.id', $i, $item->id); ?>
</td>
<th scope="row" class="d-md-table-cell">
Expand Down
163 changes: 95 additions & 68 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Joomla\CMS\Table\Table;
use Joomla\Database\ParameterType;
use Joomla\Component\Fields\Administrator\Model\FieldModel;
use Joomla\Database\UTF8MB4SupportInterface;

/**
* Script file of Joomla CMS
Expand Down Expand Up @@ -6246,23 +6245,41 @@ public function convertTablesToUtf8mb4($doDbFixMsg = false)
{
$db = Factory::getDbo();

if (!($db instanceof UTF8MB4SupportInterface))
if ($db->getServerType() !== 'mysql')
{
return;
}

// Set required conversion status
if ($db->hasUTF8mb4Support())
// Check if the #__utf8_conversion table exists
$db->setQuery('SHOW TABLES LIKE ' . $db->quote($db->getPrefix() . 'utf8_conversion'));

try
{
$convertedStep1 = 2;
$convertedStep2 = 4;
$rows = $db->loadRowList(0);
}
else
catch (Exception $e)
{
$convertedStep1 = 1;
$convertedStep2 = 3;
// Render the error message from the Exception object
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');

if ($doDbFixMsg)
{
// Show an error message telling to check database problems
Factory::getApplication()->enqueueMessage(Text::_('JLIB_DATABASE_ERROR_DATABASE_UPGRADE_FAILED'), 'error');
}

return;
}

// Nothing to do if the table doesn't exist because the CMS has never been updated from a pre-4.0 version
if (\count($rows) === 0)
{
return;
}

// Set required conversion status
$converted = 4;

// Check conversion status in database
$db->setQuery('SELECT ' . $db->quoteName('converted')
. ' FROM ' . $db->quoteName('#__utf8_conversion')
Expand All @@ -6286,20 +6303,18 @@ public function convertTablesToUtf8mb4($doDbFixMsg = false)
return;
}

// Nothing to do, saved conversion status from DB is equal to required final status
if ($convertedDB == $convertedStep2)
// If conversion status from DB is equal to required final status, try to drop the #__utf8_conversion table
if ($convertedDB === $converted)
{
$this->dropUtf8ConversionTable();

return;
}

$converted = $convertedDB;
$hasErrors = false;

// Steps 1 and 2: Convert core tables if necessary and not to be done at later steps
if ($convertedDB < $convertedStep1)
// Perform the required conversions of core tables if not done already in a previous step
if ($convertedDB !== 99)
{
// Step 1: Drop indexes later to be added again with column lengths limitations at step 2
$fileName1 = JPATH_ROOT . '/administrator/components/com_admin/sql/others/mysql/utf8mb4-conversion-01.sql';
$fileName1 = JPATH_ROOT . '/administrator/components/com_admin/sql/others/mysql/utf8mb4-conversion.sql';

if (is_file($fileName1))
{
Expand All @@ -6316,14 +6331,20 @@ public function convertTablesToUtf8mb4($doDbFixMsg = false)
}
catch (Exception $e)
{
// If the query fails we will go on. It just means the index to be dropped does not exist.
$converted = $convertedDB;

// Still render the error message from the Exception object
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}
}
}
}
}

// Step 2: Perform the index modifications and conversions
$fileName2 = JPATH_ROOT . '/administrator/components/com_admin/sql/others/mysql/utf8mb4-conversion-02.sql';
// If no error before, perform the optional conversions of tables which might or might not exist
if ($converted === 4)
{
$fileName2 = JPATH_ROOT . '/administrator/components/com_admin/sql/others/mysql/utf8mb4-conversion_optional.sql';

if (is_file($fileName2))
{
Expand All @@ -6334,70 +6355,52 @@ public function convertTablesToUtf8mb4($doDbFixMsg = false)
{
foreach ($queries2 as $query2)
{
try
// Get table name from query
if (preg_match('/^ALTER\s+TABLE\s+([^\s]+)\s+/i', $query2, $matches) === 1)
{
$db->setQuery($db->convertUtf8mb4QueryToUtf8($query2))->execute();
}
catch (Exception $e)
{
$hasErrors = true;
$tableName = str_replace('`', '', $matches[1]);
$tableName = str_replace('#__', $db->getPrefix(), $tableName);

// Still render the error message from the Exception object
JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}
}
}
}

if (!$hasErrors)
{
$converted = $convertedStep1;
}
}
// Check if the table exists and if yes, run the query
try
{
$db->setQuery('SHOW TABLES LIKE ' . $db->quote($tableName));

// Step 3: Convert action logs and privacy suite tables if necessary and conversion hasn't failed before
if (!$hasErrors && $convertedDB < $convertedStep2)
{
$fileName3 = JPATH_ROOT . '/administrator/components/com_admin/sql/others/mysql/utf8mb4-conversion-03.sql';
$rows = $db->loadRowList(0);

if (is_file($fileName3))
{
$fileContents3 = @file_get_contents($fileName3);
$queries3 = $db->splitSql($fileContents3);

if (!empty($queries3))
{
foreach ($queries3 as $query3)
{
try
{
$db->setQuery($db->convertUtf8mb4QueryToUtf8($query3))->execute();
}
catch (Exception $e)
{
$hasErrors = true;
if (\count($rows) > 0)
{
$db->setQuery($query2)->execute();
}
}
catch (Exception $e)
{
$converted = 99;

// Still render the error message from the Exception object
JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
// Still render the error message from the Exception object
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}
}
}
}
}

if (!$hasErrors)
{
$converted = $convertedStep2;
}
}

if ($doDbFixMsg && $hasErrors)
if ($doDbFixMsg && $converted !== 4)
{
// Show an error message telling to check database problems
Factory::getApplication()->enqueueMessage(Text::_('JLIB_DATABASE_ERROR_DATABASE_UPGRADE_FAILED'), 'error');
}

// If the conversion was successful try to drop the #__utf8_conversion table
if ($converted === 4 && $this->dropUtf8ConversionTable())
{
// Table successfully dropped
return;
}

// Set flag in database if the conversion status has changed.
if ($converted != $convertedDB)
if ($converted !== $convertedDB)
{
$db->setQuery('UPDATE ' . $db->quoteName('#__utf8_conversion')
. ' SET ' . $db->quoteName('converted') . ' = ' . $converted . ';'
Expand All @@ -6424,6 +6427,30 @@ private function cleanJoomlaCache()
$model->clean();
}

/**
* This method drops the #__utf8_conversion table
*
* @return boolean True on success
*
* @since 4.0.0
*/
private function dropUtf8ConversionTable()
{
$db = Factory::getDbo();

try
{
$db->setQuery('DROP TABLE ' . $db->quoteName('#__utf8_conversion') . ';'
)->execute();
}
catch (Exception $e)
{
return false;
}

return true;
}

/**
* Called after any type of action
*
Expand Down
Loading

0 comments on commit 13e44cc

Please sign in to comment.