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

Checking for 'none' as the only device relationship #8837

Merged
merged 1 commit into from Jun 21, 2018

Conversation

Projects
None yet
3 participants
@salt-lick
Contributor

salt-lick commented Jun 21, 2018

Per a discussion with @murrant in Discord, this change adds a check to make sure None is not the relationship that is being queried against on save. 'None' has an ID of '0' in the $_POST['parents_id'] array.

Without this check added, the Librenms error log contains entries like this when you save an edit to a device if none is the relationship that is selected.

2018-06-21 09:18:25 MySQL Error: Cannot add or update a child row: a foreign key constraint fails (`librenms`.`device_relationships`, CONSTRAINT `device_relationship_parent_device_id_fk` FOREIGN KEY (`parent_device_id`) REFERENCES `devices` (`device_id`) ON DELETE CASCADE) (INSERT INTO `device_relationships` (`parent_device_id`,`child_device_id`) VALUES ('0','35'))

DO NOT DELETE THIS TEXT

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926

Checking for 'none' as the only device relationship
Per a discussion with @murrant in Discord, this change adds a check to make sure `None` is not the relationship that is being queried against on save.  'None' has an ID of '0' in the $_POST['parents_id'] array. 

Without this check added, the Librenms error log contains entries like this when you save an edit to a device if `none` is the relationship that is selected.

```2018-06-21 09:18:25 MySQL Error: Cannot add or update a child row: a foreign key constraint fails (`librenms`.`device_relationships`, CONSTRAINT `device_relationship_parent_device_id_fk` FOREIGN KEY (`parent_device_id`) REFERENCES `devices` (`device_id`) ON DELETE CASCADE) (INSERT INTO `device_relationships` (`parent_device_id`,`child_device_id`)  VALUES ('0','35'))```
@murrant

LGTM, Thanks!

@murrant murrant merged commit 93dbd94 into librenms:master Jun 21, 2018

3 checks passed

WIP ready for review
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details

@salt-lick salt-lick deleted the salt-lick:patch-5 branch Jun 26, 2018

@laf laf added the Bug 🐞 label Jun 26, 2018

mattie47 added a commit to mattie47/librenms that referenced this pull request Jul 2, 2018

Checking for 'none' as the only device relationship (librenms#8837)
Per a discussion with @murrant in Discord, this change adds a check to make sure `None` is not the relationship that is being queried against on save.  'None' has an ID of '0' in the $_POST['parents_id'] array. 

Without this check added, the Librenms error log contains entries like this when you save an edit to a device if `none` is the relationship that is selected.

```2018-06-21 09:18:25 MySQL Error: Cannot add or update a child row: a foreign key constraint fails (`librenms`.`device_relationships`, CONSTRAINT `device_relationship_parent_device_id_fk` FOREIGN KEY (`parent_device_id`) REFERENCES `devices` (`device_id`) ON DELETE CASCADE) (INSERT INTO `device_relationships` (`parent_device_id`,`child_device_id`)  VALUES ('0','35'))```

@lock lock bot locked as resolved and limited conversation to collaborators Aug 25, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.