Details
-
Improvement
-
Status: Unverified Fix (View Workflow)
-
Major
-
Resolution: Fixed
-
3.1.0-dev
-
None
-
None
Description
The function is nice and allows easier MOD injections, but currently the array is mostly added directly inside the function call, so it can not be easily modified.
Example from viewtopic.php
current:
$sql = $db->sql_build_query('SELECT', array(
|
'SELECT' => 'u.*, z.friend, z.foe, p.*',
|
'FROM' => array(
|
USERS_TABLE => 'u',
|
POSTS_TABLE => 'p',
|
),
|
'LEFT_JOIN' => array(
|
array(
|
'FROM' => array(ZEBRA_TABLE => 'z'),
|
'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id'
|
)
|
),
|
'WHERE' => $db->sql_in_set('p.post_id', $post_list) . '
|
AND u.user_id = p.poster_id'
|
));
|
When the code would be:
$sql_ary = array(
|
'SELECT' => 'u.*, z.friend, z.foe, p.*',
|
'FROM' => array(
|
USERS_TABLE => 'u',
|
POSTS_TABLE => 'p',
|
),
|
'LEFT_JOIN' => array(
|
array(
|
'FROM' => array(ZEBRA_TABLE => 'z'),
|
'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id'
|
),
|
),
|
'WHERE' => $db->sql_in_set('p.post_id', $post_list) . '
|
AND u.user_id = p.poster_id',
|
);
|
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
The MOD can simply add a $sql_ary['LEFT_JOIN'][] = mod_extend_array(); before the $sql = $db->sql_build_query('SELECT', $sql_ary);
Attachments
Issue Links
- caused
-
PHPBB3-10636 cache_moderators() generates invalid query
- Closed