-
Notifications
You must be signed in to change notification settings - Fork 31
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
Remove raw sql #139
base: main
Are you sure you want to change the base?
Remove raw sql #139
Conversation
cdc5eb5
to
e56ffcd
Compare
'remove_delete_watcher_group_btn' => 1, | ||
'remove_delete_assign_group_btn' => 0, | ||
'remove_delete_assign_supplier_btn' => 1, | ||
'use_filter_assign_group' => 1, |
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.
It was 0 on previous code.
'use_filter_assign_group' => 1, | |
'use_filter_assign_group' => 0, |
$status = CommonITILObject::INCOMING.", ".CommonITILObject::PLANNED.", ". | ||
CommonITILObject::ASSIGNED.", ".CommonITILObject::WAITING; |
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 has to be converted into an array of values.
$status = CommonITILObject::INCOMING.", ".CommonITILObject::PLANNED.", ". | |
CommonITILObject::ASSIGNED.", ".CommonITILObject::WAITING; | |
$status = [ | |
CommonITILObject::INCOMING, | |
CommonITILObject::PLANNED, | |
CommonITILObject::ASSIGNED, | |
CommonITILObject::WAITING, | |
]; |
if (!$res = $DB->query($query_users)) { | ||
$res = $DB->insert('glpi_tickets_user', new QuerySubQuery([ | ||
'SELECT' => [ | ||
new QueryExpression("'' AS " . $DB::quoteName('id')), |
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.
new QueryExpression("'' AS " . $DB::quoteName('id')), | |
new QueryExpression($DB::quoteValue('') . " AS " . $DB::quoteName('id')), |
if (!$res = $DB->query($query_groups)) { | ||
$res = $DB->insert('glpi_tickets_user', new QuerySubQuery([ | ||
'SELECT' => [ | ||
new QueryExpression("'' AS " . $DB::quoteName('id')), |
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.
new QueryExpression("'' AS " . $DB::quoteName('id')), | |
new QueryExpression($DB::quoteValue('') . " AS " . $DB::quoteName('id')), |
if (! $res = $DB->query($query_docs)) { | ||
$res = $DB->insert('glpi_documents_items', new QuerySubQuery([ | ||
'SELECT' => [ | ||
new QueryExpression("'' AS " . $DB::quoteName('id')), |
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.
new QueryExpression("'' AS " . $DB::quoteName('id')), | |
new QueryExpression($DB::quoteValue('') . " AS " . $DB::quoteName('id')), |
getEntitiesRestrictCriteria('glpi_groups', '', $entity, true, true) | ||
], |
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.
We had an issue recently on treeview plugin with this because getEntitiesRestrictCriteria()
can return an empty array. See pluginsGLPI/treeview#49.
getEntitiesRestrictCriteria('glpi_groups', '', $entity, true, true) | |
], | |
] + getEntitiesRestrictCriteria('glpi_groups', '', $entity, true, true), |
|
||
if ($filter) { | ||
$query .= "AND ($filter)"; | ||
$criteria['WHERE'][] = new QueryExpression($filter); |
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.
Method is used only at 2 distinct places, please transform $filter
into an array in order to also remove raw SQL in caller method.
$criteria['WHERE'][] = new QueryExpression($filter); | |
$criteria['WHERE'][] = $filter; |
Remove raw SQL to improve future compatibility.
Requires glpi-project/glpi#14970 for
INSERT INTO ... SELECT
support.