Commit graph

60 commits

Author SHA1 Message Date
Brad Jorsch
37ed022c25 Add StubObject::unstub, and use it for $wgAuth->getUserInstance()
PHP's __call magic method can't handle functions with reference
parameters correctly,[1] which means that we need to manually unstub
StubObjects before calling such a method. Or you could use call-time
pass by reference with call_user_func_array, which is rather backwards
and verbose.

This change adds a convenience function to do this, and applies it to
the two calls which brought it to my attention.

[1]: https://bugs.php.net/bug.php?id=40694,
https://bugs.php.net/bug.php?id=62455

Change-Id: I74a0c04bf358e164f753b82fbefbd6205d9b2451
2013-09-11 13:11:20 -07:00
umherirrender
15ff79312d Fixed spacing and removed unneeded parenthesis
Added spaces after/before parenthesis
Removed unneeded parenthesis around some statements
Broke a long line

Change-Id: I7fbe129f7bbf524dd0598ece2a9708643f08453b
2013-05-17 16:12:08 +00:00
umherirrender
978bb31c5e Add missing wfProfileOut before throwing an exception
Change-Id: I1d830da0597f19efd0b2ae48642389975e736e23
2013-04-08 18:37:24 +00:00
Yuri Astrakhan
9506e3d812 Spellchecked /includes directory
* Ran spell-checker over code comments in /includes/
* A few spellchecking fixes for wfDebug() calls

Found one very strange (NOOP?) line in Linker.php - see "TODO: BUG?"

Change-Id: Ibb86b51073b980eda9ecce2cf0b8dd33f058adbf
2013-03-13 03:42:41 -04:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
umherirrender
1044b0b8df fix some spacing
Change-Id: I8f976013f33c5818e4402604fe8610aa3f43b0c6
2013-02-04 20:18:33 +00:00
Siebrand Mazeland
d4b046a893 Update docs for return and exception info
* Removed some inline tabs in the process.
* IDE fixed some incorrect leading spaces, too.

Change-Id: Ic9303eff6db4424ac3f1fa2816839692b43e6190
2012-10-09 09:41:58 +00:00
Alexandre Emsenhuber
bc9d9f1f9c Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent and removed a duplicate comment from SpecialPageFactory.php in SpecialPage.php.

Change-Id: I99dd2de7fe461f2fad4e0bd315ebc2899958a90f
2012-05-10 17:51:44 +02:00
Sam Reed
09a78c1368 More return documentation 2012-02-09 21:36:14 +00:00
Jeroen De Dauw
0b105ebf1d added missing deprecation notices 2011-12-13 19:51:03 +00:00
John Du Hart
216d661d3b Bug 29524 - Rename RequestContext::getLang to getLanguage
I'll be amazed if this doens't break any tests.
2011-11-21 16:13:21 +00:00
Sam Reed
62491fef13 Comments, braces, explicit member variables
Remove a couple of unused variables
2011-11-16 13:22:03 +00:00
Sam Reed
96641da58e Add, update, tweak documentation
Fix document comment blocks

Tweak some returns
2011-10-26 03:44:47 +00:00
Alexandre Emsenhuber
cb1c884d6f Fix for r89474: added missing () to function call 2011-06-04 20:28:59 +00:00
Platonides
72214fa718 Follow up r89408. Magic >lang to getLang(). 2011-06-04 20:12:21 +00:00
Brion Vibber
94c04f7cd1 Provisional revert of r89406, r89414: reference-related warnings need cleanup before applying code like this
Per CR http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89406#c17545 :
'Here is a third one: Strict Standards: Only variables should be passed by reference in /www/sandwiki/includes/Wiki.php on line 177 '

Offending bit is this:
-			SpecialPageFactory::executePath( $this->context->title, $this->context );
+			SpecialPageFactory::executePath( $this->getTitle(), $this->getContext() );

That function demands reference paramters for $title and $context, which is being violated here where we now pass function return values:

