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

Handle case of first CORS whitelist add-delete #29742

Merged
merged 1 commit into from
Dec 3, 2017
Merged

Handle case of first CORS whitelist add-delete #29742

merged 1 commit into from
Dec 3, 2017

Conversation

phil-davis
Copy link
Contributor

Description

Handle a default array the first time when there are no CORS whitelist entries.
When removing the last entry, delete the value completely.

Related Issue

Motivation and Context

Be able to add and delete CORS whitelist entries.

How Has This Been Tested?

Add and delete various entries manually in the webUI, refreshing to confirm the changes.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@phil-davis phil-davis added this to the development milestone Dec 1, 2017
@phil-davis phil-davis self-assigned this Dec 1, 2017
@@ -136,11 +136,14 @@ public function addDomain($domain) {
*/
public function removeDomain($id) {
$userId = $this->userId;
$domains = json_decode($this->config->getUserValue($userId, 'core', 'domains'));

$domains = json_decode($this->config->getUserValue($userId, 'core', 'domains'), true);
Copy link
Contributor

Choose a reason for hiding this comment

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

why not also add "[]" here for consistency since you did above ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, in theory removeDomain is only called if there is something to remove. But I guess it should be resilient and silent remove something from nothing if asked.

if ($id >= 0 && $id < count($domains)) {
unset($domains[$id]);
$this->config->setUserValue($userId, 'core', 'domains', json_encode($domains));
if (count($domains)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

empty($domains) ?

@phil-davis
Copy link
Contributor Author

@ anybody who cares - I think this swill pass unit tests and also actually works now. CI will tell. Ready for review again.

@codecov
Copy link

codecov bot commented Dec 1, 2017

Codecov Report

Merging #29742 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #29742   +/-   ##
=========================================
  Coverage     62.61%   62.61%           
+ Complexity    17582    17581    -1     
=========================================
  Files          1037     1037           
  Lines         57914    57914           
=========================================
  Hits          36263    36263           
  Misses        21651    21651
Impacted Files Coverage Δ Complexity Δ
settings/Controller/CorsController.php 97.5% <100%> (ø) 10 <0> (-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 a416a25...59cc6a3. Read the comment docs.

@PVince81 PVince81 merged commit 1518adb into master Dec 3, 2017
@PVince81 PVince81 deleted the fix-cors-1 branch December 3, 2017 18:30
@PVince81
Copy link
Contributor

PVince81 commented Dec 3, 2017

@phil-davis please backport for 10.0.4

@PVince81
Copy link
Contributor

PVince81 commented Dec 3, 2017

stable10: #29749

@lock
Copy link

lock bot commented Aug 1, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 1, 2019
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.

3 participants