Avoid writing to DB if poll-show-results-before-voting has not changed.

Change-Id: Iaec0cc9f3e9af5b35699618f57843722472436af
This commit is contained in:
TehKittyCat 2023-04-22 22:36:59 -04:00
parent 61a25d1dc8
commit eb4c4f8cc7

View file

@ -60,7 +60,7 @@ class AJAXPoll {
$row = $dbw->selectRow(
[ 'ajaxpoll_info' ],
[ 'COUNT(poll_id) AS count' ],
[ 'poll_show_results_before_voting' ],
[ 'poll_id' => $id ],
__METHOD__
);
@ -76,7 +76,7 @@ class AJAXPoll {
$readonly = MediaWikiServices::getInstance()->getReadOnlyMode()->getReason();
if ( !$readonly ) {
if ( empty( $row->count ) ) {
if ( $row === false ) {
$dbw->insert(
'ajaxpoll_info',
[
@ -96,7 +96,7 @@ class AJAXPoll {
// @see https://phabricator.wikimedia.org/T163625
[ 'IGNORE' ]
);
} else {
} elseif ( $row->poll_show_results_before_voting !== $showResultsBeforeVoting ) {
$dbw->update(
'ajaxpoll_info',
[