Skip to content

Commit

Permalink
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into 4.1-dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	libraries/src/Version.php
#	modules/mod_breadcrumbs/tmpl/default.php
  • Loading branch information
bembelimen committed Feb 28, 2021
2 parents 3f488bf + 309feb3 commit 533c202
Show file tree
Hide file tree
Showing 395 changed files with 6,635 additions and 11,205 deletions.
70 changes: 70 additions & 0 deletions administrator/components/com_admin/script.php
Expand Up @@ -252,6 +252,9 @@ protected function uninstallRepeatableFieldsPlugin()
return;
}

// Ensure the FieldsHelper class is loaded for the Repeatable fields plugin we're about to remove
\JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');

try
{
$db->transactionStart();
Expand Down Expand Up @@ -6280,6 +6283,8 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)
}
}

$this->fixFilenameCasing();

if ($suppressOutput === false && \count($status['folders_errors']))
{
echo implode('<br/>', $status['folders_errors']);
Expand Down Expand Up @@ -7142,4 +7147,69 @@ private function convertBlogLayouts()
$configModel->save($data);
}
}

/**
* Renames or removes incorrectly cased files.
*
* @return void
*
* @since 4.0.0
*/
protected function fixFilenameCasing()
{
$files = array(
// 3.10 changes
'libraries/src/Filesystem/Support/Stringcontroller.php' => 'libraries/src/Filesystem/Support/StringController.php',
'libraries/src/Form/Rule/SubFormRule.php' => 'libraries/src/Form/Rule/SubformRule.php',
// 4.0.0
'media/vendor/skipto/js/skipTo.js' => 'media/vendor/skipto/js/skipto.js',
);

foreach ($files as $old => $expected)
{
$oldRealpath = realpath(JPATH_ROOT . '/' . $old);

// On Unix without incorrectly cased file.
if ($oldRealpath === false)
{
continue;
}

$oldBasename = basename($oldRealpath);
$newRealpath = realpath(JPATH_ROOT . '/' . $expected);
$newBasename = basename($newRealpath);
$expectedBasename = basename($expected);

// On Windows or Unix with only the incorrectly cased file.
if ($newBasename !== $expectedBasename)
{
// Rename the file.
rename(JPATH_ROOT . '/' . $old, JPATH_ROOT . '/' . $old . '.tmp');
rename(JPATH_ROOT . '/' . $old . '.tmp', JPATH_ROOT . '/' . $expected);

continue;
}

// There might still be an incorrectly cased file on other OS than Windows.
if ($oldBasename === basename($old))
{
// Check if case-insensitive file system, eg on OSX.
if (fileinode($oldRealpath) === fileinode($newRealpath))
{
// Check deeper because even realpath or glob might not return the actual case.
if (!in_array($expectedBasename, scandir(dirname($newRealpath))))
{
// Rename the file.
rename(JPATH_ROOT . '/' . $old, JPATH_ROOT . '/' . $old . '.tmp');
rename(JPATH_ROOT . '/' . $old . '.tmp', JPATH_ROOT . '/' . $expected);
}
}
else
{
// On Unix with both files: Delete the incorrectly cased file.
unlink(JPATH_ROOT . '/' . $old);
}
}
}
}
}
Expand Up @@ -56,7 +56,7 @@ class HtmlView extends BaseHtmlView
/**
* Selected item type properties.
*
* @var Registry
* @var \Joomla\Registry\Registry
*
* @since 3.7.0
*/
Expand Down
Expand Up @@ -71,7 +71,7 @@
<th scope="col" class="w-15">
<?php echo Text::_('JGRID_HEADING_LANGUAGE'); ?>
</th>
<th scope="col" class="w-5">
<th scope="col" class="w-15">
<?php echo Text::_('COM_ASSOCIATIONS_HEADING_ASSOCIATION'); ?>
</th>
<th scope="col" class="w-15">
Expand Down
Expand Up @@ -100,7 +100,7 @@
?>
<tr class="row<?php echo $i % 2; ?>" data-draggable-group="<?php echo $item->catid; ?>">
<td class="text-center">
<?php echo HTMLHelper::_('grid.id', $i, $item->id); ?>
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->name); ?>
</td>
<td class="text-center d-none d-md-table-cell">
<?php
Expand Down
Expand Up @@ -101,7 +101,7 @@
?>
<tr class="row<?php echo $i % 2; ?>">
<td class="text-center">
<?php echo HTMLHelper::_('grid.id', $i, $item->id); ?>
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->name); ?>
</td>
<td class="text-center">
<?php echo HTMLHelper::_('jgrid.published', $item->state, $i, 'clients.', $canChange); ?>
Expand Down
Expand Up @@ -153,6 +153,18 @@ public function batch($model = null)
protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
{
$append = parent::getRedirectToItemAppend($recordId);

// In case extension is not passed in the URL, get it directly from category instead of default to com_content
if (!$this->input->exists('extension') && $recordId > 0)
{
$table = $this->getModel('Category')->getTable();

if ($table->load($recordId))
{
$this->extension = $table->extension;
}
}

$append .= '&extension=' . $this->extension;

return $append;
Expand Down
Expand Up @@ -160,7 +160,7 @@
?>
<tr class="row<?php echo $i % 2; ?>" data-draggable-group="<?php echo $item->parent_id; ?>" item-id="<?php echo $item->id ?>" parents="<?php echo $parentsStr ?>" level="<?php echo $item->level ?>">
<td class="text-center">
<?php echo HTMLHelper::_('grid.id', $i, $item->id); ?>
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->title); ?>
</td>
<td class="text-center d-none d-md-table-cell">
<?php
Expand Down
Expand Up @@ -268,7 +268,7 @@ public function sendtestmail()
$this->app->sendHeaders();

// Check if user token is valid.
if (!Session::checkToken('get'))
if (!Session::checkToken())
{
$this->app->enqueueMessage(Text::_('JINVALID_TOKEN'), 'error');
echo new JsonResponse;
Expand Down
Expand Up @@ -201,7 +201,23 @@ public function cancel($key = null)
// Clear session data.
$this->app->setUserState("$this->option.edit.$this->context.$component.data", null);

$this->setRedirect(Route::_('index.php?option=' . $component, false));
// Calculate redirect URL
$returnUri = $this->input->post->get('return', null, 'base64');

$redirect = 'index.php?option=' . $component;

if (!empty($returnUri))
{
$redirect = base64_decode($returnUri);
}

// Don't redirect to an external URL.
if (!Uri::isInternal($redirect))
{
$redirect = Uri::base();
}

$this->setRedirect(Route::_($redirect, false));

return true;
}
Expand Down
Expand Up @@ -142,11 +142,11 @@ protected function getInput()
. ' class="novalidate form-select"'
. '>';
$html[] = ' <option value="BL"' . ($group_filter['filter_type'] == 'BL' ? ' selected="selected"' : '') . '>'
. Text::_('COM_CONFIG_FIELD_FILTERS_DEFAULT_BLACK_LIST') . '</option>';
. Text::_('COM_CONFIG_FIELD_FILTERS_DEFAULT_FORBIDDEN_LIST') . '</option>';
$html[] = ' <option value="CBL"' . ($group_filter['filter_type'] == 'CBL' ? ' selected="selected"' : '') . '>'
. Text::_('COM_CONFIG_FIELD_FILTERS_CUSTOM_BLACK_LIST') . '</option>';
. Text::_('COM_CONFIG_FIELD_FILTERS_CUSTOM_FORBIDDEN_LIST') . '</option>';
$html[] = ' <option value="WL"' . ($group_filter['filter_type'] == 'WL' ? ' selected="selected"' : '') . '>'
. Text::_('COM_CONFIG_FIELD_FILTERS_WHITE_LIST') . '</option>';
. Text::_('COM_CONFIG_FIELD_FILTERS_ALLOWED_LIST') . '</option>';
$html[] = ' <option value="NH"' . ($group_filter['filter_type'] == 'NH' ? ' selected="selected"' : '') . '>'
. Text::_('COM_CONFIG_FIELD_FILTERS_NO_HTML') . '</option>';
$html[] = ' <option value="NONE"' . ($group_filter['filter_type'] == 'NONE' ? ' selected="selected"' : '') . '>'
Expand Down
125 changes: 125 additions & 0 deletions administrator/components/com_config/src/Model/ApplicationModel.php
Expand Up @@ -727,6 +727,131 @@ public function save($data)
}
}

/*
* Look for a custom tmp_path
* First check if a path is given in the submitted data, then check if a path exists in the previous data, otherwise use the default
*/
$defaultTmpPath = JPATH_ROOT . '/tmp';

if (!empty($data['tmp_path']))
{
$path = $data['tmp_path'];
}
elseif (!empty($prev['tmp_path']))
{
$path = $prev['tmp_path'];
}
else
{
$path = $defaultTmpPath;
}

$path = Path::clean($path);

// Give a warning if the tmp-folder is not valid or not writable
if (!is_dir($path) || !is_writable($path))
{
$error = true;

// If a custom path is in use, try using the system default tmp path
if ($path !== $defaultTmpPath && is_dir($defaultTmpPath) && is_writable($defaultTmpPath))
{
try
{
Log::add(
Text::sprintf('COM_CONFIG_ERROR_CUSTOM_TEMP_PATH_NOTWRITABLE_USING_DEFAULT', $path, $defaultTmpPath),
Log::WARNING,
'jerror'
);
}
catch (\RuntimeException $logException)
{
$app->enqueueMessage(
Text::sprintf('COM_CONFIG_ERROR_CUSTOM_TEMP_PATH_NOTWRITABLE_USING_DEFAULT', $path, $defaultTmpPath),
'warning'
);
}

$error = false;

$data['tmp_path'] = $defaultTmpPath;
}

if ($error)
{
try
{
Log::add(Text::sprintf('COM_CONFIG_ERROR_TMP_PATH_NOTWRITABLE', $path), Log::WARNING, 'jerror');
}
catch (\RuntimeException $exception)
{
$app->enqueueMessage(Text::sprintf('COM_CONFIG_ERROR_TMP_PATH_NOTWRITABLE', $path), 'warning');
}
}
}

/*
* Look for a custom log_path
* First check if a path is given in the submitted data, then check if a path exists in the previous data, otherwise use the default
*/
$defaultLogPath = JPATH_ADMINISTRATOR . '/logs';

if (!empty($data['log_path']))
{
$path = $data['log_path'];
}
elseif (!empty($prev['log_path']))
{
$path = $prev['log_path'];
}
else
{
$path = $defaultLogPath;
}

$path = Path::clean($path);

// Give a warning if the log-folder is not valid or not writable
if (!is_dir($path) || !is_writable($path))
{
$error = true;

// If a custom path is in use, try using the system default log path
if ($path !== $defaultLogPath && is_dir($defaultLogPath) && is_writable($defaultLogPath))
{
try
{
Log::add(
Text::sprintf('COM_CONFIG_ERROR_CUSTOM_LOG_PATH_NOTWRITABLE_USING_DEFAULT', $path, $defaultLogPath),
Log::WARNING,
'jerror'
);
}
catch (\RuntimeException $logException)
{
$app->enqueueMessage(
Text::sprintf('COM_CONFIG_ERROR_CUSTOM_LOG_PATH_NOTWRITABLE_USING_DEFAULT', $path, $defaultLogPath),
'warning'
);
}

$error = false;
$data['log_path'] = $defaultLogPath;
}

if ($error)
{
try
{
Log::add(Text::sprintf('COM_CONFIG_ERROR_LOG_PATH_NOTWRITABLE', $path), Log::WARNING, 'jerror');
}
catch (\RuntimeException $exception)
{
$app->enqueueMessage(Text::sprintf('COM_CONFIG_ERROR_LOG_PATH_NOTWRITABLE', $path), 'warning');
}
}
}

// Create the new configuration object.
$config = new Registry($data);

Expand Down
Expand Up @@ -102,7 +102,7 @@
?>
<tr class="row<?php echo $i % 2; ?>" data-draggable-group="<?php echo $item->catid; ?>">
<td class="text-center">
<?php echo HTMLHelper::_('grid.id', $i, $item->id); ?>
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->name); ?>
</td>
<td class="text-center d-none d-md-table-cell">
<?php
Expand Down

0 comments on commit 533c202

Please sign in to comment.