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

do not fail update or installation when .htaccess file is not writable #34478

Merged
merged 1 commit into from
Feb 14, 2019

Conversation

individual-it
Copy link
Member

Description

since #32230 an exception is thrown when the .htaccess is read-only but it has to be possible to install or update oC when the .htaccess file is not writeable
but when occ maintenance:update:htaccess and the file cannot be updated the command should fail

Related Issue

Motivation and Context

see issue

How Has This Been Tested?

  • install oC with R/O .htaccess
  • install oC with R/W .htaccess
  • update oC with R/O .htaccess
  • run occ maintenance:update:htaccess with R/O .htaccess
  • run occ maintenance:update:htaccess with R/W .htaccess

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Open tasks:

  • Backport (if applicable set "backport-request" label and remove when the backport was done)

@@ -472,11 +468,11 @@ public static function updateHtaccess() {

if ($content !== '') {
$fileWriteResult = @\file_put_contents(
$setupHelper->pathToHtaccess(), $htaccessContent . $content . "\n"
self::pathToHtaccess(), $htaccessContent . $content . "\n"
);
if ($fileWriteResult === false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - the "real" exception is still thrown here, if we did get here and still the htaccess file could not be written.

Copy link
Contributor

@phil-davis phil-davis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
I will let @PVince81 give the final approval.

@codecov
Copy link

codecov bot commented Feb 14, 2019

Codecov Report

Merging #34478 into master will decrease coverage by <.01%.
The diff coverage is 40%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #34478      +/-   ##
============================================
- Coverage     64.84%   64.83%   -0.01%     
- Complexity    18323    18325       +2     
============================================
  Files          1198     1198              
  Lines         69576    69575       -1     
  Branches       1283     1283              
============================================
- Hits          45115    45112       -3     
- Misses        24087    24089       +2     
  Partials        374      374
Flag Coverage Δ Complexity Δ
#javascript 53.1% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 66.19% <40%> (-0.01%) 18325 <1> (+2)
Impacted Files Coverage Δ Complexity Δ
lib/private/Updater.php 12.41% <0%> (-0.18%) 51 <0> (+2)
lib/private/Setup.php 26.6% <57.14%> (-1%) 52 <1> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ca47dd...b74c4da. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Feb 14, 2019

Codecov Report

Merging #34478 into master will decrease coverage by <.01%.
The diff coverage is 40%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #34478      +/-   ##
============================================
- Coverage     64.84%   64.83%   -0.01%     
- Complexity    18323    18325       +2     
============================================
  Files          1198     1198              
  Lines         69576    69575       -1     
  Branches       1283     1283              
============================================
- Hits          45115    45112       -3     
- Misses        24087    24089       +2     
  Partials        374      374
Flag Coverage Δ Complexity Δ
#javascript 53.1% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 66.19% <40%> (-0.01%) 18325 <1> (+2)
Impacted Files Coverage Δ Complexity Δ
lib/private/Updater.php 12.41% <0%> (-0.18%) 51 <0> (+2)
lib/private/Setup.php 26.6% <57.14%> (-1%) 52 <1> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ca47dd...b74c4da. Read the comment docs.

@individual-it
Copy link
Member Author

tried hard to add more unit tests but the whole install/update code is hard to test

@@ -425,11 +425,7 @@ public static function updateHtaccess() {
$webRoot = !empty(\OC::$WEBROOT) ? \OC::$WEBROOT : '/';
}

$setupHelper = new \OC\Setup($config, \OC::$server->getIniWrapper(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the class exists in this form due to unit testing.
I'm unsure whether we should remove it like this but I don't mind if it doesn't break anything...

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

setup works again on my env

@PVince81 PVince81 merged commit 986bbbb into master Feb 14, 2019
@delete-merged-branch delete-merged-branch bot deleted the htaccessFix branch February 14, 2019 15:52
@PVince81
Copy link
Contributor

@individual-it please backport

@phil-davis
Copy link
Contributor

Backport stable10 #34486

@lock lock bot locked as resolved and limited conversation to collaborators Feb 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't setup with non-writable htaccess
3 participants