Skip to content

Commit 9bfa92e

Browse files
authored
Merge pull request #42001 from HLeithner/5.0/upmerge/300923
[5.0] Upmerge 30.09.23
2 parents c55a187 + 0719930 commit 9bfa92e

File tree

32 files changed

+178
-118
lines changed

32 files changed

+178
-118
lines changed

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

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -968,9 +968,9 @@ public function upload()
968968

969969
// Check the uploaded file (throws RuntimeException when a check failed)
970970
if (\extension_loaded('zip')) {
971-
$this->checkPackageFileZip($userfile['tmp_name']);
971+
$this->checkPackageFileZip($userfile['tmp_name'], $userfile['name']);
972972
} else {
973-
$this->checkPackageFileNoZip($userfile['tmp_name']);
973+
$this->checkPackageFileNoZip($userfile['tmp_name'], $userfile['name']);
974974
}
975975

976976
// Build the appropriate paths.
@@ -1790,64 +1790,66 @@ public function collectError(string $context, \Throwable $error)
17901790
/**
17911791
* Check the update package with ZipArchive class from zip PHP extension
17921792
*
1793-
* @param string $filePath Full path to the update package to test
1793+
* @param string $filePath Full path to the uploaded update package (temporary file) to test
1794+
* @param string $packageName Name of the selected update package
17941795
*
17951796
* @return void
17961797
*
1797-
* @since 5.0.0
1798+
* @since 4.4.0
17981799
* @throws \RuntimeException
17991800
*/
1800-
private function checkPackageFileZip(string $filePath)
1801+
private function checkPackageFileZip(string $filePath, $packageName)
18011802
{
18021803
$zipArchive = new \ZipArchive();
18031804

18041805
if ($zipArchive->open($filePath) !== true) {
1805-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN'), 500);
1806+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN', $packageName), 500);
18061807
}
18071808

18081809
if ($zipArchive->locateName('installation/index.php') !== false) {
1809-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_INSTALL_PACKAGE'), 500);
1810+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_INSTALL_PACKAGE', $packageName), 500);
18101811
}
18111812

18121813
$manifestFile = $zipArchive->getFromName('administrator/manifests/files/joomla.xml');
18131814

18141815
if ($manifestFile === false) {
1815-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_MANIFEST_FILE'), 500);
1816+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_MANIFEST_FILE', $packageName), 500);
18161817
}
18171818

1818-
$this->checkManifestXML($manifestFile);
1819+
$this->checkManifestXML($manifestFile, $packageName);
18191820
}
18201821

18211822
/**
18221823
* Check the update package without using the ZipArchive class from zip PHP extension
18231824
*
1824-
* @param string $filePath Full path to the update package to test
1825+
* @param string $filePath Full path to the uploaded update package (temporary file) to test
1826+
* @param string $packageName Name of the selected update package
18251827
*
18261828
* @return void
18271829
*
18281830
* @see https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
1829-
* @since 5.0.0
1831+
* @since 4.4.0
18301832
* @throws \RuntimeException
18311833
*/
1832-
private function checkPackageFileNoZip(string $filePath)
1834+
private function checkPackageFileNoZip(string $filePath, $packageName)
18331835
{
18341836
// The file must exist and be readable
18351837
if (!file_exists($filePath) || !is_readable($filePath)) {
1836-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN'), 500);
1838+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN', $packageName), 500);
18371839
}
18381840

18391841
// The file must be at least 1KiB (anything less is not even a real file!)
18401842
$filesize = filesize($filePath);
18411843

18421844
if ($filesize < 1024) {
1843-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN'), 500);
1845+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN', $packageName), 500);
18441846
}
18451847

18461848
// Open the file
18471849
$fp = @fopen($filePath, 'rb');
18481850

18491851
if ($fp === false) {
1850-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN'), 500);
1852+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN', $packageName), 500);
18511853
}
18521854

18531855
// Read chunks of max. 1MiB size
@@ -1874,7 +1876,7 @@ private function checkPackageFileNoZip(string $filePath)
18741876
if ($fileChunk === false || strlen($fileChunk) !== $readsize) {
18751877
@fclose($fp);
18761878

1877-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN'), 500);
1879+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN', $packageName), 500);
18781880
}
18791881

18801882
$posFirstHeader = strpos($fileChunk, $headerSignature);
@@ -1893,7 +1895,7 @@ private function checkPackageFileNoZip(string $filePath)
18931895
if (substr($fileChunk, $pos - 46, 4) == $headerSignature && substr($fileChunk, $pos - 18, 2) == $sizeSignatureIndexPhp) {
18941896
@fclose($fp);
18951897

1896-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_INSTALL_PACKAGE'), 500);
1898+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_INSTALL_PACKAGE', $packageName), 500);
18971899
}
18981900

18991901
$offset = $pos + 22;
@@ -1928,14 +1930,14 @@ private function checkPackageFileNoZip(string $filePath)
19281930
if (!$headerFound) {
19291931
@fclose($fp);
19301932

1931-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN'), 500);
1933+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN', $packageName), 500);
19321934
}
19331935

19341936
// If no central directory file header found for the manifest XML file it's not a valid Joomla package
19351937
if (!$headerInfo) {
19361938
@fclose($fp);
19371939

1938-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_MANIFEST_FILE'), 500);
1940+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_MANIFEST_FILE', $packageName), 500);
19391941
}
19401942

19411943
// Read the local file header of the manifest XML file
@@ -1948,7 +1950,7 @@ private function checkPackageFileNoZip(string $filePath)
19481950
if (!$localHeaderInfo['Compressed']) {
19491951
@fclose($fp);
19501952

1951-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_MANIFEST_FILE'), 500);
1953+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_MANIFEST_FILE', $packageName), 500);
19521954
}
19531955

19541956
// Read the compressed manifest XML file content
@@ -1978,34 +1980,35 @@ private function checkPackageFileNoZip(string $filePath)
19781980
}
19791981

19801982
if (!$manifestFile) {
1981-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_MANIFEST_FILE'), 500);
1983+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_MANIFEST_FILE', $packageName), 500);
19821984
}
19831985

1984-
$this->checkManifestXML($manifestFile);
1986+
$this->checkManifestXML($manifestFile, $packageName);
19851987
}
19861988

19871989
/**
19881990
* Check content of manifest XML file in update package
19891991
*
1990-
* @param string $manifest Content of the manifest XML file
1992+
* @param string $manifest Content of the manifest XML file
1993+
* @param string $packageName Name of the selected update package
19911994
*
19921995
* @return void
19931996
*
1994-
* @since 5.0.0
1997+
* @since 4.4.0
19951998
* @throws \RuntimeException
19961999
*/
1997-
private function checkManifestXML(string $manifest)
2000+
private function checkManifestXML(string $manifest, $packageName)
19982001
{
19992002
$manifestXml = simplexml_load_string($manifest);
20002003

20012004
if (!$manifestXml) {
2002-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_VERSION_FOUND'), 500);
2005+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_VERSION_FOUND', $packageName), 500);
20032006
}
20042007

20052008
$versionPackage = (string) $manifestXml->version ?: '';
20062009

20072010
if (!$versionPackage) {
2008-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_VERSION_FOUND'), 500);
2011+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_VERSION_FOUND', $packageName), 500);
20092012
}
20102013

20112014
$currentVersion = JVERSION;
@@ -2016,7 +2019,7 @@ private function checkManifestXML(string $manifest)
20162019
}
20172020

20182021
if (version_compare($versionPackage, $currentVersion, 'lt')) {
2019-
throw new \RuntimeException(Text::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_DOWNGRADE'), 500);
2022+
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_DOWNGRADE', $packageName, $versionPackage, $currentVersion), 500);
20202023
}
20212024
}
20222025
}

administrator/components/com_users/src/Model/UsersModel.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,7 @@ protected function getListQuery()
365365
$groups = $this->getState('filter.groups');
366366

367367
if ($groupId || isset($groups)) {
368-
$query->join('LEFT', '#__user_usergroup_map AS map2 ON map2.user_id = a.id')
369-
->group(
370-
$db->quoteName(
371-
[
368+
$group_by = [
372369
'a.id',
373370
'a.name',
374371
'a.username',
@@ -385,9 +382,14 @@ protected function getListQuery()
385382
'a.otpKey',
386383
'a.otep',
387384
'a.requireReset',
388-
]
389-
)
390-
);
385+
];
386+
387+
if (PluginHelper::isEnabled('multifactorauth')) {
388+
$group_by[] = 'mfa.mfaRecords';
389+
}
390+
391+
$query->join('LEFT', '#__user_usergroup_map AS map2 ON map2.user_id = a.id')
392+
->group($db->quoteName($group_by));
391393

392394
if ($groupId) {
393395
$groupId = (int) $groupId;

administrator/language/en-GB/com_joomlaupdate.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ COM_JOOMLAUPDATE_VIEW_UPDATE_FINALISE_HEAD_DESC="To complete the update Process
179179
COM_JOOMLAUPDATE_VIEW_UPDATE_PERCENT="Percent complete"
180180
COM_JOOMLAUPDATE_VIEW_UPLOAD_CAPTIVE_INTRO_BODY="Make sure that the update file you have uploaded comes from the official Joomla download page. Afterwards, please confirm that you want to install it by re-entering the login information for your site &quot;%s&quot; below."
181181
COM_JOOMLAUPDATE_VIEW_UPLOAD_CAPTIVE_INTRO_HEAD="Are you sure you want to install the file you uploaded?"
182-
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_DOWNGRADE="The update package file has a lower version than the current Joomla version. You cannot downgrade a Joomla site."
183-
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_INSTALL_PACKAGE="The uploaded package file looks like it is a full installation package of Joomla which can only be used for creating new sites. You can only use the \"Upgrade Package (.zip)\" to update your site."
184-
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_MANIFEST_FILE="The uploaded package file is not a Joomla update package. It does not contain the \"administrator/manifests/files/joomla.xml\" file."
185-
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_VERSION_FOUND="The uploaded package file is not a Joomla update package. It does not contain valid version information."
186-
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN="The uploaded package file is either not a ZIP file or is corrupted."
182+
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_DOWNGRADE="The uploaded package file \"%1$s\" has a lower version \"%2$s\" than the installed version \"%3$s\". You cannot downgrade a Joomla site.<br>Check <a class=\"alert-link\" href=\"https://downloads.joomla.org/latest\" target=\"_blank\" rel=\"noopener noreferrer\">the official Joomla download page</a> for the Joomla Upgrade Package of a <em><strong>newer version</strong></em>."
183+
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_INSTALL_PACKAGE="The uploaded package file \"%s\" looks like it is a full installation package of Joomla which can only be used for creating new sites. You can only use the <em><strong>Upgrade Package</strong></em> to update your site.<br>Check <a class=\"alert-link\" href=\"https://downloads.joomla.org/latest\" target=\"_blank\" rel=\"noopener noreferrer\">the official Joomla download page</a> for the Joomla <em><strong>Upgrade Package</strong></em> of the right version."
184+
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_MANIFEST_FILE="The uploaded package file \"%s\" is not a Joomla update package. It does not contain the \"administrator/manifests/files/joomla.xml\" file.<br>Check <a class=\"alert-link\" href=\"https://downloads.joomla.org/latest\" target=\"_blank\" rel=\"noopener noreferrer\">the official Joomla download page</a> for the right Joomla <em><strong>Upgrade Package</strong></em>."
185+
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_VERSION_FOUND="The uploaded package file \"%s\" is not a Joomla update package. It does not contain valid version information.<br>Check <a class=\"alert-link\" href=\"https://downloads.joomla.org/latest\" target=\"_blank\" rel=\"noopener noreferrer\">the official Joomla download page</a> for the right Joomla <em><strong>Upgrade Package</strong></em>."
186+
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_PACKAGE_OPEN="The uploaded package file \"%s\" is either not a ZIP file or is corrupted.<br>Check <a class=\"alert-link\" href=\"https://downloads.joomla.org/latest\" target=\"_blank\" rel=\"noopener noreferrer\">the official Joomla download page</a> for the desired Joomla <em><strong>Upgrade Package in ZIP format</strong></em>."
187187
COM_JOOMLAUPDATE_VIEW_UPLOAD_PACKAGE_FILE="Joomla package file"
188188
COM_JOOMLAUPDATE_XML_DESCRIPTION="Updates Joomla to the latest version with one click."
189189

libraries/src/Event/MultiFactor/BeforeDisplayMethods.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(User $user)
4646
* @return User
4747
* @since 4.2.0
4848
*
49-
* @deprecated 5.0.0 will be removed in 6.0
49+
* @deprecated 4.4.0 will be removed in 6.0
5050
* Use counterpart with onSet prefix
5151
*/
5252
public function setUser(User $value): User
@@ -64,7 +64,7 @@ public function setUser(User $value): User
6464
* @param User $value The value to validate
6565
*
6666
* @return User
67-
* @since 5.0.0
67+
* @since 4.4.0
6868
*/
6969
protected function onSetUser(User $value): User
7070
{

libraries/src/Event/MultiFactor/Callback.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(string $method)
4343
* @throws \DomainException
4444
* @since 4.2.0
4545
*
46-
* @deprecated 5.0.0 will be removed in 6.0
46+
* @deprecated 4.4.0 will be removed in 6.0
4747
* Use counterpart with onSet prefix
4848
*/
4949
public function setMethod(string $value): string
@@ -62,7 +62,7 @@ public function setMethod(string $value): string
6262
*
6363
* @return string
6464
* @throws \DomainException
65-
* @since 5.0.0
65+
* @since 4.4.0
6666
*/
6767
protected function onSetMethod(string $value): string
6868
{

libraries/src/Event/MultiFactor/Captive.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(MfaTable $record)
5555
* @return MfaTable
5656
* @since 4.2.0
5757
*
58-
* @deprecated 5.0.0 will be removed in 6.0
58+
* @deprecated 4.4.0 will be removed in 6.0
5959
* Use counterpart with onSet prefix
6060
*/
6161
public function setRecord(MfaTable $value): MfaTable
@@ -73,7 +73,7 @@ public function setRecord(MfaTable $value): MfaTable
7373
* @param MfaTable $value The value to validate
7474
*
7575
* @return MfaTable
76-
* @since 5.0.0
76+
* @since 4.4.0
7777
*/
7878
protected function onSetRecord(MfaTable $value): MfaTable
7979
{

libraries/src/Event/MultiFactor/GetSetup.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(MfaTable $record)
5555
* @return MfaTable
5656
* @since 4.2.0
5757
*
58-
* @deprecated 5.0.0 will be removed in 6.0
58+
* @deprecated 4.4.0 will be removed in 6.0
5959
* Use counterpart with onSet prefix
6060
*/
6161
public function setRecord(MfaTable $value): MfaTable
@@ -73,7 +73,7 @@ public function setRecord(MfaTable $value): MfaTable
7373
* @param MfaTable $value The value to validate
7474
*
7575
* @return MfaTable
76-
* @since 5.0.0
76+
* @since 4.4.0
7777
*/
7878
protected function onSetRecord(MfaTable $value): MfaTable
7979
{

libraries/src/Event/MultiFactor/SaveSetup.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function __construct(MfaTable $record, Input $input)
5959
* @return MfaTable
6060
* @since 4.2.0
6161
*
62-
* @deprecated 5.0.0 will be removed in 6.0
62+
* @deprecated 4.4.0 will be removed in 6.0
6363
* Use counterpart with onSet prefix
6464
*/
6565
public function setRecord(MfaTable $value): MfaTable
@@ -79,7 +79,7 @@ public function setRecord(MfaTable $value): MfaTable
7979
* @return Input
8080
* @since 4.2.0
8181
*
82-
* @deprecated 5.0.0 will be removed in 6.0
82+
* @deprecated 4.4.0 will be removed in 6.0
8383
* Use counterpart with onSet prefix
8484
*/
8585
public function setInput(Input $value): Input
@@ -97,7 +97,7 @@ public function setInput(Input $value): Input
9797
* @param MfaTable $value The value to validate
9898
*
9999
* @return MfaTable
100-
* @since 5.0.0
100+
* @since 4.4.0
101101
*/
102102
protected function onSetRecord(MfaTable $value): MfaTable
103103
{
@@ -110,7 +110,7 @@ protected function onSetRecord(MfaTable $value): MfaTable
110110
* @param Input $value The value to validate
111111
*
112112
* @return Input
113-
* @since 5.0.0
113+
* @since 4.4.0
114114
*/
115115
protected function onSetInput(Input $value): Input
116116
{

libraries/src/Event/MultiFactor/Validate.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function __construct(MfaTable $record, User $user, string $code)
5959
* @return MfaTable
6060
* @since 4.2.0
6161
*
62-
* @deprecated 5.0.0 will be removed in 6.0
62+
* @deprecated 4.4.0 will be removed in 6.0
6363
* Use counterpart with onSet prefix
6464
*/
6565
public function setRecord(MfaTable $value): MfaTable
@@ -79,7 +79,7 @@ public function setRecord(MfaTable $value): MfaTable
7979
* @return User
8080
* @since 4.2.0
8181
*
82-
* @deprecated 5.0.0 will be removed in 6.0
82+
* @deprecated 4.4.0 will be removed in 6.0
8383
* Use counterpart with onSet prefix
8484
*/
8585
public function setUser(User $value): User
@@ -99,7 +99,7 @@ public function setUser(User $value): User
9999
* @return string|null
100100
* @since 4.2.0
101101
*
102-
* @deprecated 5.0.0 will be removed in 6.0
102+
* @deprecated 4.4.0 will be removed in 6.0
103103
* Use counterpart with onSet prefix
104104
*/
105105
public function setCode(?string $value): ?string
@@ -114,7 +114,7 @@ public function setCode(?string $value): ?string
114114
* @param MfaTable $value The value to validate
115115
*
116116
* @return MfaTable
117-
* @since 5.0.0
117+
* @since 4.4.0
118118
*/
119119
protected function onSetRecord(MfaTable $value): MfaTable
120120
{
@@ -127,7 +127,7 @@ protected function onSetRecord(MfaTable $value): MfaTable
127127
* @param User $value The value to validate
128128
*
129129
* @return User
130-
* @since 5.0.0
130+
* @since 4.4.0
131131
*/
132132
protected function onSetUser(User $value): User
133133
{
@@ -140,7 +140,7 @@ protected function onSetUser(User $value): User
140140
* @param string|null $value The value to validate
141141
*
142142
* @return string|null
143-
* @since 5.0.0
143+
* @since 4.4.0
144144
*/
145145
protected function onSetCode(?string $value): ?string
146146
{

0 commit comments

Comments
 (0)