-
Notifications
You must be signed in to change notification settings - Fork 453
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
Consistent DB enum
function
#5952
Consistent DB enum
function
#5952
Conversation
/** | ||
* @param string|null $where_clause | ||
* @param string|null $order_clause | ||
* @return list<BoincUser> | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the typing. If we target recent php versions I can just add it directly in the function signature (except for the generic return).
@@ -29,7 +29,7 @@ | |||
|
|||
function create_category($orderID, $name, $is_helpdesk) { | |||
$q = "(orderID, lang, name, is_helpdesk) values ($orderID, 1, '$name', $is_helpdesk)"; | |||
$db = BoincDB::get(); | |||
$db = BoincDb::get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The case was incorrect. PHP is case-insensitive but it is better to use the correct casing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to split this file to have 1 file per class for OOP. I'm not sure that this is possible with the current setup though.
* @param string|null $where_clause | ||
* @param string|null $order_clause | ||
* @return list<BoincProfile> | ||
*/ | ||
static function enum($where_clause=null, $order_clause=null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only occurence of $where_clause=null
, should I keep it? Or should I check for usages?
static function enum($where_clause, $order_clause=null) { | ||
$db = BoincDb::get(); | ||
return $db->enum('team_delta', 'BoincTeamDelta', $where_clause); | ||
return $db->enum('team_delta', 'BoincTeamDelta', $where_clause, $order_clause); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to have this function in a trait?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot wasn't able to review any files in this pull request.
Files not reviewed (5)
- html/inc/boinc_db.inc: Language not supported
- html/inc/db_conn.inc: Language not supported
- html/ops/create_forums.php: Language not supported
- html/user/get_project_config.php: Language not supported
- html/user/server_status.php: Language not supported
@davidpanderson, please review |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5952 +/- ##
=========================================
Coverage 10.73% 10.73%
Complexity 1068 1068
=========================================
Files 280 280
Lines 36619 36619
Branches 8489 8489
=========================================
Hits 3930 3930
Misses 32300 32300
Partials 389 389 |
207e56c
to
6c38fbe
Compare
There's a better way to do the DB API, but a this point there's no |
Can you update your vision on #1813? I may be able to tackle this. |
It's possible to use inheritance so that the table-specific classes (BoincUser etc.) Something that would be worth doing: make sure that SQL injection attacks are impossible.
I can create an issue if you'd like. |
If we take example from PDO, DBAL and Eloquent they all favor parameterized queries. So it is the responsibility of the caller to use parameters and the API guarantee that those cannot be used as SQL injection. |
Fixes #1813
Description of the Change
Make all DB
enum
functions consistentAbout the following requirement from the task:
Should I just update the
DbConn::enum
andDbConn::enum_fields
?Release Notes
N/A