public static function executePath( Title &$title, RequestContext &$context, $including = false ) {

The $title does sometimes get replaced within the function body, but $context does not appear to ever be replaced (its *contents* are modified, which does not require passing by reference)
If replacing it is something it should be doing, then we need to be able to replace it upstream presumably, so $this->getTitle() probably isn't appropriate.
The $context probably should have the reference simply removed.
2011-06-03 18:48:59 +00:00
Happy-melon
23bb7c3ba6 Follow-up r89406 CR: another use of RequestContext::__get() 2011-06-03 14:36:06 +00:00
Happy-melon
21813a563c Follow-up r86775: restub $wgLang. Not because it's a good idea, but because I can't see how to avoid the circular dependencies on it *without* stubbing it. Probably easier to just continue the drive to deprecate the global variable altogether. 2011-04-24 10:50:51 +00:00
Happy-melon
c80535ae10 Stop stubbing $wgLang and $wgContLang. There are no major code paths which do not call either $wgLang or $wgContLang at least once. All index.php calls unstub $wgContLang from MediaWiki::parseTitle() except in the edgecase of viewing pages referenced only by "curid=123", and since those will end up calling OutputPage::output() they will eventually be unstubbed at some point as well. All calls through load.php unstub $wgLang in ResourceLoaderContext::getLanguage() from ResouceLoader::respond() --> ResourceLoader::preloadModuleInfo(). All calls through api.php unstub $wgContLang in ApiResult::cleanUpUTF8() from ApiMain::printResult(). 2011-04-23 15:19:38 +00:00
Daniel Friesen
9f81e60c64 Followup r85278, remove duplication of userlang code. 2011-04-03 23:56:15 +00:00
Happy-melon
4a0500a514 Follow-up to r85240:
* Don't stub RequestContext.  The chances of us getting away without needing to access *any* of the six major globals is nil, and in the meantime it's screwing up strong function typing and throwing catchable fatals everywhere.  

* Stop stubbing $wgOut.  The only path where we can avoid unstubbing it is if we immediately die due to maxlag overflow, and that's a) a pretty uncommon code path, and b) a DB issue which won't be affected by a tiny bit of extra apache load.  That allows us to do strong typing on function parameters with it, which is a Good Thing (TM).

Also make OutputPage::getContext() private; I'm not convinced that a context belongs here (it's *part of* the context, not a consumer of it), let's work through it a it more before we advertise its existence.
2011-04-03 20:40:27 +00:00
Daniel Friesen
c08158368c Implement the RequestContext class. Some credit to IAlex, ;) other credit for me and that plethora of bugs and hicoughs I had to deal with in impelenting it.
http://www.mediawiki.org/wiki/Requests_for_comment/Context_object (it's little different though)
2011-04-03 10:41:14 +00:00
Alexandre Emsenhuber
d9c46a0939 * Added UserGetLanguageObject hook to change the language used in $wgLang 2011-03-06 21:05:18 +00:00
Tim Starling
63394d63f5 (bug 27094) fix path traversal vulnerability 2011-02-01 22:43:58 +00:00
X!
1d0ac4a481 Move wfCreateObject to MWFunction::newObj. This uses the ReflectionClass to
instantiate a variable-length constructor in php 5.1.3 and up, and falls
back to the old, ugly, manual method that was in the old wfCreateObject
function. The instances in the core have been replaced.
2011-01-03 02:10:05 +00:00
Sam Reed
e76775e06f More unused variables 2010-11-30 18:44:50 +00:00
Platonides
537826a674 Remove $wgContLanguageCode usage in core.
sed -i 's/$wgContLanguageCode/$wgLanguageCode/g'
These are now the same, always. Per and since r15827.

$wgLanguageCode wins due to being the one set by LocalSettings.

$wgContLanguageCode definition at includes/Setup.php kept for now.
2010-09-07 22:37:55 +00:00
Chad Horohoe
985e8971c8 Get rid of StubUser. Constructing a user object isn't quite as intensive as it once was. It actually takes more time using the StubUser (construction + unstub on first call) than just initializing User::newFromSession() from the start. Either way, the real overhead starts when you start calling methods (for the nitpicky, the optimization was only about 20µs. The real gain here was eliminating a StubObject) 2010-08-12 17:10:00 +00:00
Alexandre Emsenhuber
a582793590 Fixed some doxygen warnings 2010-03-28 20:21:30 +00:00
Tim Starling
0603c609e3 Fixes for r51204: removed useless $wgVariant and StubUserVariant. In Skin::makeGlobalVariablesScript(), use $wgContLang->getPreferredVariant() instead, which is the variant used in the relevant server-side code. 2009-09-02 07:19:35 +00:00
Niklas Laxström
72a3e109d9 (bug 20090) BCP 47 issues 2009-08-14 15:41:48 +00:00
Andrew Garrett
ac774b60ea If an object has already been unstubbed (i.e. we have a copy of the StubObject, which has since been unstubbed but the copy not updated), then return the already-unstubbed object instead of unstubbing it again 2009-08-06 16:11:12 +00:00
Shinjiman
648bfbabc0 * (bug 10837) Introducing the StubUserVariant class to determine the variant variable instead of using this to overrules the user language preference. 2009-05-30 19:49:51 +00:00
Purodha B Blissenbach
56c2036f1e Bugfis, making ?uselang=qqq an invalid language code, see
https://bugzilla.wikimedia.org/show_bug.cgi?id=17445
2009-02-11 11:56:01 +00:00
Chad Horohoe
7e8f748bd2 Minor tweak in debug output. Makes much more readible (and per most other debug statements that mention the calling method), since -> gets turned to -> in the debug comments. 2008-11-04 02:04:53 +00:00
Robert Stojnić
0ce3c66acd Fix regreesion in r37662, disabled conversion when interface language variant is different that main wiki language variant. 2008-07-15 16:49:57 +00:00
Robert Stojnić
098cfc3c3b * (bug 10837) Language variants overrides languages other than the variant main language.
Explicitely forbid conversion when interface language is different than the main content language.
2008-07-14 21:32:13 +00:00
Tim Starling
8ae900c46b DB schema change.
In CentralAuth (and related changes interface changes in Newuserlog and the core):

* Moved the AutoAuthenticate hook to User::loadFromSession(), to defer processing for longer and avoid unstub loops
* Undeprecated User::setID()
* Added partial support for new user log registration and IP-based blocking of automatically created accounts. Still needs the same support implemented in Special:Userlogin.
* Fixed all inappropriate uses of the term "DB name", changing them to "wiki" or "wiki ID". Renamed the relevant database fields.
* Refactored central session and cache support
2008-05-14 00:35:14 +00:00
Siebrand Mazeland
79d5225c0e * remove end of line whitespace
* remove empty lines at end of file
* remove "?>" where still present
2008-04-14 07:45:50 +00:00
Alexandre Emsenhuber
2a46b1b8c3 Typo, thanks to nikerabbit for reporting it :) 2008-04-08 19:52:19 +00:00
Alexandre Emsenhuber
6a96aeb291 Document a bit. 2008-04-08 18:52:57 +00:00
Tim Starling
98611cdd4e Revert r31022 -- breaks commons upload hack. 2008-02-22 11:49:13 +00:00
Victor Vasiliev
b8ec8a526c * (bug 13010) Invalid language codes should fallback to default wiki language not English
Patch by Alexandre Emsenhuber
2008-02-17 15:36:52 +00:00
Niklas Laxström
e96e7ba96c * Reverting r28802 until I can figure what is going on 2007-12-24 13:14:25 +00:00
Niklas Laxström
fc30ace0b5 * Use variant only if interface language === content language
* (bug 10837) Interface "variant" overruling "language" preference
2007-12-23 18:00:54 +00:00
Aryeh Gregor
a15c419b3d Remove ?>'s from files. They're pointless, and just asking for people to mess with the files and add trailing whitespace. (Yes, I looked over every one and reverted those that were bogus. Slash-enter a million times in less worked well enough, although it was a bit mind-numbing.) 2007-06-29 01:19:14 +00:00
Tim Starling
dc7a748b8a Fix language code validation regex to allow be-x-old. 2007-04-02 17:49:12 +00:00
Antoine Musso
f78e9c549f Fix r19896 for bug 8944 (pressing 'u' in vim before committing is a bad idea). 2007-02-12 20:22:34 +00:00
Antoine Musso
70a270421a Fix #8944: The deprecated is_a() function is used in StubObjects.php 2007-02-12 20:18:05 +00:00
Antoine Musso
171945efed User::getOption now accept a default value to override default user values
this makes it consistent with WebRequest::get* methods. Corrected code in
various places accordingly.
2006-12-14 20:28:38 +00:00