refactor: MySQL strict and query fixes #5338

Merged
merged 2 commits into from Jan 13, 2017

Projects

None yet

4 participants

@laf
Member
laf commented Jan 7, 2017

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.

These now start to address STRICT_TRANS_TABLES

@laf laf refactor: MySQL strict and query fixes
4d0e354
@@ -14,7 +14,7 @@
$delete_username = dbFetchCell('SELECT username FROM users WHERE user_id = ?', array($vars['id']));
if ($vars['confirm'] == 'yes') {
- if (deluser($delete_username)) {
+ if (deluser($vars['id']) >= 0) {
@murrant
murrant Jan 8, 2017 Contributor

Why not put the >= 0 check inside the function so it just returns a boolean?

@laf
laf Jan 8, 2017 Member

That function is in all of the authentication modules (well 3/4) so this seemed a bit more central.

@murrant
murrant Jan 8, 2017 Contributor

I was thinking of the function. What do you want to know upon return of the function. Was it successful or not. (rather than the id that you already sent or not if if it failed).

@laf
laf Jan 8, 2017 Member

Are you talking about the deluser() function?

@murrant
murrant Jan 8, 2017 Contributor

yes.

@laf
laf Jan 8, 2017 Member

That function is in all of the auth modules so it would mean updating them all to do that same check and return true / false when we can just do it here.

@murrant
murrant Jan 9, 2017 Contributor

Yes, because when you call deluser you will never want to know the user id you deleted.
Basically, there is a hidden rule that you need to add >= 0 after this method everytime it is called.

I understand that it is only called once and there is three implementations... Can't fix everything at once.

@laf
laf Jan 9, 2017 Member

I'm happy to update it but it just seems a bit ott for a function that we most likely won't ever call unless someone creates a deluser.php for cli.

@laf
laf Jan 12, 2017 Member

Want me to update the deluser() functions to be able to merge this?

@murrant
murrant Jan 12, 2017 Contributor

It's fine, I guess I'm just trying to express a general guideline...

@laf laf moved sql file
e32a5fc
@laf
Member
laf commented Jan 10, 2017

Rebased

@scrutinizer-notifier

The inspection completed: 2 new issues, 1 updated code elements

@murrant murrant merged commit d529631 into librenms:master Jan 13, 2017

2 checks passed

Auto-Deploy Build finished.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@laf laf deleted the laf:mysqlllll1111 branch Jan 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment