-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[4.0] [com_modules] convert to prepared statement #25386
Conversation
Co-Authored-By: Quy <quy@fluxbb.org>
Co-Authored-By: Quy <quy@fluxbb.org>
Co-Authored-By: Quy <quy@fluxbb.org>
Co-Authored-By: Quy <quy@fluxbb.org>
Co-Authored-By: Quy <quy@fluxbb.org>
Co-Authored-By: Quy <quy@fluxbb.org>
Co-Authored-By: Quy <quy@fluxbb.org>
Co-Authored-By: Quy <quy@fluxbb.org>
Co-Authored-By: Quy <quy@fluxbb.org>
@@ -1074,7 +1088,8 @@ public function save($data) | |||
$db->quoteName('#__modules', 'm') . ' ON ' . $db->quoteName('e.client_id') . ' = ' . (int) $table->client_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.
' ON ' => ,
I would not use leftJoin any longer because it's an unneeded function call and should be removed in my opinion see joomla-framework/database#174
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 cannot see any leftJoin
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.
Starts two line above
Co-Authored-By: Quy <quy@fluxbb.org>
Co-Authored-By: Quy <quy@fluxbb.org>
Co-Authored-By: Quy <quy@fluxbb.org>
Error 500
|
$db->setQuery($query); | ||
$menus = $db->loadColumn(); | ||
|
||
// Insert the new records into the table | ||
foreach ($menus as $menu) | ||
foreach ($menus as $i => $menu) |
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.
You could rewrite this query to one execute call and add only ->values() in the loop something like:
$query->insert($db->quoteName('#__modules_menu'))
->columns($db->quoteName(['moduleid', 'menuid']))
foreach ($menus as $i => $menu)
{
$query->values(implode(', ', [':newid' . $i, ':menu' . $i]))
->bind(':newid' . $i, $newId, ParameterType::INTEGER)
->bind(':menu' . $i, $menu, ParameterType::INTEGER);
}
$db->setQuery($query);
$db->execute();
->values((int) $table->id . ', 0'); | ||
->insert($db->quoteName('#__modules_menu')) | ||
->columns($db->quoteName(['moduleid', 'menuid'])) | ||
->values(implode(', ', [':moduleid', 0])) |
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.
Implode is unneeded, I would only concatenate a string.
@@ -1074,7 +1088,8 @@ public function save($data) | |||
$db->quoteName('#__modules', 'm') . ' ON ' . $db->quoteName('e.client_id') . ' = ' . (int) $table->client_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.
Starts two line above
fixed now, can you confirm ? |
I have tested this item ✅ successfully on fd9f342 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/25386. |
1 similar comment
I have tested this item ✅ successfully on fd9f342 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/25386. |
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/25386. |
Thanks! |
Summary of Changes
use prepared statement for SQL
Testing Instructions
test com_modules
Expected result
should work as before
Actual result
N/A