The folder [installation] should have been removed.
The folder [installation] is still there.
Joomla 4.0.0-beta7-dev
PHP 8.0.1
MySQLi 10.2.33-MariaDB-log
This happens when you choose an additional language towards the end of installation.
If at step 5 you do not choose an additional language but immediately click [Remove "installation" folder] the folder [installation] will b removed all right.
There is an error in the tag «Build: 4.0.0-beta8-dev». I was using Joomla 4.0.0-beta7-dev downloaded today from https://github.com/joomla/joomla-cms/releases/tag/4.0.0-beta7. I did three test-installations with this package:
Installation 1 and 3 the folder "installation" was not deleted.
@crimle Please test using the Joomla nightly builds: https://developer.joomla.org/nightly-builds.html
I was testing again with the nightly build right now.
Despite my clicking the red button [Remove "installation" folder] the folder was NOT deleted.
Please note: the error only occurs, when choosing an additional language towards the end of the installation.
See attached screenshot.
Confirmed on a fresh 4.0 dev.
Install a laguage and SET IT AS DEFAULT. Then the installation folder remains after delete button.
Labels |
Added:
J4 Issue
?
|
Please open Console to see any js error
The delete is not working on a dev env, it's not a bug
Priority | Urgent | ⇒ | Medium |
Labels |
Removed:
?
|
Delete is working if no language is selected or the language is not set as default. I tested several times on win 10, xampp, php 7.4.
I performed the tests in a local environment, always the same directory
So either it is a bug that the folder ist deleted as @infograf768 and I can see, or it is strange that the folder remains in some situations as @crimle and I have seen ... as long as we are in development is makes no difference.
@dgrammatiko the difference between a dev and release is that you do not have to delete the installation folder. You should still be able to its just not required
The point here is not that it does not have to be deleted on the dev.
The OP says the button does not work. My tests here show that it works in the conditions stated (install language, make it as default).
The event here is present and the js is working as should.
Maybe a permissions issue? Not sure as I can’t reproduce.
@infograf768
Did you just select «German (Germany)» using the radio buttons?
Or did you click the [Set default language] button afterwards?
And after that the [Remove "installation" folder?
Oops.. I did not use the set default language button
testing again
I confirm the bug and console does not show any error...
Labels |
Added:
?
|
@dgrammatiko @Fedik
Looks like the issue is in the remove.js
I not tested, but js just showing the result. And because the response is 200 it thinks that all is okay.
The bug may be due this TODO
:
joomla-cms/installation/src/Controller/InstallationController.php
Lines 267 to 277 in 60f2f0d
If there any error happen during InstallationController::delete()
it should return error response, but it just stays silent.
Additionally, this section totaly ignored (because that TODO
):
joomla-cms/installation/src/Controller/InstallationController.php
Lines 261 to 266 in 60f2f0d
The Remove Installation folder button only exists if we are in development...
<?php if ($this->development) : ?>
<div class="alert flex-column mb-1" id="removeInstallationTab">
<span class="mb-1 font-weight-bold"><?php echo Text_('INSTL_SITE_DEVMODE_LABEL'); ?></span>
<button class="btn btn-danger mb-1" id="removeInstallationFolder"><?php echo Textsprintf('INSTL_COMPLETE_REMOVE_FOLDER', 'installation'); ?></button>
</div>
<?php endif; ?>
If I set the Version param to stable
, then it does not show at all.
Then if I test without installing extra languages and just click Complete and Open (site or admin), the installation folder is not deleted at all and we do not get to site or admin
we have a real mess here
I just checked a page that I had installed with Joomla Beta 7 online. I added a second language here, which is the default language. The installation folder was not deleted. I did not check this at the time of installation.
Just now I tested this again locally. If you select another language and set it as default, then the installation folder is not deleted. There is also no hint or error displayed. You click the delete button and assume that the directory is deleted. You can continue to navigate to site or admin normally.
I'm sure there are a few installations that are online and their webmasters don't read this issue. What happens with this? Is there any way to ensure that the directory is deleted in a future update?
Then if I test without installing extra languages and just click Complete and Open (site or admin), the installation folder is not deleted at all and we do not get to site or admin
we have a real mess here
I'll bet that the session is different on the last page than the one on the previous page. I thought this was fixed...
EDIT: can someone test the following: add
Joomla.replaceTokens(successresponse.token);
after
@dgrammatiko
Does not work here.
There are also other problems to solve when this one is done.
Does not work here.
Yes it needs also passing the token from the PHP side $r->token = $app->getFormToken();
in both set and setdefault functions on installation/src/Controller/LanguageController.php
@dgrammatiko
Alas this does not work here.
@dgrammatiko is right, it a session issue, server response for task=installation.removeFolder
:
Plus javascript issue because it should show that there an error to User
Please provide patch as a priority. This is an important Release Blocker.
Other notables errors:
The Remove Installation Folder
button is only displayed when we are in -dev version
The Important Alert
INSTL_COMPLETE_REMOVE_INSTALLATION="PLEASE REMEMBER TO COMPLETELY REMOVE THE INSTALLATION FOLDER.<br />You will not be able to proceed beyond this point until the "%s" folder has been removed. This is a security feature of Joomla!"
is absent from 4.0.
IMHO, we need to modify the remove/default.php to
<div class="alert flex-column mb-1" id="removeInstallationTab">
<?php if ($this->development) : ?>
<span class="mb-1 font-weight-bold"><?php echo Text::sprintf('INSTL_SITE_DEVMODE_LABEL', 'installation'); ?></span>
<?php else : ?>
<span class="mb-1 font-weight-bold"><?php echo Text::sprintf('INSTL_COMPLETE_REMOVE_INSTALLATION', 'installation'); ?></span>
<?php endif; ?>
<button class="btn btn-danger mb-1" id="removeInstallationFolder"><?php echo Text::sprintf('INSTL_COMPLETE_REMOVE_FOLDER', 'installation'); ?></button>
</div>
and modify strings to something like
INSTL_SITE_DEVMODE_LABEL="We detected development mode.<br>The \"%s\" folder should be deleted if you are not testing on localhost."
INSTL_COMPLETE_REMOVE_INSTALLATION="PLEASE REMEMBER TO COMPLETELY REMOVE THE INSTALLATION FOLDER.<br>You will not be able to proceed beyond this point until the \"%s\" folder has been removed. This is a security feature of Joomla!"
We have also to make sure that, after setting Default Languages by using the Set default language
button, the final page is no more including the choice to install new languages and setting Default again as we would get in another token issue.
@infograf768 not before finishing the Child templates UI...
Look like the solution is:
@dgrammatiko @Fedik Do we have a javascript API to get the token from the hidden input, something like token = Joomla.getToken(); ? I tested by using the code
if (form) {
var data = Joomla.serialiseForm(form);
}
else
{
var data = {};
}
then pass that data in ajax request https://github.com/joomla/joomla-cms/blob/4.0-dev/installation/template/js/remove.js#L39 and it works. But I know it is not nice to use that code.
Do we have a javascript API to get the token from the hidden input
nope, a new token should come from ajax response I think,
something like in comment @dgrammatiko #32516 (comment)
but confusing part is why it changes after set default language,
I cannot find a reason
There is an api Joomla.refreshToken() iirc which takes it from the hidden input
that something new
It’s a useless piece of code that used only in the installation but still bloating core.js. I mean it’s not the only useless thing in that file
@joomdonation adding the token should be way easier in this case:
// Get the token from the previous response and save it as `token`
Joomla.request({
method: "POST",
// Then just append it here
url: Joomla.installationBaseUrl + '?task=installation.removeFolder&format=json&' + token + '=1',
perform: true,
// token: true,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
onSuccess: function () {
const customInstallation = document.getElementById('customInstallation');
customInstallation.parentNode.removeChild(customInstallation);
const removeInstallationTab = document.getElementById('removeInstallationTab');
removeInstallationTab.parentNode.removeChild(removeInstallationTab);
},
onError: function (xhr) {
Joomla.renderMessages({ error: [xhr] }, '#system-message-container');
}
}
);
@dgrammatiko I know adding the token is easy. I was asking to see if we have an easy way to get the token from previous response instead of having to:
var form = document.getElementById('languagesForm');
if (form) {
var data = Joomla.serialiseForm(form);
}
else
{
var data = {};
}
Joomla.replaceTokens = function (newToken) {
if (!/^[0-9A-F]{32}$/i.test(newToken)) {
return;
}
var elements = [].slice.call(document.getElementsByTagName('input'));
elements.forEach(function (element) {
if (element.type === 'hidden' && element.value === '1' && element.name.length === 32) {
element.name = newToken;
}
});
};
but confusing part is why it changes after set default language,
I cannot find a reason
@Fedik As I understand, for each ajax request, we generate a new token https://github.com/joomla/joomla-cms/blob/4.0-dev/installation/src/Response/JsonResponse.php#L35 , that's why the old token is not valid anymore.
hm, I see now, that explain everything,
so as @dgrammatiko said, this section should update/store the token:
joomla-cms/installation/template/js/remove.js
Lines 96 to 101 in d14dcd9
The token also should be updated in ScriptOptions registry:
Joomla.loadOptions({'csrf.token': successresponse.token})
because Joomla.request() pick it from there for POST request:
joomla-cms/build/media_source/system/js/core.es6/ajax.es6
Lines 65 to 70 in d14dcd9
Then this basically should be done after every request, if we update session token every time.
Joomla.loadOptions is what I'm looking for :).
@dgrammatiko @joomdonation @Fedik It is a pleasure to me to see how you are working together. These are the times when I love to be here. We are community, free, from all over the world. Thanks a lot for that.
Can't wait to test a working PR ;)
@joomdonation to recap here:
set
and setdefault
functions on installation/src/Controller/LanguageController.phpjoomla-cms/installation/template/js/remove.js
Lines 90 to 105 in d14dcd9
function updateToken(token) {
let options = Joomla.optionStorage;
options['X-CSRF-Token'] = token;
Joomla.loadOptions(options)
}
Joomla.request({
method: 'POST',
url: `${Joomla.installationBaseUrl}?view=setup&frontendlang=${frontendlang}&administratorlang=${administratorlang}&task=language.setdefault&format=json`,
perform: true,
token: true,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
onSuccess(response) {
const successresponse = JSON.parse(response);
if (successresponse.messages) {
Joomla.renderMessages(successresponse.messages, '#system-message-container');
updateToken(successresponse.token)
}
},
onError(xhr) {
Joomla.renderMessages({ error: [xhr] }, '#system-message-container');
const successresponse = JSON.parse(response); // This might need a try/catch
updateToken(successresponse.token)
},
});
That should be all 4-5 lines of code needed here
EDIT Oops the Joomla object needs to be invoked here
@dgrammatiko It would be simpler than that if Joomla.loadOptions works as @Fedik mentioned. I will give it a try later today.
@joomdonation actually what I posted was wrong, the token needs to be updated using Joomla.loadOptions
@dgrammatiko Yes, Joomla.loadOptions is the way to go. Tested and it worked.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-03-06 12:43:03 |
Closed_By | ⇒ | richard67 |
Labels |
Removed:
?
|
Can't confirm this on 4.0-dev as of today.