Brian Wolff has uploaded a new change for review.
https://gerrit.wikimedia.org/r/90769
Change subject: Cache Page content language in Title object.
......................................................................
Cache Page content language in Title object.
During the parsing process, $title->getPageLanguage() gets called
a large number of times for the same title. Appearantly the value
can vary by user, but it should be safe to cache for the current
request (I believe).
On [[Commons:Commons:Featured_picture_candidates/Log/October_2013]],
it appears that this method is called 5118 times, and represents
20.58% (11.77 seconds) of the time to render the page.
Change-Id: I84b2d86c7bcb32997acff47cfea0f789b5b960a6
---
M includes/Title.php
1 file changed, 10 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/69/90769/1
diff --git a/includes/Title.php b/includes/Title.php
index 56e9b44..04fc79d 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -4814,12 +4814,17 @@
return $wgLang;
}
- //TODO: use the LinkCache to cache this! Note that this may
depend on user settings, so the cache should be only per-request.
- //NOTE: ContentHandler::getPageLanguage() may need to load the
content to determine the page language!
- $contentHandler = ContentHandler::getForTitle( $this );
- $pageLang = $contentHandler->getPageLanguage( $this );
+ static $pageLanguageObj = null;
- return wfGetLangObj( $pageLang );
+ if ( !$pageLanguageObj ) {
+ //Note that this may depend on user settings, so the
cache should be only per-request.
+ //NOTE: ContentHandler::getPageLanguage() may need to
load the content to determine the page language!
+ $contentHandler = ContentHandler::getForTitle( $this );
+ $pageLang = $contentHandler->getPageLanguage( $this );
+ $pageLanguageObj = wfGetLangObj( $pageLang );
+ }
+
+ return $pageLanguageObj;
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/90769
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I84b2d86c7bcb32997acff47cfea0f789b5b960a6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits