Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old installer logic from ContentController #2958

Closed
maxime-rainville opened this issue Jun 7, 2024 · 1 comment
Closed

Remove old installer logic from ContentController #2958

maxime-rainville opened this issue Jun 7, 2024 · 1 comment

Comments

@maxime-rainville
Copy link
Contributor

maxime-rainville commented Jun 7, 2024

We used to have an installer that could be use to set up your environment file via a browser form.

We got rid of that some time ago, but there's bits of logic left in Content Controller to handle that. At first glance, these bits look mildly scary because they are printing out credentials, pinging back some silverstripe domain and deleting files. Glancing at the fine print of the code, I don't think there's any risk. But it's certainly not code we should be keeping around.

I don't think there's anything useful that can be done with this code anyway, so we can probably removed it in CMS 5.

/**
* This action is called by the installation system
*/
public function successfullyinstalled()
{
// Return 410 Gone if this site is not actually a fresh installation
if (!file_exists(PUBLIC_PATH . '/install.php')) {
$this->httpError(410);
}
if (isset($_SESSION['StatsID']) && $_SESSION['StatsID']) {
$url = 'http://ss2stat.silverstripe.com/Installation/installed?ID=' . $_SESSION['StatsID'];
@file_get_contents($url ?? '');
}
global $project;
$data = new ArrayData([
'Project' => Convert::raw2xml($project),
'Username' => Convert::raw2xml($this->getRequest()->getSession()->get('username')),
'Password' => Convert::raw2xml($this->getRequest()->getSession()->get('password')),
]);
return [
"Title" => _t(__CLASS__ . ".INSTALL_SUCCESS", "Installation Successful!"),
"Content" => $data->renderWith([
'type' => 'Includes',
'Install_successfullyinstalled',
]),
];
}
public function deleteinstallfiles()
{
if (!Permission::check("ADMIN")) {
return Security::permissionFailure($this);
}
$title = new DBVarchar("Title");
$content = new DBHTMLText('Content');
// As of SS4, index.php is required and should never be deleted.
$installfiles = [
'install.php',
'install-frameworkmissing.html',
'index.html'
];
$unsuccessful = new ArrayList();
foreach ($installfiles as $installfile) {
$installfilepath = PUBLIC_PATH . '/' . $installfile;
if (file_exists($installfilepath ?? '')) {
@unlink($installfilepath ?? '');
}
if (file_exists($installfilepath ?? '')) {
$unsuccessful->push(new ArrayData(['File' => $installfile]));
}
}
$data = new ArrayData([
'Username' => Convert::raw2xml($this->getRequest()->getSession()->get('username')),
'Password' => Convert::raw2xml($this->getRequest()->getSession()->get('password')),
'UnsuccessfulFiles' => $unsuccessful,
]);
$content->setValue($data->renderWith([
'type' => 'Includes',
'Install_deleteinstallfiles',
]));
return [
"Title" => $title,
"Content" => $content,
];
}

Acceptance criteria

  • successfullyinstalled and deleteinstallfiles are removed from ContentController in CMS6 and deprecated in CMS 5.
  • Matching actions and routes are removed.
  • Any related unit test are removed.

CMS 5 PRs

CMS 6 PRs

NOTE Don't merge these until the CMS 5 PRs have been merged in and up - this is to ensure we don't get deprecation notices popping up in weird places due to bad mergeups.

@emteknetnz
Copy link
Member

Reassigning to Guy to merge-up and update CMS 6 PRs

@GuySartorelli GuySartorelli changed the title Removed old installer logic from ContentController Remove old installer logic from ContentController Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants