Mwalker has submitted this change and it was merged.
Change subject: Add getKeys optimization to BannerMessageGroup
......................................................................
Add getKeys optimization to BannerMessageGroup
This avoids the wfMessage calls to load message content.
Bug: 53769
Bug: 53792
Change-Id: I14cdda777e3a70cda78d2f52d59b6ad569619571
---
M includes/BannerMessageGroup.php
1 file changed, 27 insertions(+), 0 deletions(-)
Approvals:
Mwalker: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/BannerMessageGroup.php b/includes/BannerMessageGroup.php
index 38c13c8..50e941d 100644
--- a/includes/BannerMessageGroup.php
+++ b/includes/BannerMessageGroup.php
@@ -32,6 +32,33 @@
}
/**
+ * This is optimized version of getDefinitions that only returns
+ * message keys to speed up message index creation.
+ * @return array
+ */
+ public function getKeys() {
+ $keys = array();
+
+ $banner = Banner::fromName( $this->bannerName );
+ $fields = $banner->extractMessageFields();
+
+ // The MediaWiki page name convention for messages is the same
as the
+ // convention for banners themselves, except that it doesn't
include
+ // the 'template' designation.
+ if ( $this->namespace == NS_CN_BANNER ) {
+ $msgKeyPrefix = $this->bannerName . '-';
+ } else {
+ $msgKeyPrefix = "Centralnotice-{$this->bannerName}-";
+ }
+
+ foreach ( array_keys( $fields ) as $msgName ) {
+ $keys[] = $msgKeyPrefix . $msgName;
+ }
+
+ return $keys;
+ }
+
+ /**
* Fetch the messages for the banner
* @return array Array of message keys with definitions.
*/
--
To view, visit https://gerrit.wikimedia.org/r/83827
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I14cdda777e3a70cda78d2f52d59b6ad569619571
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
Gerrit-Reviewer: Mwalker <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits