From: Aryeh Gregor Date: Mon, 6 Aug 2018 16:54:04 +0000 (+0300) Subject: Do not return invalid hash from ApiStashEdit X-Git-Tag: 1.34.0-rc.0~4549^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=6380cadedc572056c16179a402de4a92b3300212;p=lhc%2Fweb%2Fwiklou.git Do not return invalid hash from ApiStashEdit If we were rate-limited, we don't store a new hash, so we shouldn't return a new one. If we received a hash from the client, however, that should still be valid, so we can return it. Change-Id: Ifc37ae044172b8838fee15d539b076a0d0f02f22 --- diff --git a/includes/api/ApiStashEdit.php b/includes/api/ApiStashEdit.php index bf956dcbec..e8318c2d3e 100644 --- a/includes/api/ApiStashEdit.php +++ b/includes/api/ApiStashEdit.php @@ -151,14 +151,13 @@ class ApiStashEdit extends ApiBase { $stats = MediaWikiServices::getInstance()->getStatsdDataFactory(); $stats->increment( "editstash.cache_stores.$status" ); - $this->getResult()->addValue( - null, - $this->getModuleName(), - [ - 'status' => $status, - 'texthash' => $textHash - ] - ); + $ret = [ 'status' => $status ]; + // If we were rate-limited, we still return the pre-existing valid hash if one was passed + if ( $status !== 'ratelimited' || $params['stashedtexthash'] !== null ) { + $ret['texthash'] = $textHash; + } + + $this->getResult()->addValue( null, $this->getModuleName(), $ret ); } /**