Commit graph

45 commits

Author SHA1 Message Date
Aaron Schulz
dcd0a3d534 Add isCurrentWikiId()/isCurrentWikiDomain()/getCurrentWikiDomain() to WikiMap
Use these in place of various wfWikiID() calls.

Also cleanup UserRightsProxy wiki ID variable names and removed unused
and poorly named getDBname() method.

Change-Id: Ib28889663989382d845511f8d34712b08317f60e
2018-10-29 14:53:37 -07:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Aaron Schulz
a005f1de98 Clean up wiki ID and DB domain ID handling
Bug: T174017
Change-Id: I42299a393c6691d39817db1d83a176a17df2474b
2017-09-30 10:25:03 +00:00
Aaron Schulz
15cb57b3b5 Avoid preemptive DB replication waits for farm cross-wiki redirects
This previously only worked if $wgLocalVirtualHosts was set, which
was too specific to check and not used by WMF. Use the more generic
WikiMap class.

Two methods have been added there to do the work of enumerating
canonical wiki farm URLs and checking them against a given URL.

Bug: T172357
Change-Id: Id2415bab5d7f5a08b9f536858c32d329138384a2
2017-08-23 15:37:35 -07:00
Kunal Mehta
d1cf48a397 build: Update mediawiki/mediawiki-codesniffer to 0.10.1
And auto-fix all errors.

The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.

Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
2017-07-22 18:24:09 -07:00
Reedy
e86a6310f7 Move some more classes to comply with class per file
Change-Id: Ibecea848fcca24709847931f5e02a7c981c4d277
2017-05-21 13:23:31 +01:00
Fomafix
464f0c72a5 Remove multiple spaces in PHP files
Change-Id: Id9c26ec5ca730a9536f8fdccb8853eb03cbe87a4
2017-04-12 17:27:19 +02:00
Erik Bernhardson
d67197fa11 Cleanup some incorrect return annotations
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.

Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.

This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.

Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
2016-12-12 10:15:05 -08:00
Brad Jorsch
010410265a Improve WikiMap::getWikiReferenceFromWgConf()
If we don't have a valid canonical server and path to pass, there's no
point in returning a WikiReference that will fail in strange and unusal
ways.

This also documents that $wgServer/$wgCanonicalServer and $wgArticlePath
are required in SiteConfiguration.

Change-Id: Ib08011e9f1d0817a5d1bb165aba6b424785eaa6a
2016-07-06 14:20:07 -04:00
daniel
eb46307b00 Introduce top level service locator.
The service locator, MediaWikiServices, is intended to facilitate
"manual" dependency injection in static entry points.

See also the Dependency Injection RFC T384 and Service Locator
RFC T124792 for details.
The following key points were implemented according the
discussion surrounding these RFCs:

* a configurable DI container that allows extensions to add and replace services.
* no auto-wiring, since it's prone to add confusion in large and complex applications.
* no 3rd party framework, since they typically do too much.

The following services in MediaWiki core are made accessible via the service locator
mechanism to showcase the bootstrapping mechanism:

* ConfigFactory and MainConfig
* SiteLookup and SiteStore

However, the implementation of these services was not yet converted to using proper DI
throughout the code.

Bug: T124792
Change-Id: I3c25c0ac17300d3dd13e1cf5100558a605eee15f
2016-04-02 18:07:28 +03:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Marius Hoch
3d85fde609 Make WikiMap fall back to sites if a site couldn't be found using $wgConf
The mapping is not very good, but should be good enough, given
that only the URL parts are really being used.

Bug: T114107
Change-Id: I8186140aed5620cf7b4ba84aa4c9492c61f406d0
2015-10-07 14:59:31 +02:00
Marius Hoch
725a203bc1 Remove unused minor and major in WikiReference
Given that the class is not constructed anywhere outside
of core the constructor can be altered without having to
worry about b/c.

Change-Id: Ie49c43a1724f05cb95a296dc0fad0f1c587d80ef
2015-10-01 19:12:07 +02:00
Amir E. Aharoni
9f4c895190 Make lines short to pass phpcs in files under includes/
Bug: T102614
Change-Id: I33ac3f4bb8116020ccda5d64fdd2924e78810546
2015-09-27 16:10:59 +00:00
daniel
50ff1eaec3 Remove WikiReference::getHostname.
getHostname() was broken and seems to be unused.

Change-Id: I8d44a6907ad395ea12deebf404831c06e07ed401
2015-09-14 18:41:13 +00:00
daniel
5852451177 Add support for fragments to WikiMap
WikiMap::makeForeignUrl should support fragement IDs in the
generated URL.

Change-Id: I612d5f465822b56356a78b3e72fb441a888668f1
2015-09-11 16:25:53 +02:00
Ricordisamoa
12dec5d85d Fix some stuttering in comments and documentation
Change-Id: I9c0088b9aab37335203cad45a1d6fa8ac3f43321
2014-12-17 19:44:10 +00:00
umherirrender
a3983418d5 Fixed some @params documentation (includes/*)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I0056b4a8df243cfc0c5f25378de48f7a35170aca
2014-04-22 13:07:02 +02:00
Ladsgroup
1ba0445c12 Changing URLs of mediawiki.org in scripts to the SSL-based website
http://www.mediawiki.org --> https://www.mediawiki.org

Part 2

Change-Id: I3be61fe3dfb502cc20180486eb1a8016eac151df
2014-03-12 23:24:03 +00:00
Tim Starling
f70c572bf2 In $wgConf, allow wgCanonicalServer to be false or absent
According to the doc comment, $wgCanonicalServer can be false, and this
is equivalent to it being set to $wgServer. So don't require it to be
set for foreign wikis in $wgConf, just use the same interpretation.

This makes it slightly easier to set up CentralAuth test servers.

Change-Id: I5eb11669236ed2a71d08f53a1393a3d5e8f5f770
2013-07-04 05:50:57 +00:00
umherirrender
ef2f507d23 Fixed spacing in files direct in includes folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b
2013-04-21 06:38:49 +00:00
umherirrender
15abcf71ca Added/Removed spaces around string concatenation
And added/removed spaces around some other tokens,
like +, -, *, /, <, >, =, !

Fixed windows newline style

Change-Id: I0b9c8c408f3f6bfc0d685a074d7ec468fb848fc8
2013-04-13 13:36:24 +02:00
Alexandre Emsenhuber
df5265e14d Fix case of some Title methods
Change-Id: I37ce7fe392f4941c500fa0a88007664501d7e338
2013-03-27 14:36:05 +01:00
umherirrender
6c278b6d7e fix some spacing
* Removed spaces around array index
* Removed double spaces or added spaces to begin or end of function
  calls, method signature, conditions or foreachs
* Added braces to one-line ifs
* Changed multi line conditions to one line conditions
* Realigned some arrays

Change-Id: Ia04d2a99d663b07101013c2d53b3b2e872fd9cc3
2013-03-25 22:22:46 +00: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
Derk-Jan Hartman
dbc563169b (bug 31644) [MERGE DEPENDENCY] Let WikiMap url builders return full urls instead of canonical urls
* This commit depends on a commit of globalusage https://gerrit.wikimedia.org/r/17117
* This allows GlobalUsage, CentralAuth and AbuseLog extensions to use protocol relative URLs.

Change-Id: I7e65bd029f359c36770aa48e6663f26a671b92c0
2012-07-31 23:17:12 +02:00
Reedy
c5e154664d Add getCanonicalServer to WikiMap
Change-Id: I9473034ced524ea3d0b3ea9e4166b173653f58c4
2012-07-13 10:02:00 +00:00
Alexandre Emsenhuber
2040d1337e Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: Ib46e50da4ec649a6a06cbeed00752effb79ed06e
2012-05-09 20:11:36 +02:00
Sam Reed
f3cc77aaee Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 17:41:50 +00:00
Sam Reed
6906724935 Add, update, tweak documentation
Fix document comment blocks

Tweak some returns
2011-10-26 03:45:13 +00:00
Roan Kattouw
a4c0941213 (bug 31320) CentralAuth uses http URLs for autologin images when logging in over https.
Renamed WikiReference::getUrl() to getCanonicalUrl() (but kept the old name as a back compat alias), and added getFullUrl() which returns a URL built using $wgServer rather than $wgCanonicalServer, which means it'll be protocol-relative if the wiki is configured for that.
2011-10-03 10:27:23 +00:00
Alexandre Emsenhuber
5f62872f13 Don't use isset() to check for null 2011-09-17 19:09:13 +00:00
Roan Kattouw
e6fca5c816 In WikiMap, pull wgCanonicalServer from $wgConf instead of wgServer for building URLs to foreign wikis. This means wgCanonicalServer is now expected to always be available in wgConf; document this in RELEASE-NOTES (-1.18 because this is for backporting). 2011-08-29 08:55:35 +00:00
Roan Kattouw
d0d89f4297 Instead of using some hacky regexes, just use wfParseUrl() in WikiMap::getDisplayName(). This should make protocol-relative URLs behave correctly as well, and fix bug 29965 2011-08-12 19:19:34 +00:00
Alexandre Emsenhuber
ed4a147637 Call Linker::link() statically instead of getting a Skin object from $wgUser 2011-07-01 08:24:32 +00:00
Siebrand Mazeland
75c6696aa8 Use consistent notation for "@todo FIXME". Should update http://svn.wikimedia.org/doc/todo.html nicely. 2011-05-17 22:03:20 +00:00
Sam Reed
ecf56c33fa Braces and spaces 2010-09-04 03:43:33 +00:00
Sam Reed
04f68827d0 Removal of unused globals
Removal of one setting of a variable to '', then not using further
2010-07-24 19:11:52 +00:00
Bryan Tong Minh
e505a59df7 Fix undefined variable 2010-01-22 21:37:29 +00:00
Alexandre Emsenhuber
5fc268d803 document a bit 2010-01-12 21:49:47 +00:00
Alexandre Emsenhuber
586be1e1eb * (bug 9794) User rights log entries for foreign user now links to the foreign user's page if possible 2010-01-09 15:23:27 +00:00
Andrew Garrett
af184614e5 Phase 1 in fixing up SiteConfiguration: Replace the hack of including InitialiseSettings.php with a generic system for loading full configuration data, involving a callback. 2009-06-02 09:49:31 +00:00
Andrew Garrett
6a91f0640c Move WikiMap class from CentralAuth to core, since it's used in 2 extensions at least now, and doesn't depend on CentralAuth 2009-03-26 13:31:30 +00:00