Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
5bc1339a
Commit
5bc1339a
authored
Aug 18, 2014
by
Martin Danko
Committed by
Robert Lyon
Oct 22, 2014
Browse files
SQL optimization
Bug 1358092 Change-Id: I688f290dd8904621a7d9328dfeed549eed8ab2aa
parent
30a3e92f
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/account/activity/index.json.php
View file @
5bc1339a
...
...
@@ -54,42 +54,47 @@ if ($markasread) {
$message
=
get_string
(
'markedasread'
,
'activity'
);
}
else
if
(
$delete
)
{
$ids
=
array
();
$
raw
ids
=
array
();
$deleteunread
=
0
;
// Remember the number of unread messages being deleted
foreach
(
$_GET
as
$k
=>
$v
)
{
if
(
preg_match
(
'/^delete\-(\d+)$/'
,
$k
,
$m
))
{
$ids
[]
=
$m
[
1
];
$
raw
ids
[]
=
$m
[
1
];
if
(
isset
(
$_GET
[
'unread-'
.
$m
[
1
]]))
{
$deleteunread
++
;
}
}
}
if
(
$ids
)
{
$strids
=
join
(
','
,
$ids
);
if
(
$rawids
)
{
$userid
=
$USER
->
get
(
'id'
);
db_begin
();
// Remove parent pointers to messages we're about to delete
// Use temp table in subselect for Mysql compat.
execute_sql
(
"
UPDATE
{
notification_internal_activity
}
SET parent = NULL
WHERE parent IN (
SELECT id
FROM (
SELECT id FROM
{
notification_internal_activity
}
WHERE id IN (
$strids
) AND usr = ?
) AS temp
)"
,
array
(
$userid
)
);
delete_records_select
(
'notification_internal_activity'
,
"id IN (
$strids
) AND usr = ?"
,
// Ignore message ids that do not belong to the current user to stop
// hacking of the form allowing the deletion of messages owned by other users.
$rawstrids
=
join
(
','
,
$rawids
);
$ids
=
get_column_sql
(
"SELECT id FROM
{
notification_internal_activity
}
WHERE id IN (
$rawstrids
) AND usr = ?"
,
array
(
$userid
)
);
if
(
$deleteunread
)
{
$newunread
=
$USER
->
add_unread
(
-
$deleteunread
);
if
(
$ids
)
{
$strids
=
join
(
','
,
$ids
);
db_begin
();
// Remove parent pointers to messages we're about to delete
execute_sql
(
"
UPDATE
{
notification_internal_activity
}
SET parent = NULL
WHERE parent IN (
$strids
)"
);
delete_records_select
(
'notification_internal_activity'
,
"id IN (
$strids
)"
);
if
(
$deleteunread
)
{
$newunread
=
$USER
->
add_unread
(
-
1
*
$deleteunread
);
}
db_commit
();
}
db_commit
();
}
$message
=
get_string
(
'deletednotifications'
,
'activity'
,
count
(
$ids
));
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment