Commit graph

423 commits

Author SHA1 Message Date
Kunal Mehta
303b4057f9 LinkBatch: Set visibility and document constructor
Change-Id: I9d8edeb214b9d7507826004e470dcb5c1ef015f6
2016-09-08 22:02:39 -07:00
Aaron Schulz
8ebec93fea Cache NS_TEMPLATE/NS_FILE titles in LinkCache persistently
Queries from parsing are the top use of selectRow() according
to reverse flame graphs on xenon. This does not bother with
pages in namespaces less likely to be included.

Change-Id: Ica5d6e52c830cd71effff21933b8c64691082c11
2016-09-07 00:20:26 -07:00
Timo Tijhof
b2585a95b2 filecache: Remove unused ObjectFileCache class
This was originally intended for use by ResourceLoader but it was
incomplete and not actually used by ResourceLoader at first.

Then 93d358cd added support for FileCache to ResourceLoader with
a separate ResourceFileCache class.

Also fixed typo in HTMLFileCache from 6559b8bf.

ObjectFileCache is not mentioned anywhere else in Wikimedia Git.

Change-Id: I69cca27ee7cd922da12f1793660432709c273be6
2016-09-06 17:09:50 -07:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07:00
Aaron Schulz
16266edff3 Change "slave" => "replica DB" in /includes
Change-Id: Icb716219c9335ff8fa447b1733d04b71d9712bf9
2016-09-05 21:01:01 +00:00
Amir Sarabadani
efa0d7af44 Clean up array() syntax in docs, part III
Also fixing some typos here and there

Change-Id: I29c29acf87f84ba9993ba75ebf2ad8091d981574
2016-08-13 05:40:40 +04:30
Aaron Schulz
017c9169e8 Unbreak file caching
This was totally broken by 796d62d0

Change-Id: I34ee08e926117b9472151d9fd415c1dfc6a57de1
2016-07-29 20:03:24 -07:00
Erik Bernhardson
4aca0ce803 Fix reference to undefined class
This error class was moved into wikimedia/cldr-plural-rule-parser
project, but in the conversion process this exception was not
converted over.

Change-Id: I36a2466a89e2ed6f0b98b45fcb945b6fdf56fbcf
2016-06-30 14:39:50 -07:00
Aaron Schulz
9b3f2165a1 Avoid exceptions for empty titles in addResultToCache() for sanity
Bug: T137083
Change-Id: Ie8aabba30bc0d7a6910a58104ff08ea036ba962d
2016-06-06 10:03:20 -07:00
Bartosz Dziewoński
8e38519e07 LinkBatch: Cast array keys to string when constructing TitleValue
If $dbkey consisted only of numbers (0-9), PHP converts it to an
integer when using it as array key, and then returns it as an integer
when iterating over the array. This is normally fine, but TitleValue
does strict type checking.

Follow-up to 6821167601.

Bug: T136615
Change-Id: I894800c3f5aec0c2d0c23f8adfa1b840495f3b16
2016-06-01 22:12:59 +02:00
Kunal Mehta
6821167601 LinkBatch: Use TitleValue instead of Title
Replace the remaining instances of Title with TitleValue, and use
services from MediaWikiServices instead of calling deprecated singleton
functions.

Change-Id: I5d13939a76380fff6b787cea8d4a5f90c1a31a5d
2016-05-26 14:47:45 -07:00
Kunal Mehta
a50a2731cb LinkCache: Don't try looking up NS_SPECIAL
Change-Id: I1afe8c780c3b12ae806ac19c4efb37c7033951ca
2016-05-26 14:47:45 -07:00
jenkins-bot
67a97fced6 Merge "Language: Introduce new method equals( Language $lang )" 2016-05-23 16:03:50 +00:00
daniel
fc1d4d7960 Fix installer issues introduces by MediaWikiServices
This fixes three issues with the installer:

1) Make sure LocalizationCache can find the installer's i18n files.
2) Make sure we don't try to use an SqlBagOStuff for caching before we have
   a functioning database.
3) Don't try to output HTML when redirecting (this is unrelated to
   MediaWikiServices, but came up during testing)

Bug: T135169
Change-Id: I7caa932024cd771d6fa226a3ac6001c3148ecc9c
2016-05-17 15:24:31 +00:00
Fomafix
796d62d034 Language: Introduce new method equals( Language $lang )
Use

 $lang->equals( $wgContLang )

instead of

 $lang->getCode() === $wgContLang->getCode()

Change-Id: Id7ed6a21ce5e2ea2887ec98c7bd9d3eba83d733b
2016-05-16 22:33:33 +00:00
Kunal Mehta
e8e2cc0ffc Add LinkCache::getSelectFields() and use it in a few places
Change-Id: Ic65b20cc2aa41f9b481e280918fe95c57da53221
2016-05-13 00:25:07 -07:00
Kunal Mehta
ef2a84e108 Remove now-unused LinkCache::$instance
Follows-up 449084ec4.

Change-Id: Ia43344beba0f1e5f98210d0e4e51e53e138495d1
2016-05-12 16:05:19 -07:00
Kunal Mehta
449084ec4e Add LinkCache to MediaWikiServices
LinkCache::singleton() is now deprecated, and the destroySingleton() and
setSingleton() methods were removed. They were not used in extensions,
and the usage in core was updated to use MediaWikiServices.

Change-Id: I08bb4f7913b03f71331ff683d0197c948aad6790
2016-05-12 15:44:33 -07:00
Kunal Mehta
f77cbc02b1 LinkCache: Use LinkTarget instead of Title
Change-Id: I9ed5a095fc50334a3c41fd52f6d05611dadbaf68
2016-05-12 11:36:54 -07:00
addshore
b85d9f3363 Make GenderCache use MediaWikiServices
Change-Id: Id20310f78d938bdfa4d29ae483bb1a33bacd2b51
2016-05-07 13:26:26 +01:00
Kunal Mehta
cfea4137e9 LinkCache: Clarify in doc comments what format $title is
Sometimes $title is a Title object, sometimes it is the prefixed DB key
as a string.

Change-Id: I0e574f35f0c3193bc933e77250c42765626d3cbf
2016-04-27 14:34:18 -07:00
Kunal Mehta
07d4c17da3 LinkCache: Remove unncessary & from singleton() function
Change-Id: I9e9e530a59d7b9062d0214ba82146b313e6b10fd
2016-04-27 14:30:54 -07:00
Kunal Mehta
288e9d2280 LinkCache: Make clearBadLink() only clear that link
Calling clear() empties all of mBadLinks instead of the one that was
requested.

Change-Id: Iec7f7845704dd5742b5bdf4aff05678194e08054
2016-04-26 14:42:47 -07:00
jenkins-bot
47e2941bcd Merge "Namespace LinkTarget under MediaWiki\Linker" 2016-04-24 12:31:13 +00:00
Kunal Mehta
c9d885f3b4 Namespace LinkTarget under MediaWiki\Linker
And add a GPL file header while we're at it.

Change-Id: I15a6f240124c879b21fb655ade1baaebf4f34ffd
2016-04-21 17:19:10 -07:00
Aaron Schulz
2cafd151de Make MessageCache handle lock timeouts better
* Timeouts happen when memcached is cleared or on DC-switchover likewise
* Disable the sidebar cache when the MessageCache is disabled
* Also lower any output expiry for CDN and set a custom header
  when the MessageCache is disabled
* Log when this happens to a dedicated "MessageCacheError" channel

Bug: T133069
Bug: T7092
Change-Id: I1b80e250532033c52680246279e1e8f56350ae83
2016-04-21 13:18:29 +00:00
Adrian Heine
89a64f20bb Reduce code duplication in MessageCache
Change-Id: I3432958c8f81b7a33079b7933e85b87ced7363fa
2016-04-12 10:26:08 +02:00
addshore
2ac621beb7 Remove usages of CdbCompat class alises
Change-Id: Id7223689f135c3ce3e4193f8c724b52d3f39dfd5
2016-04-03 12:20:00 +03:00
addshore
b8ca311a1c Split LocalisationCache.php classes into own files
Change-Id: I1b88081e6b082fcad73990550a3ffbf58e11d97e
2016-03-24 11:00:44 +00:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
Brad Jorsch
7c543bb6c2 Allow passing a language into Status::getWikiText() etc.
This also corrects a bug in MessageCache::parse() where it takes a
language code string but the Parser expects a Language object in
ParserOptions.

Bug: T128809
Change-Id: I3508c9e515e505890b3c62bc4a0982aa2a313782
2016-03-09 22:35:19 +00:00
jenkins-bot
3071f1fad7 Merge "Revert "Add type hint against LinkTarget"" 2016-02-29 23:58:59 +00:00
Brian Wolff
74ac95c0cc Revert "Add type hint against LinkTarget"
Can cause fatal if your database has invalid titles
stored in it (Title::makeTitleSafe is fed to $lb->addObj()
without checking that the result is non-null)

