jenkins-bot has submitted this change and it was merged.
Change subject: Optimize draft content loading query
......................................................................
Optimize draft content loading query
The old query was incorrect and caused memory limit to be exceeded
and thus preventing access to many non-small drafts due to
multiplication effect.
For more details see T94402.
Bug: T94402
Change-Id: I1437f37e779888a62578d88f56d47ceb3663c884
---
M includes/Translator.php
1 file changed, 11 insertions(+), 12 deletions(-)
Approvals:
Santhosh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Translator.php b/includes/Translator.php
index 499c057..4f5bd0d 100644
--- a/includes/Translator.php
+++ b/includes/Translator.php
@@ -38,28 +38,27 @@
/**
* Get a translation by translation id for the translator
- * @return Translation
+ * @param int $translationId
+ * @return Translation|null
*/
public function getTranslation( $translationId ) {
$dbr = Database::getConnection( DB_SLAVE );
- $rows = $dbr->select(
- array( 'cx_translations', 'cx_translators', 'cx_drafts'
),
+ $row = $dbr->selectRow(
+ array( 'cx_drafts', 'cx_translators', 'cx_translations'
),
'*',
array(
- 'translator_translation_id' => $translationId,
- 'draft_id' => $translationId,
- 'translator_user_id' => $this->getGlobalUserId()
+ 'translator_user_id' =>
$this->getGlobalUserId(),
+ 'translator_translation_id' => $translationId,
+ 'translator_translation_id = draft_id',
+ 'translator_translation_id = translation_id',
),
__METHOD__
);
- $result = array();
- foreach ( $rows as $row ) {
- $result[] = Translation::newFromRow( $row );
+ if ( $row ) {
+ return Translation::newFromRow( $row );
}
- if ( count( $result ) > 0 ) {
- return $result[0];
- }
+
return null;
}
--
To view, visit https://gerrit.wikimedia.org/r/204224
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1437f37e779888a62578d88f56d47ceb3663c884
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits