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

Fixes #13341: Clean up correct seats on license delete #13342

Merged
merged 1 commit into from
Jul 20, 2023

Conversation

Loemnk
Copy link

@Loemnk Loemnk commented Jul 20, 2023

Description

When you have two licenses:

  • License A with X seats checked out
  • License B with 0 sets checked out

When you now delete License B, and License A has a seat with the id of License A, then the fields assigned_to and asset_id will be set to NULL.

This happens because in snipe-it/app/Http/Controllers/Licenses/LicensesController.php:210 the query incorrectly checks for id instead of license_id.

Additionally, this does not show up in the activity log.

Before this change, we checked for the id collumn in the license_seats table, insteasd of using license_id for this.

This way, we ensure that we only alter seats belonging to the correct license.

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context, providing screenshots where practical. List any dependencies that are required for this change.

Fixes #13341

Type of change

Please delete options that are not relevant.

  • [x ] 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 not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • PHP version: 8.1
  • MySQL version: 8.0.33
  • Webserver version: Apache 2.4.52
  • OS version: Ubuntu 22.04

Checklist:

  • [x ] I have read the Contributing documentation available here: https://snipe-it.readme.io/docs/contributing-overview
  • [ x] I have formatted this PR according to the project guidelines: https://snipe-it.readme.io/docs/contributing-overview#pull-request-guidelines
  • [ x] My code follows the style guidelines of this project
  • [ x] I have performed a self-review of my own code
  • [ x] I have commented my code, particularly in hard-to-understand areas
  • [ x] I have made corresponding changes to the documentation
  • [ x] My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Before this, we checked for the `id` collumn in the `license_seats` table, insteasd of
using `license_id` for this.

This way, we ensure that we only alter seats belonging to the correct license.
@Loemnk Loemnk requested a review from snipe as a code owner July 20, 2023 11:55
@welcome
Copy link

welcome bot commented Jul 20, 2023

💖 Thanks for this pull request! 💖

We use semantic commit messages to streamline the release process and easily generate changelogs between versions. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix if it doesn't have one already.

Examples of commit messages with semantic prefixes:

  • Fixed #<issue number>: don't overwrite prevent_default if default wasn't prevented
  • Added #<issue number>: add checkout functionality to assets
  • Improved Asset Checkout: use new notification method for checkout

Things that will help get your PR across the finish line:

  • Document any user-facing changes you've made.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@what-the-diff
Copy link

what-the-diff bot commented Jul 20, 2023

PR Summary

  • Updated Deletion Method in Licenses Controller
    The system's way of managing and tracking licenses has been optimized. Previously, when a license was removed, our system would reference the wrong value leading to incorrect record updates. With this change, we will be accurately tracking seat assignments based on the specific license identifiers, helping ensure more consistent and accurate license management.


@snipe
Copy link
Owner

snipe commented Jul 20, 2023

Thanks for this!

@snipe snipe merged commit 917005c into snipe:develop Jul 20, 2023
@welcome
Copy link

welcome bot commented Jul 20, 2023

Congrats on merging your first pull request! 🎉🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants