Skip to content

Commit 0b7b8ad

Browse files
authored
Merge pull request joomla#43994 from Hackwar/52-53-upmerge-20240828
2 parents 1a91fa3 + 88bf334 commit 0b7b8ad

File tree

88 files changed

+791
-252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+791
-252
lines changed

.github/workflows/create-translation-pull-request-v4.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Create translation pull request
1+
name: Create translation pull request J4
22

33
on:
44
push:

administrator/components/com_admin/script.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,23 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)
23332333
'/libraries/vendor/cweagans/composer-patches/src/Patches.php',
23342334
'/libraries/vendor/cweagans/composer-patches/tests/PatchEventTest.php',
23352335
'/libraries/vendor/laminas/laminas-diactoros/PATCHES.txt',
2336+
// From 5.1.2 to 5.1.3
2337+
'/libraries/vendor/joomla/application/rector.php',
2338+
'/libraries/vendor/joomla/console/.drone.jsonnet',
2339+
'/libraries/vendor/joomla/console/.drone.yml',
2340+
'/libraries/vendor/joomla/database/.drone.jsonnet',
2341+
'/libraries/vendor/joomla/database/.drone.yml',
2342+
'/libraries/vendor/joomla/database/phpunit.appveyor_sql2012sp1.xml.dist',
2343+
'/libraries/vendor/joomla/database/phpunit.appveyor_sql2014.xml.dist',
2344+
'/libraries/vendor/joomla/database/phpunit.appveyor_sql2017.xml.dist',
2345+
'/libraries/vendor/joomla/database/phpunit.mariadb.xml.dist',
2346+
'/libraries/vendor/joomla/database/phpunit.mysql.xml.dist',
2347+
'/libraries/vendor/joomla/database/phpunit.mysqli.xml.dist',
2348+
'/libraries/vendor/joomla/database/phpunit.pgsql.xml.dist',
2349+
'/libraries/vendor/joomla/database/phpunit.sqlite.xml.dist',
2350+
'/libraries/vendor/joomla/database/phpunit.sqlsrv.xml.dist',
2351+
'/libraries/vendor/joomla/session/.drone.jsonnet',
2352+
'/libraries/vendor/joomla/session/.drone.yml',
23362353
// From 5.2.0-alpha2 to 5.2.0-alpha3
23372354
'/libraries/vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/font-awesome/fonts/FontAwesome.otf',
23382355
'/libraries/vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/font-awesome/fonts/fontawesome-webfont.eot',

administrator/components/com_installer/src/Model/InstallModel.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Joomla\CMS\Event\Installer\BeforeInstallationEvent;
1515
use Joomla\CMS\Event\Installer\BeforeInstallerEvent;
1616
use Joomla\CMS\Factory;
17-
use Joomla\CMS\Filesystem\File;
1817
use Joomla\CMS\Installer\Installer;
1918
use Joomla\CMS\Installer\InstallerHelper;
2019
use Joomla\CMS\Language\Text;
@@ -23,6 +22,8 @@
2322
use Joomla\CMS\Router\Route;
2423
use Joomla\CMS\Updater\Update;
2524
use Joomla\CMS\Uri\Uri;
25+
use Joomla\Filesystem\Exception\FilesystemException;
26+
use Joomla\Filesystem\File;
2627
use Joomla\Filesystem\Path;
2728

2829
// phpcs:disable PSR1.Files.SideEffects
@@ -327,7 +328,13 @@ protected function _getPackageFromUpload()
327328
$tmp_src = $userfile['tmp_name'];
328329

