Commit graph

179 commits

Author SHA1 Message Date
Chad Horohoe
0327a95ea1 (bug 28643) Merge Serbian language variant conversion improvements to trunk (r85224, r85239, r85308) from Nikola's branch 2011-04-21 14:02:38 +00:00
Tim Starling
7bb50c630a The beginnings of HipHop compiled mode support. It works now for parser cache hits.
* Work around HipHop issue 314 (volatile broken) and issue 308 (no compilation detection) by adding some large and ugly compilation detection code to WebStart.php and doMaintenance.php.
* Provide an MW_COMPILED constant which can be used to detect compiled mode throughout the codebase.
* Introduced wfIsHipHop(), which detects either compiled or interpreted mode. Used this to work around unusual eval() return value in eval.php.
* Work around lack of ini_get() in Maintenance.php, by duplicating wfIsHipHop(). 
* In Maintenance::shouldExecute(), accept "include" as an inclusion function name, since all kinds of inclusion give this string in HipHop.
* Introduced new class MWInit, which provides some static functions in the pre-autoloader environment.
* Introduced MWInit::compiledPath(), which provides a relative path for invoking a compiled file, and MWInit::interpretedPath(), which provides an absolute path for interpreting a PHP file. Used these new functions in the appropriate places.
* When we are running compiled code, don't include files which would generate duplicate class, function or constant definitions. Documented the new requirements on the contents of Defines.php and UtfNormalDefines.php.
* In HipHop compiled mode, it's not possible to have executable code in the same file as a class definition. 
  ** Moved MimeMagic initialisation to the constructor.
  ** Moved Namespace.php global variable initialisation to Setup.php.
  ** Moved MemcachedSessions.php initialisation to the caller in GlobalFunctions.php.
  ** Moved Sanitizer.php constants and global variables to static class members. Introduced an accessor function for the attribs regex, as a new place to put code formerly at file level. 
  ** Moved Language.php initialisation of $wgLanguageNames to Language::getLanguageNames(). Removed the global variable, marked "private" since forever.

* In two places: don't use error_log() with type=3 to append to a file, HipHop doesn't support it. Use file_put_contents() with FILE_APPEND instead.
* Work around the terrible breakage of class_exists() by using MWInit::classExists() instead in various places. In WebInstaller::getPageByName(), the class_exists() was marked with a fixme comment already, so I replaced it with an autoloader solution.
2011-04-04 12:59:55 +00:00
Sam Reed
1699e2b185 Use unused $fallback_languages 2011-03-30 12:04:25 +00:00
Jack Phoenix
3b5750adb4 coding style tweaks, doc updates, marked some public functions as such 2011-03-22 20:23:52 +00:00
Ariel Glenn
97533db0b7 ActiveAbstracts needs translate (used in abstracts production for xml dumps, the alternative, autoConvert(), does a lot more work) 2011-03-01 13:36:25 +00:00
Roan Kattouw
af5993f195 Followup r82550: define variables passed by reference to preg_match() beforehand, to prevent E_NOTICEs 2011-02-23 15:54:19 +00:00
Tim Starling
465e50e8e7 Rewrote LanguageConverter::autoConvert() to make it use preg_match() with an offset instead of preg_split(). Reduces memory usage for my test case ([[台灣演員列表]]) to a negligible amount. This should eliminate the most common cause of OOMs on Wikimedia. Produces the exact same output for that test case for the zh -> zh-tw, parser tests pass, seems to work. 2011-02-21 14:17:50 +00:00
Sam Reed
15f4f6f360 Explicitally define some variables
Function documentation
2011-02-18 23:21:48 +00:00
Platonides
7cca433b30 Add missing wfProfileOut 2011-02-10 15:47:43 +00:00
Tim Starling
b7b5b5d3c6 Fix whitespace from r80978 2011-02-07 22:11:27 +00:00
Alexandre Emsenhuber
51c6afc751 * Replaced $wgMessageCache by MessageCache::singleton(); since we only use one instance of this class (as for ParserCache, LinkCache)
* MessageCache::singleton() calls wfGetMessageCacheStorage() directly instead of using $messageMemc, just in case this would be called before that variable is set
* Per TimStarling: also removed deprecated methods in MessageCache class: addMessages() and related, [get|set|enable|disable]Transform(), loadAllMessages(), loadMessageFile() and some others. Same for the legacyData stuff in LocalisationCache that was only used by MessageCache::addMessages() and related. 
* Converted remaining extensions
2011-01-26 15:42:04 +00:00
Philip Tzou
f16d1e4ed7 LanguageConverter::captionConvert(): remove HTML tags and escape HTML special chars to prevent disrupting the layout. 2011-01-25 18:33:21 +00:00
Philip Tzou
6ecb094a23 follow r78679, correct the comment line 2011-01-05 16:44:11 +00:00
Philip Tzou
fa8fb431e7 Fix the bug when a math image was contained by an "<a>" tag, there will be extra markup -{R| and }-.
Since the -{ and }- has been escaped, the Raw (-{R|text}-) markup are no longer needed.
2010-12-21 15:27:23 +00:00
Philip Tzou
e6c51a4143 1. Revert the complicated redirection I made in r59754;
2. Add more Accept-Language XVO cache name for IE;
3. Use hreflang to specify canonical and alternate links, it's search engine friendly
   when a wiki has multiple variant languages.
2010-10-28 16:58:39 +00:00
Sam Reed
6b3b915353 Big attack on unused variables... 2010-10-14 20:53:04 +00:00
Alexandre Emsenhuber
2d078552de * Standardised file description headers
* Added some descriptions
* Added @file where needed
2010-08-20 20:39:04 +00:00
Sam Reed
380b6725d5 Remove some unused variables
Move variable in languages/classes/LanguageKu.php into commented code (used in comment)
2010-08-13 20:58:16 +00:00
Sam Reed
cc218ccc8f Remove some more unused variables 2010-08-13 11:43:01 +00:00
Max Semenik
07760f5799 Follow-up to r64587:
* Use WebRequest::getAcceptLang() instead of home-brewed code (and in LanguageConverter too).
* Refactored that function to use getHeader()
2010-08-02 20:16:36 +00:00
Sam Reed
e476b51e3a Stylize languages/*, languages/classes/*, but not languages/messages/* 2010-07-29 09:43:18 +00:00
Sam Reed
ea08069ec1 1 more dynamic used as static 2010-07-25 21:43:44 +00:00
Philip Tzou
6d351b1df5 Continue to clean up the LanguageConverter.php. 2010-07-07 14:46:27 +00:00
Philip Tzou
4defc6713d * Deprecated convertLinkToAllVariants() since the "{" and "}" are not allowed in titles, the text will get all converted always like autoConvertToAllVariants().
* Removed some redundant code.
2010-07-07 08:59:03 +00:00
Philip Tzou
83496034a8 Clean up LanguageConverter.php. 2010-07-07 08:35:25 +00:00
Philip Tzou
ad88d6e005 Follow up r69081. Use wfEmptyMsg() rather than the ugly comparison. 2010-07-06 07:29:41 +00:00
Philip Tzou
279a29cdc1 1. Fix the underline bug in the title(namespace) conversion, which displayed title like "User_talk:Example".
2. Improve the function of namespace conversion. Allow admins to custom namespace conversion in MediaWiki's messages([[MediaWiki:conversion-nsX]]).
2010-07-06 05:00:15 +00:00
Philip Tzou
5226085154 Bug 24072: The manual conversion of title was taken interferes by other manual conversion rule(s). This patch fixed the problem and add a new test to parserTests.txt to prevent it to reappear again. 2010-07-06 03:06:31 +00:00
Chad Horohoe
44229b50e6 Fixed a bunch of silly instances of [^!=]==\s*(true|false) 2010-06-09 11:44:05 +00:00
Tim Starling
3a2345fe1c Proposed cleanup of recent LanguageConverter-related commits:
* Moved the responsibility for calling $wgOut->setPageTitle() from OutputPage::addParserOutputNoText() to the OutputPage/Parser caller. Previously, every call to $wgOut->addWikiText() (or any other message parsing function) was resulting in the title being reset to a converted version of $wgTitle, producing bug 23124. Moving responsibility to the caller seems to work fairly well, since there are apparently only two callers that really want {{DISPLAYTITLE}} etc. to work (EditPage and Article::view). 
* Reverted data flow obfuscation in OutputPage::setHTMLTitle() from r64851, replaced by the above. The caller decides what overrides what.
* Reverted inappropriate, cache-polluting references to $wgUser and $wgRequest in Parser::parse(), introduced in r64819.
* Reverted incomprehensible boolean parameter to Language::convert() from r64851, reintroduced Language::convertTitle() instead. Gave it a simpler implementation than before.
* Fixed broken {{DISPLAYTITLE}} feature, was being unconditionally overwritten by the ParserOutput::setTitleText() call in Parser::parse(). Give {{DISPLAYTITLE}} precedence over autoconverted title, like we do for -{T|...}-.
* Tested extensively (perhaps not exhaustively)
2010-04-10 13:38:50 +00:00
Philip Tzou
221f00408a Fix bug 23115 again. Follow up r64821, r64823 and r64827. Rewrite the converted title to HTML title if the HTML title haven't set by other messages. 2010-04-10 05:46:01 +00:00
Happy-melon
ae3ced88e5 Make MessageCache::get() return false if the requested message does not exist, and handle setting the '<$key>' one layer further down in wfMsgGetKey(). Allows us to get away from that horrible string comparison in wfEmptyMsg(). 2010-03-25 20:21:31 +00:00
Alexandre Emsenhuber
a73327494e Fixed some doxygen warnings 2010-02-22 21:34:19 +00:00
Alexandre Emsenhuber
1990bd90cf Fixed some doxygen warnings 2010-02-19 17:39:24 +00:00
Tim Starling
750b8f7c04 In LanguageConverter:
* Rewrote convertArray() as an RD parser (with inline tokenizer) as suggested on CR r60986. Fixes unclosed rule issue (with parser test). Fixes O(N^2) timing.
* Removed $this->mMarkup abstraction. Life is complicated enough as it is.
* Replaced a couple of instances of explode() with StringUtils::explode(), limited element count in a couple more.

In ConverterRule:
* Removed mConvTable initialisation from the constructor, unnecessary
* Optimised the "-{xxx}-" tight loop by replacing function calls such as count() and in_array() with language constructs such as isset(). Reduced execution time from 356us to 275us.
* Cached $varsep_pattern for further reduction to 243us.
* A couple more parseFlags() hacks brings it back to 230us.
* Split out $this->mVariantFlags from $this->mFlags. Rearranged flag detection into a foreach/switch to avoid unnecessary isset() calls. 189us.
* Added a special-case optimisation to generateConvTable() for the case where there are no tables defined inline in the article. 116us.
* Fixed bug from r37499: "!R || !N" is always true since they are mutually exclusive, "!R && !N" was intended (with parser test).
* Fixed E_NOTICE from "-{N|foo}-"
2010-01-19 02:36:33 +00:00
Mark A. Hershberger
2800ca2db7 follow up r60832 and follow up r60763
* Don't set Parser::$mTitle to random garbage.
* Remove ParserOutput::$displayTitle, make setDisplayTitle() and
  getDisplayTitle() wrappers for their *TitleText() equivalents.
* Remove Parser::$mDo*Convert member variables, move test for
  $mDoubleUnderScores[] directives closer to the action.
* Remove bogus "global $wgContLang".
* Use accessor to get at $mConvRuleTitle
* Fix up showtitle option in parserTests.inc
* TODO: refactor FakeConverter class away
2010-01-15 19:14:23 +00:00
Philip Tzou
a5d15e09ab follow-up r60986. fix for parser test failed. 2010-01-12 22:02:00 +00:00
Philip Tzou
28ca5b8bb6 1. Add a new feature to LanguageConverter, for supporting nested using of manual convert syntax like "-{-{}-}-".
2. Fixed a little bug find in getURLVariant().
2010-01-12 20:54:26 +00:00
Mark A. Hershberger
f6e2367714 follow up r60961 just test for truth rather than using isset. Found a bug in the process. 2010-01-12 18:35:45 +00:00
Mark A. Hershberger
81f62b6f61 Further logic cleanup on getPreferredVariant & memoization of functions where possible. 2010-01-12 05:31:46 +00:00
Mark A. Hershberger
3b147f876a cleaned up getPreferredVariant() (MUCH easier to follow the logic), found a bug or two 2010-01-11 05:53:39 +00:00
Mark A. Hershberger
934c2bcd50 follow up r60763
Recover the -{T| }- rule.  Add the ability to test for it to the parserTests and add a test for it.  Add a couple of disabled tests that I think demonstrate bugs in the LanguageTranslator
2010-01-08 08:22:19 +00:00
Philip Tzou
339a9a6586 Fix the undefined variable and undefined property notices caused by r60763. 2010-01-07 18:02:33 +00:00
Mark A. Hershberger
857fa9458b follow-up r60763 and r58275. Parser tests now pass. 2010-01-07 05:00:19 +00:00
Mark A. Hershberger
c568220e61 Refactor LanguageConversion so that title conversion isn't so flimsy. Pull MagicWord detection into Parser->doDoubleUnderscore() && remove ParserConvert. 2010-01-07 04:13:14 +00:00
Mark A. Hershberger
dcdc0f4dc7 New tests for LanguageConverter->getPreferredVariant()
Refactor getPreferredVariant, new function getHeaderVariant()
New function (FauxRequest::setHeader()) to help with testing.
2010-01-06 03:50:59 +00:00
Siebrand Mazeland
ebf751d7a3 Follow-up r60650: run stylize.php and remove trailing whitespace 2010-01-05 09:34:42 +00:00
Mark A. Hershberger
dead5afa5b Coding Convention cleanup, removed extraneous references to $_SERVER 2010-01-05 09:07:12 +00:00
Philip Tzou
d16a0c2910 bug 21974, don't return $this->mPreferredVariant if $fromUser = false 2009-12-31 17:14:59 +00:00
Philip Tzou
0a6a24661f follow-up r59522. follow Tim's suggestion to serve same vary and XVO headers for the same URL. Now the vary headers should be consistent. Feel free to test it. 2009-12-21 18:55:42 +00:00