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

Patch fix sql error on gengroupsql #9929

Merged
merged 5 commits into from Mar 18, 2019

Conversation

Projects
None yet
4 participants
@dracmic
Copy link
Contributor

commented Mar 11, 2019

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
After you are done testing, you can remove the changes with ./scripts/github-remove. If there are schema changes, you can ask on discord how to revert.

@PipoCanaja

This comment has been minimized.

Copy link
Contributor

commented Mar 11, 2019

Hi @dracmic
Could you detail the bug you are facing ? any way to reproduce it ?
PipoCanaja

@@ -153,6 +152,11 @@ function GenGroupSQL($pattern, $search = '', $extra = 0)
if (!empty($join)) {
$join = '('.rtrim($join, '& ').') &&';
}
//patch sql error adding extra devices table in query when it has 3 elements
$pos=array_search('devices',$tables);

This comment has been minimized.

Copy link
@murrant

murrant Mar 12, 2019

Member

This line is unused.

//patch sql error adding extra devices table in query when it has 3 elements
$pos=array_search('devices',$tables);
if (count($tables)==3) {
array_pop($tables);

This comment has been minimized.

Copy link
@murrant

murrant Mar 12, 2019

Member

It would probably be better to just call array_unique($tables) to remove any duplicate tables.

This current code removes the last table when there happens to be 3 tables.

This comment has been minimized.

Copy link
@dracmic

dracmic Mar 12, 2019

Author Contributor

Hello,

I am open to suggestion, but being a beginner in writing code and I just like to debug. I just wanted to help. I can redo the commit with array_unique.

This comment has been minimized.

Copy link
@murrant

murrant Mar 12, 2019

Member

You can also update this PR. Currently the code doesn't work as you intend (in some cases).

I think just $tables = array_unique($tables); should be the only thing needed.

murrant added some commits Mar 13, 2019

@murrant murrant merged commit fffd45a into librenms:master Mar 18, 2019

5 of 6 checks passed

Travis CI - Pull Request Build Failed
Details
Inspection Summary
Details
Node: analysis
Details
WIP Ready for review
Details
codeclimate All good!
Details
license/cla Contributor License Agreement is signed.
Details

@laf laf added the Bug 🐞 label Mar 31, 2019

funzoneq added a commit to funzoneq/librenms that referenced this pull request Apr 30, 2019

Patch fix sql error on gengroupsql (librenms#9929)
* Patch fix sql error on gengroupsql

* Update device-groups.inc.php

* Update device-groups.inc.php

* Update device-groups.inc.php

* Update device-groups.inc.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.