329330
// Move uploaded file.
330-
File::upload($tmp_src, $tmp_dest, false, true);
331+
try {
332+
File::upload($tmp_src, $tmp_dest, false, true);
333+
} catch (FilesystemException $exception) {
334+
Factory::getApplication()->enqueueMessage(Text::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLUPLOADERROR'), 'error');
335+
336+
return false;
337+
}
331338

332339
// Unpack the downloaded package file.
333340
$package = InstallerHelper::unpack($tmp_dest, true);

administrator/components/com_joomlaupdate/src/Model/UpdateModel.php

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212

1313
use Joomla\CMS\Authentication\Authentication;
1414
use Joomla\CMS\Component\ComponentHelper;
15+
use Joomla\CMS\Event\Extension\AfterJoomlaUpdateEvent;
16+
use Joomla\CMS\Event\Extension\BeforeJoomlaUpdateEvent;
1517
use Joomla\CMS\Extension\ExtensionHelper;
1618
use Joomla\CMS\Factory;
17-
use Joomla\CMS\Filesystem\File as FileCMS;
1819
use Joomla\CMS\Filter\InputFilter;
1920
use Joomla\CMS\Http\Http;
2021
use Joomla\CMS\Http\HttpFactory;
@@ -30,6 +31,7 @@
3031
use Joomla\CMS\User\UserHelper;
3132
use Joomla\CMS\Version;
3233
use Joomla\Database\ParameterType;
34+
use Joomla\Filesystem\Exception\FilesystemException;
3335
use Joomla\Filesystem\File;
3436
use Joomla\Registry\Registry;
3537
use Joomla\Utilities\ArrayHelper;
@@ -508,7 +510,11 @@ protected function downloadPackage($url, $target)
508510

509511
// Make sure the target does not exist.
510512
if (is_file($target)) {
511-
File::delete($target);
513+
try {
514+
File::delete($target);
515+
} catch (FilesystemException $exception) {
516+
return false;
517+
}
512518
}
513519

514520
// Download the package
@@ -526,9 +532,9 @@ protected function downloadPackage($url, $target)
526532
$body = $result->body;
527533

528534
// Write the file to disk
529-
$result = File::write($target, $body);
530-
531-
if (!$result) {
535+
try {
536+
File::write($target, $body);
537+
} catch (FilesystemException $exception) {
532538
return false;
533539
}
534540

@@ -576,7 +582,7 @@ public function createUpdateFile($basename = null): bool
576582
$app = Factory::getApplication();
577583

578584
// Trigger event before joomla update.
579-
$app->triggerEvent('onJoomlaBeforeUpdate');
585+
$app->getDispatcher()->dispatch('onJoomlaBeforeUpdate', new BeforeJoomlaUpdateEvent('onJoomlaBeforeUpdate'));
580586

581587
// Get the absolute path to site's root.
582588
$siteroot = JPATH_SITE;
@@ -611,14 +617,18 @@ public function createUpdateFile($basename = null): bool
611617
$configpath = JPATH_COMPONENT_ADMINISTRATOR . '/update.php';
612618

613619
if (is_file($configpath)) {
614-
File::delete($configpath);
620+
try {
621+
File::delete($configpath);
622+
} catch (FilesystemException $exception) {
623+
return false;
624+
}
615625
}
616626

617627
// Write new file. First try with File.
618-
$result = File::write($configpath, $data);
619-
620-
// In case File failed but direct access could help.
621-
if (!$result) {
628+
try {
629+
$result = File::write($configpath, $data);
630+
} catch (FilesystemException $exception) {
631+
// In case File failed but direct access could help.
622632
$fp = @fopen($configpath, 'wt');
623633

624634
if ($fp !== false) {
@@ -882,25 +892,29 @@ public function cleanUp()
882892
$app = Factory::getApplication();
883893

884894
// Trigger event after joomla update.
885-
$app->triggerEvent('onJoomlaAfterUpdate');
895+
// @TODO: The event dispatched twice, here and at the end of current method. One of it should be removed.
896+
$app->getDispatcher()->dispatch('onJoomlaAfterUpdate', new AfterJoomlaUpdateEvent('onJoomlaAfterUpdate'));
886897

887898
// Remove the update package.
888899
$tempdir = $app->get('tmp_path');
889900

890901
$file = $app->getUserState('com_joomlaupdate.file', null);
891902

892-
if (is_file($tempdir . '/' . $file)) {
893-
File::delete($tempdir . '/' . $file);
894-
}
903+
try {
904+
if (is_file($tempdir . '/' . $file)) {
905+
File::delete($tempdir . '/' . $file);
906+
}
895907

896-
// Remove the update.php file used in Joomla 4.0.3 and later.
897-
if (is_file(JPATH_COMPONENT_ADMINISTRATOR . '/update.php')) {
898-
File::delete(JPATH_COMPONENT_ADMINISTRATOR . '/update.php');
899-
}
908+
// Remove the update.php file used in Joomla 4.0.3 and later.
909+
if (is_file(JPATH_COMPONENT_ADMINISTRATOR . '/update.php')) {
910+
File::delete(JPATH_COMPONENT_ADMINISTRATOR . '/update.php');
911+
}
900912

901-
// Remove joomla.xml from the site's root.
902-
if (is_file(JPATH_ROOT . '/joomla.xml')) {
903-
File::delete(JPATH_ROOT . '/joomla.xml');
913+
// Remove joomla.xml from the site's root.
914+
if (is_file(JPATH_ROOT . '/joomla.xml')) {
915+
File::delete(JPATH_ROOT . '/joomla.xml');
916+
}
917+
} catch (FilesystemException $exception) {
904918
}
905919

906920
// Unset the update filename from the session.
@@ -909,7 +923,9 @@ public function cleanUp()
909923
$oldVersion = $app->getUserState('com_joomlaupdate.oldversion');
910924

911925
// Trigger event after joomla update.
912-
$app->triggerEvent('onJoomlaAfterUpdate', [$oldVersion]);
926+
$app->getDispatcher()->dispatch('onJoomlaAfterUpdate', new AfterJoomlaUpdateEvent('onJoomlaAfterUpdate', [
927+
'oldVersion' => $oldVersion ?: '',
928+
]));
913929
$app->setUserState('com_joomlaupdate.oldversion', null);
914930

915931
try {
@@ -983,10 +999,10 @@ public function upload()
983999
$tmp_src = $userfile['tmp_name'];
9841000

9851001
// Move uploaded file.
986-
$result = FileCMS::upload($tmp_src, $tmp_dest, false, true);
987-
988-
if (!$result) {
989-
throw new \RuntimeException(Text::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLUPLOADERROR'), 500);
1002+
try {
1003+
File::upload($tmp_src, $tmp_dest, false);
1004+
} catch (FilesystemException $exception) {
1005+
throw new \RuntimeException(Text::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLUPLOADERROR'), 500, $exception);
9901006
}
9911007

9921008
Factory::getApplication()->setUserState('com_joomlaupdate.temp_file', $tmp_dest);
@@ -1061,7 +1077,10 @@ public function removePackageFiles()
10611077

10621078
foreach ($files as $file) {
10631079
if ($file !== null && is_file($file)) {
1064-
File::delete($file);
1080+
try {
1081+
File::delete($file);
1082+
} catch (FilesystemException $exception) {
1083+
}
10651084
}
10661085
}
10671086
}

administrator/components/com_menus/src/Model/MenuModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected function populateState()
125125
*
126126
* @since 1.6
127127
*/
128-
public function &getItem($itemId = null)
128+
public function getItem($itemId = null)
129129
{
130130
$itemId = (!empty($itemId)) ? $itemId : (int) $this->getState('menu.id');
131131

administrator/components/com_messages/src/Model/ConfigModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function populateState()
5757
*
5858
* @since 1.6
5959
*/
60-
public function &getItem()
60+
public function getItem()
6161
{
6262
$item = new CMSObject();
6363
$userid = (int) $this->getState('user.id');

administrator/components/com_modules/src/Model/PositionsModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function getItems()
110110
->bind(':clientid', $clientId, ParameterType::INTEGER);
111111

112112
if ($search) {
113-
$search = '%' . str_replace(' ', '%', trim($search), true) . '%';
113+
$search = '%' . str_replace(' ', '%', trim($search)) . '%';
114114
$query->where($db->quoteName('position') . ' LIKE :position')
115115
->bind(':position', $search);
116116
}

administrator/components/com_templates/src/Model/TemplateModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ protected function populateState()
625625
*
626626
* @since 1.6
627627
*/
628-
public function &getTemplate()
628+
public function getTemplate()
629629
{
630630
if (empty($this->template)) {
631631
$pk = (int) $this->getState('extension.id');

administrator/components/com_templates/src/View/Template/HtmlView.php

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -236,39 +236,9 @@ protected function addToolbar()
236236

237237
// User is global SuperUser
238238
$isSuperUser = $user->authorise('core.admin');
239-
$explodeArray = explode('.', $this->fileName);
240-
$ext = end($explodeArray);
241239

242240
ToolbarHelper::title(Text::sprintf('COM_TEMPLATES_MANAGER_VIEW_TEMPLATE', ucfirst($this->template->name)), 'icon-code thememanager');
243241

244-
// Only show file edit buttons for global SuperUser
245-
if ($isSuperUser) {
246-
// Add an Apply and save button
247-
if ($this->type === 'file') {
248-
$toolbar->apply('template.apply');
249-
$toolbar->save('template.save');
250-
} elseif ($this->type === 'image') {
251-
// Add a Crop and Resize button
252-
$toolbar->standardButton('crop', 'COM_TEMPLATES_BUTTON_CROP', 'template.cropImage')
253-
->listCheck(false)
254-
->icon('icon-crop');
255-
ToolbarHelper::modal('resizeModal', 'icon-expand', 'COM_TEMPLATES_BUTTON_RESIZE');
256-
} elseif ($this->type === 'archive') {
257-
// Add an extract button
258-
$toolbar->standardButton('extract', 'COM_TEMPLATES_BUTTON_EXTRACT_ARCHIVE', 'template.extractArchive')
259-
->listCheck(false)
260-
->icon('icon-chevron-down');
261-
} elseif ($this->type === 'home') {
262-
// Add a copy/child template button
263-
if (isset($this->template->xmldata->inheritable) && (string) $this->template->xmldata->inheritable === '1') {
264-
ToolbarHelper::modal('childModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_TEMPLATE_CHILD');
265-
} elseif (empty($this->template->xmldata->parent) && empty($this->template->xmldata->namespace)) {
266-
// We can't copy parent templates nor namespaced templates
267-
ToolbarHelper::modal('copyModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_COPY_TEMPLATE');
268-
}
269-
}
270-
}
271-
272242
// Add a Template preview button
273243
if ($this->type === 'home') {
274244
$client = (int) $this->preview->client_id === 1 ? 'administrator/' : '';
@@ -278,6 +248,44 @@ protected function addToolbar()
278248
->attributes(['target' => '_new']);
279249
}
280250

251+
// Only show file edit buttons for global SuperUser
252+
if ($isSuperUser) {
253+
switch ($this->type) {
254+
case 'file':
255+
$toolbar->apply('template.apply');
256+
$toolbar->save('template.save');
257+
$toolbar->cancel('template.close', 'COM_TEMPLATES_BUTTON_CLOSE_FILE');
258+
break;
259+
260+
case 'image':
261+
// Add a Crop and Resize button
262+
$toolbar->standardButton('crop', 'COM_TEMPLATES_BUTTON_CROP', 'template.cropImage')
263+
->listCheck(false)
264+
->icon('icon-crop');
265+
ToolbarHelper::modal('resizeModal', 'icon-expand', 'COM_TEMPLATES_BUTTON_RESIZE');
266+
$toolbar->cancel('template.close', 'COM_TEMPLATES_BUTTON_CLOSE_FILE');
267+
break;
268+
269+
case 'archive':
270+
// Add an extract button
271+
$toolbar->standardButton('extract', 'COM_TEMPLATES_BUTTON_EXTRACT_ARCHIVE', 'template.extractArchive')
272+
->listCheck(false)
273+
->icon('icon-chevron-down');
274+
break;
275+
276+
case 'home':
277+
// Add a copy/child template button
278+
if (isset($this->template->xmldata->inheritable) && (string) $this->template->xmldata->inheritable === '1') {
279+
ToolbarHelper::modal('childModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_TEMPLATE_CHILD');
280+
} elseif (empty($this->template->xmldata->parent) && empty($this->template->xmldata->namespace)) {
281+
// We can't copy parent templates nor namespaced templates
282+
ToolbarHelper::modal('copyModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_COPY_TEMPLATE');
283+
}
284+
285+
break;
286+
}
287+
}
288+
281289
// Only show file manage buttons for global SuperUser
282290
if ($isSuperUser) {
283291
if ($this->type === 'home') {
@@ -291,7 +299,7 @@ protected function addToolbar()
291299
ToolbarHelper::modal('renameModal', 'icon-sync', 'COM_TEMPLATES_BUTTON_RENAME_FILE');
292300

293301
// Add a Delete file Button
294-
ToolbarHelper::modal('deleteModal', 'icon-times', 'COM_TEMPLATES_BUTTON_DELETE_FILE', 'btn-danger');
302+
ToolbarHelper::modal('deleteModal', 'icon-trash', 'COM_TEMPLATES_BUTTON_DELETE_FILE', 'btn-danger');
295303
}
296304
}
297305

@@ -320,10 +328,8 @@ protected function addToolbar()
320328
->listCheck(true);
321329
}
322330

323-
if ($this->type === 'home') {
331+
if (!\in_array($this->type, ['image', 'file'])) {
324332
$toolbar->cancel('template.cancel');
325-
} else {
326-
$toolbar->cancel('template.close', 'COM_TEMPLATES_BUTTON_CLOSE_FILE');
327333
}
328334

329335
$toolbar->divider();

administrator/language/en-GB/com_templates.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ COM_TEMPLATES_ASSIGNED_1="Assigned to one menu item."
99
COM_TEMPLATES_ASSIGNED_MORE="Assigned to %d menu items."
1010
COM_TEMPLATES_BUTTON_CHECK="Check Overrides"
1111
COM_TEMPLATES_BUTTON_CHECK_LIST_ENTRY="Mark Checked"
12-
COM_TEMPLATES_BUTTON_CLOSE_FILE="Close File"
12+
COM_TEMPLATES_BUTTON_CLOSE_FILE="Close"
1313
COM_TEMPLATES_BUTTON_COPY_FILE="Copy File"
1414
COM_TEMPLATES_BUTTON_COPY_TEMPLATE="Copy Template"
1515
COM_TEMPLATES_BUTTON_CREATE="Create"

0 commit comments

Comments
 (0)