Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
hubzilla
core
Commits
16555b93
Commit
16555b93
authored
Jan 11, 2023
by
Mario
Browse files
fix race conditions when processing multiple choice polls
parent
2eb4f093
Pipeline
#564624
passed with stage
in 1 minute and 14 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Zotlabs/Lib/Activity.php
View file @
16555b93
...
...
@@ -2081,16 +2081,29 @@ class Activity {
}
static
function
update_poll
(
$item
,
$post
)
{
static
function
update_poll
(
$item
_id
,
$post
)
{
$multi
=
false
;
$mid
=
$post
[
'mid'
];
$content
=
$post
[
'title'
];
if
(
!
$item_id
)
{
return
false
;
}
dbq
(
"START TRANSACTION"
);
$item
=
q
(
"SELECT * FROM item WHERE id = %d FOR UPDATE"
,
intval
(
$item_id
)
);
if
(
!
$item
)
{
dbq
(
"COMMIT"
);
return
false
;
}
$item
=
$item
[
0
];
$o
=
json_decode
(
$item
[
'obj'
],
true
);
if
(
$o
&&
array_key_exists
(
'anyOf'
,
$o
))
{
$multi
=
true
;
...
...
@@ -2162,16 +2175,23 @@ class Activity {
}
logger
(
'updated_poll: '
.
print_r
(
$o
,
true
),
LOGGER_DATA
);
if
(
$answer_found
&&
!
$found
)
{
q
(
"update item set obj = '%s', edited = '%s' where id = %d"
,
$u
=
q
(
"update item set obj = '%s', edited = '%s' where id = %d"
,
dbesc
(
json_encode
(
$o
)),
dbesc
(
datetime_convert
()),
intval
(
$item
[
'id'
])
);
Master
::
Summon
([
'Notifier'
,
'wall-new'
,
$item
[
'id'
],
$post
[
'mid'
]
/* trick queueworker de-duplication */
]);
return
true
;
if
(
$u
)
{
dbq
(
"COMMIT"
);
Master
::
Summon
([
'Notifier'
,
'wall-new'
,
$item
[
'id'
]
/* , $post['mid'] trick queueworker de-duplication */
]);
return
true
;
}
dbq
(
"ROLLBACK"
);
}
dbq
(
"COMMIT"
);
return
false
;
}
...
...
include/items.php
View file @
16555b93
...
...
@@ -1834,7 +1834,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
$arr
[
'item_private'
]
=
0
;
if
(
in_array
(
$arr
[
'obj_type'
],
[
'Note'
,
'Answer'
])
&&
$r
[
0
][
'obj_type'
]
===
'Question'
&&
intval
(
$r
[
0
][
'item_wall'
]))
{
Activity
::
update_poll
(
$r
[
0
]
,
$arr
);
Activity
::
update_poll
(
$r
[
0
]
[
'id'
],
$arr
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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