This reverts commit 0e5a1f8879.

Change-Id: I4174b2fdcc3d8e24ecf0bcc39cd0f0f2e8bfd6b2
2016-02-29 23:31:48 +00:00
jenkins-bot
40a628a501 Merge "Add type hint against LinkTarget" 2016-02-26 18:13:14 +00:00
Leszek Manicki
0e5a1f8879 Add type hint against LinkTarget
A follow up to I132f254536a7516e878e20ad49d2f415796c4490

Change-Id: I74bff64e86ea95cecddf504e532543aa74b79775
2016-02-25 18:21:02 +01:00
Niklas Laxström
5b33f0fca1 Allow ­ in messages
Bug: T127062
Change-Id: I8b89d8fd6f688a2fa60f3bd92e4cea6909ed267f
2016-02-17 12:45:36 +01: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
Florian
d237380021 Fix not-loaded DbPageLanguage when Title::getPageLanguage() get's called
If the Title object isn't the title of the current viewed WikiPage, the page_lang
field of the database isn't requested. This results in the problem, that
Title::getPageLanguage() always returns the default content language, even if
the page language is different (changed with Special:PageLanguage, if
wgPageLanguageUseDB is true). That is problematic for the Translate extension,
which relies on the correct page language.

This change makes sure, that getPageLanguage() always return the correct page
language. If the page language isn't loaded already, Title::getPageLanguage()
now does a database lookup (if $wgPageLanguageUseDB is true) to get the correct
page language. It will use LinkCache for the page_lang field.

Bug: T121666
Change-Id: I0ae5ea39f7a124ed427ca5dfb26c1a116b27a94e
2016-02-16 20:37:40 +00:00
jenkins-bot
87d3bd7afc Merge "Use LinkTarget in LinkBatch::addObj" 2016-02-11 03:49:50 +00:00
Brad Jorsch
35c38ce319 Add User::isSafeToLoad() and ParserOptions::newFromAnon()
Useful for avoiding "User::loadFromSession called before the end of
Setup.php".

Bug: T124367
Change-Id: I0b018a623fc833ca95d249ee21667a8f5690d50e
2016-02-03 21:45:56 +00:00
Brad Jorsch
2257fe4228 Revert "Remove SessionManager, temporarily"
This reverts commit 823db5d63dd5200d04c63da50ba6bf16f928e70b.

Change-Id: Ibb3e023e4eb6715295586dea87d0725c344a8271
2016-02-03 21:44:59 +00:00
addshore
cc425ece7b Use LinkTarget in LinkBatch::addObj
Change-Id: I132f254536a7516e878e20ad49d2f415796c4490
2016-02-03 16:17:38 +01:00
Brad Jorsch
5083e810eb Remove SessionManager, temporarily
The plan here is to take it out of 1.27.0-wmf.12 and put it back in
1.27.0-wmf.13.

Since BotPasswords depends on SessionManager, that's getting temporarily
removed too.

This reverts the following commits:
* 6acd424e0d SessionManager: Notify AuthPlugin before calling hooks
* 4d1ad32d8a Close a loophole in CookieSessionProvider
* fcdd643a46 SessionManager: Don't save non-persisted sessions to backend storage
* 058aec4c76 MessageCache: Don't get a ParserOptions for $wgUser before the end of Setup.php
* b5c0c03bb7 SessionManager: Save user name to metadata even if the user doesn't exist locally
* 13f2f09a19 SECURITY: Fix User::setToken() call on User::newSystemUser
* 305bc75b27 SessionManager: Don't generate user tokens when checking the tokens
* 7c4bd85d21 RequestContext::exportSession() should only export persisted session IDs
* 296ccfd4a9 SessionManager: Save 'persisted' flag in session metadata
* 94ba53f677 Move CSRF token handling into MediaWiki\Session\Session
* 46a565d6b0 Avoid false "added in both Session and $_SESSION" when value is null
* c00d0b5d94 Log backtrace for "User::loadFromSession called before the end of Setup.php"
* 4eeff5b559 Use $wgSecureCookie to decide whether to actually mark secure cookies as 'secure'
* 7491b52f70 Call session_cache_limiter() before starting a session
* 2c34aeea72 SessionManager: Abstract forceHTTPS cookie setting
* 9aa53627a5 Ignore auth cookies with value 'deleted'
* 43f904b51a SessionManager: Kill getPersistedSessionId()
* 50c5256352 SessionManager: Add SessionBackend::setProviderMetadata()
* f640d40315 SessionManager: Notify AuthPlugin when auto-creating accounts
* 70b05d1ac1 Add checks of $wgEnableBotPasswords in more places
* bfed32eb78 Do not raise a PHP warning when session write fails
* 722a7331ad Only check LoggedOut timestamp on the user loaded from session
* 4f5057b84b SessionManager: Change behavior of getSessionById()
* 66e82e614e Fix typo in [[MediaWiki:Botpasswords-editexisting/en]]
* f9fd9516d9 Add "bot passwords"
* d7716f1df0 Add missing argument for wfDebugLog
* a73c5b7395 Add SessionManager

Change-Id: I2389a8133e25ab929e9f27f41fa9a05df8147a50
2016-02-01 22:06:49 +00:00
Brad Jorsch
058aec4c76 MessageCache: Don't get a ParserOptions for $wgUser before the end of Setup.php
Until Setup.php completes, we can't access the "current" user and trying
to do so logs a warning. So don't try.

Bug: T124367
Change-Id: If31230407829c04f34d9cfefcbb97edacb949b6d
2016-01-29 14:30:25 -05:00
addshore
8f4ce04107 LinkBatch::addObj can also work with TitleValue objs
Change-Id: I035d38a5eb8299fcce9cc0efa3952e391b325722
2016-01-26 20:04:28 +01:00
Bryan Davis
0affda7edf Remove use of $dest = 'log' for wfDebugLog
The functionality for marking a debug log message for delivery to a log
file but not to MWDebug was removed in 1.25 with the introduction of
the PSR-3 logging system. Convert the messages that were marked for this
special handling in a7a0883 to use 'private' instead.

Bug: T122644
Change-Id: Iefaac07a5922c16c2899904c7b678199c5b1efe9
2015-12-30 13:03:14 -07:00
jenkins-bot
ea9fcc1e4d Merge "Merge namespace aliases like we merge namespace names" 2015-12-17 19:03:48 +00:00
This, that and the other
1783ae651c Merge namespace aliases like we merge namespace names
To avoid problems like T60074 and deal with requests like T101634.

Bug: T108427
Change-Id: I3ef6bbcc820a254b44ba86bfccb3854983a19ff6
2015-12-15 16:53:28 +11:00
Timo Tijhof
8326c1f860 resourceloader: Avoid using 'message' in log message key
This overrides the message being sent. Use 'messageKey' instead,
which complements 'cacheKey' used elsewhere in the class.

Change-Id: I70b1115853d16e5f1357dc5f3d10e46f9c029fc6
2015-12-10 01:33:25 +00:00
Timo Tijhof
5d5b269e0e resourceloader: Migrate from msg_resource table to object cache
MessageBlobStore class:
* Make logger aware.
* Log an error if json encoding fails.
* Stop using the DB table. WANObjectCache supports everything we need:
  - Batch retrieval.
  - Invalidate keys with wildcard selects or cascading check keys.
* Update tests slightly since the actual update now happens on-demand as
  part of get() instead of within updateMessage().

ResourceLoader class:
* Remove all interaction with the msg_resource table. Remove db table later.
* Refactor code to use a hash of the blob instead of a timestamp.
  Timestamps are unreliable and roll over too frequently for message blob store
  because there is no authoritative source. The timestamps were inferred based on
  when a change is observed. Message overrides from the local wiki have an
  explicit update event when the page is edited. All other messages, such as
  from MediaWiki core and extensions using LocalisationCache, have a single
  timestamp for all messages which rolls over every time the cache is rebuilt.
  A hash is deterministic, and won't cause needless invalidation (T102578).
* Remove redundant pre-fetching in makeModuleResponse().
  This is already done by preloadModuleInfo() in respond().
* Don't bother storing and retreiving empty "{}" objects.
  Instead, detect whether a module's message list is empty at runtime.

ResourceLoaderModule class:
* Make logger aware.
* Log if a module's message blob was not preloaded.

cleanupRemovedModules:
* Now that blobs have a TTL, there's no need to prune old entries.

Bug: T113092
Bug: T92357
Change-Id: Id8c26f41a82597e34013f95294cdc3971a4f52ae
2015-12-08 14:02:38 +00:00