Commit graph

1439 commits

Author SHA1 Message Date
Siebrand Mazeland
5b119a0e44 Replace uses of join() by implode()
All of core uses implode() consistently now.

Change-Id: Iba50898c64c43f356d1caf8869f484e90d9ff651
2016-03-08 18:24:16 +00:00
addshore
fee0afdc8a Move WatchedItem logic to WatchedItemStore
This also removes assumptions that when a page
in one Namespace should be watched / removed
that the page in the talk / subject ns for the
page should have the same action applied

This should maintain all backward compatability
for the WatchedItem class

This also includes tests written by:
 - WMDE-leszek
 - Addshore

Bug: T127956
Change-Id: Iad9abafe4417bb479151a3bfbee6e1c78a3afe3c
2016-03-08 15:41:22 +00:00
Fomafix
757714bf95 Title.php: Support DB language in getPageViewLanguage()
If a page language in database is set then use the current preferred variant
of this language.

Bug: T117667
Change-Id: Idfe1165346ae0068a4b73de441dc9dfa107b8e8b
2016-02-18 17:48:54 +00:00
jenkins-bot
58cb1f824a Merge "Avoid master queries in Title::getLinksFrom()" 2016-02-18 14:31:18 +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
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
d65fc1eb34 Merge "Add 2 FIXMEs about confusingly named functions" 2016-02-14 16:33:26 +00:00
Kaldari
ea6b78909d Add 2 FIXMEs about confusingly named functions
With the roll-out of the Gadget namespace, these are going to be
especially misleading and likely to cause bugs.

Change-Id: I61f1f56762711fab173bbc54d110a7c48604d464
2016-02-12 18:27:36 -06:00
Aaron Schulz
6ce91360c0 Avoid master queries in Title::getLinksFrom()
All callers only hit this case by accident (e.g. limit/offset)

Bug: T92357
Change-Id: I4b5d1b62b2e564b40c65c82cfd4788093d61fc98
2016-02-08 13:41:57 -08:00
addshore
8ddb6a8bbb phpdoc @return MediaWikiTitleCodec in Title::getTitleParser
This will always return a MediaWikiTitleCodec object.
This is called in Title::secureAndSplit which expects
the method splitTitleString which is only in this
implementation and not the interface

Change-Id: Ibb6cdcf7deb6c1080e320379aa58981e9935ca33
2016-02-03 17:26:13 +01:00
jenkins-bot
920c06e42c Merge "Use LinkTarget in TitleValue only methods" 2016-02-03 13:36:59 +00:00
jenkins-bot
9a3a412f86 Merge "Add LinkTarget interface" 2016-02-03 13:23:08 +00:00
addshore
ab66a4427a Use LinkTarget in TitleValue only methods
Change-Id: Iee4b183ae54457d0c6cd3473f9fed3207742b54f
2016-01-29 12:51:52 +01:00
addshore
1c63abcda3 Add LinkTarget interface
To be used by things that do not care if they are
passed a Title or TitleValue so long as it has a
dbkey, namespace, possible fragment and text

Example uses include:
 LinkBatch::addObj
 MediaWikiPageLinkRenderer methods
 MediaWikiTitleCodec methods
 PageLinkRenderer methods
 TitleFormatter methods

Change-Id: I2aa1a82129bb01155924a8e6a403c7a47391432f
2016-01-29 12:48:21 +01:00
This, that and the other
eda82d60c6 Title::newFromText: Cast integers to strings
This is the cause of the T76305 debug log entries relating to SpecialExport
and Echo.

Bug: T76305
Bug: T116034
Change-Id: I64d629d31be79c4b4702a4298bce68fd544df6e8
2016-01-29 10:52:37 +11:00
Fomafix
6f0caa48c6 Title.php: Avoid wfGetLangObj for Language objects
getPageLanguage() from ContentHandler already returns a Language object.
wfGetLangObj is not necessary.

Change-Id: I556236419e445ce549598dd1752b29f619b0ca3c
2016-01-16 15:57:41 +00:00
Aaron Schulz
ec63f72c79 Add AtomicSectionUpdate deferred update class
This makes it easier to have deferred atomic DB transactions

Bug: T122115
Change-Id: I67afe335f03cc21fdce78abdf3f31fa67a368419
2016-01-14 10:32:39 +00:00
Reedy
f684d17b0e Don't call Title::getInternalURL with 2 parameters.
Unnecessary, and causes a deprecated notice

Change-Id: I823b2a037260d3d50a7b074d25d51c11c165d3b8
2016-01-11 12:50:24 +00:00
Florian
77468269af Remove deprecated Title::userIsWatching
Bug: T122754
Change-Id: Ibb895855aa1bf6b9cbbaf68643362ea485e0427c
2016-01-04 18:08:15 +00:00
Bartosz Dziewoński
f0b6b9da04 Title: Fix typo in variable name
Change-Id: I8da1c995f2da2e7a43c70aeadd28b93e5f3e511f
2015-12-22 19:43:43 +00:00
Aaron Schulz
4302b0419d Rename getSquidURLs() => getCdnUrls()
Change-Id: I433acc7990a5fcefd0d2ff5b14ba33dec0424706
2015-12-11 16:40:35 -08:00
Aaron Schulz
6af3c39c07 Replace "squid" with "CDN" in various comments
Change-Id: Idcc528daf28e119349155d36e30a9bcf61b2e7d5
2015-12-09 17:35:37 -08:00
Aaron Schulz
282c5fa9f3 Rename SquidUpdate => CdnCacheUpdate
Squid is not the only possible CDN

Change-Id: Ie2a2955847c5706e630322bbbab71c9d063b378f
2015-12-09 16:31:17 -08:00
Aaron Schulz
afbff42aca Make CDN purge calls use DeferredUpdates
* Using addUpdate() makes sure purges are coalesced and
  de-duplicated.
* Also removed incosistent $wgUseSquid checks. If CDN caching
  is not used, then $wgSquidServers will just be empty anyway.

Bug: T119016
Change-Id: I8b448366f037f668385d252f9d68289b71d1a707
2015-12-04 19:09:03 +00:00
Timo Tijhof
06ba31d267 Title: Convert cache from MapCacheLRU to HashBagOStuff
Change-Id: I0d4c21be1356216970d9ad424ffc848f82778e50
2015-11-09 23:29:19 +00:00
jenkins-bot
2a6d5b5092 Merge "Title: Add warning if newFromText is given non-string/non-null value" 2015-11-05 22:08:35 +00:00
Timo Tijhof
dbd6b4af3f Title: Add warning if newFromText is given non-string/non-null value
Specify null as allowed value to make this method more easy to use.
The method is often used like that already and this makes it official.
Previously we were on a months-long trajectory to try and remove all
instances of passing null, but it was a never-ending quest (with new
ones introduced all the time). And in all cases the added handling
in the caller is the same as the handling for when this method
returns null. Requiring the caller to bounce null makes code more
complex, duplicates logic and serves no reason. Let this method be
a non-throwing validation method that returns null if given null.

Bug: T76305
Change-Id: I47517021471ac6fd6daca6deee039c8047224a33
2015-11-05 19:38:29 +00:00
Bartosz Dziewoński
92c29b8891 Allow passing detailed permission errors data to API
Using the new system introduced in
1c57794e37 (see T47843).

This change allows Title::getUserPermissionsErrors() to include
MessageSpecifiers instead of string message keys in its return value.
This doesn't seem to have any bad effects, and should work seamlessly as
long as callers aren't trying to do anything stupid and just pass the
value to PermissionsError or OutputPage::showPermissionsErrorPage()
or wfMessage() or some such.

If the callers *are* trying something stupid, nothing worse than
duplicated or otherwise less-than-perfect error messages (in code
which tries to handle some message keys specially) should happen.
(I fixed wfMergeErrorArrays(), but who knows what else lurks in all
this code.) Any problems should only affect new-style errors using
MessageSpecifier, though.

Since MessageSpecifiers tend to be stringable, we probably won't get
fatals, but might get incorrect checks. Should we try to log this
happening somehow?

Goes with I42a0c5b0ea7e61088dd609b764dd7d1396c60cd5 in TitleBlacklist.

Bug: T115258
Change-Id: I1334ba21a2862973a9d8ff5be2c9bec06a82698b
2015-11-02 17:11:50 +01:00
Kunal Mehta
8d9e477048 Mark Title::setFragment() as @private
It is deprecated for public use, so indicate that it should only be used
privately.

Change-Id: I1b32f52f427a36ddb81bd7befadc9099ebc4f191
2015-10-14 13:49:43 +00:00
umherirrender
63478e1415 Move the "shit" out
There is no need for such words

Change-Id: I0294c0e2381b96fd4377d7edcdf4d7e7fc0d06d3
2015-10-14 09:26:42 +02:00
Aaron Schulz
c6a4e7c131 Defer execution of HTMLCacheUpdate instances
None of these places need it to happen right now,
so for performance and consistent style, defer
them too.

Change-Id: Id0a2a352bfc04a783c3ebc54b059b241bb6a6f7e
2015-10-06 13:31:31 -07:00
Timo Tijhof
0a3e40aad6 Title: Fix @param for TS_MW to be string instead of int
Follows-up 6b0163391.

Change-Id: I7c45e1968b6ba8db0e5b19b8ca819e6ecc5764c9
2015-10-05 14:39:07 -07:00
jenkins-bot
1569779421 Merge "Update various @params from DatabaseBase to IDatabase" 2015-10-05 19:59:21 +00:00
Thiemo Mättig
56d2a644f7 Add null to @return tags if a method can return null
Change-Id: I420998351663d92c4a101f61842e40591eebcd5f
2015-10-05 17:53:13 +02:00
Aaron Schulz
0f7893f877 Update various @params from DatabaseBase to IDatabase
Change-Id: I98e44cdffb0fc0d729f69f702799139afb988c20
2015-10-05 05:24:29 +00:00
Amir E. Aharoni
ddbba62d03 Make lines short to pass phpcs in 2 files under includes/
Bug: T102614
Change-Id: Iae4d4fbdba88ebcd9bcb018a2a0015d0c0ac607c
2015-09-30 05:20:03 +00:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Thiemo Mättig
afdbf42328 Remove non-existing param PHPDoc tag from Title
Change-Id: Ie05be75b3e1a20e241206fdae8d1496fcbffeaae
2015-09-02 14:50:55 +00:00
jenkins-bot
6b1a173f07 Merge "tiny optimization Title::isValidRedirectTarget()" 2015-07-21 11:11:26 +00:00
Pavel Astakhov
1c97b1fb41 tiny optimization Title::isValidRedirectTarget()
Not special page cannot be invalid redirect target

Change-Id: Ie8cc0c9717963472bdaf5b9d143938bd05bef6ba
2015-07-21 16:47:05 +06:00
jenkins-bot
6c5470467e Merge "Improve serialization of Message, Title" 2015-07-16 19:52:16 +00:00
Brad Jorsch
7782819d64 Improve serialization of Message, Title
This allows them to be stored in the session, for example.

Note that properly serializing a Message requires that all its
parameters be serializable as well; we don't attempt to account for that
here.

Change-Id: I3a42a2a883e8eef900eeb02355fc3b064411f642
2015-07-07 15:56:47 -04:00
Timo Tijhof
c318e3a265 Hygiene: Use strtr() instead of str_replace() for character swapping
strtr() is marginally faster as it runs through the string only
once. A better fit for one-for-one character translation.

The strtr() function also supports an associative array as second
parameter for entire string replacements. This, too, has the same
performance and predictable behaviour (starts with the longest key).
Whereas str_replace is for more aggressive needs where you want
multiple passes until there are no further matches.

The associative array form is arguably also easier to understand
and harder to mess up since the needle/replacement pairs are
explicitly connected instead of two separate arrays.

Also:
* Use getFormattedNsText instead of strtr( getNsText, .. ) which
  reduces duplication of this fact through a more semantic intent.

Change-Id: Ie23e4210a5b6908dd79eebc8a2b931d12fe31af6
2015-07-06 20:25:19 +00:00
Kunal Mehta
5e4a15477e Change "? :" to "?:"
Anomie pointed out that I am the only person who writes it as "? :", and
that all other instances in core use no space.

Change-Id: I01b68eed5f866fa7582fb4257f795c4c2d1244d1
2015-07-01 19:15:07 -07:00
Aaron Schulz
6b0163391b Avoid parser cache miss that often occurs post-save
* This should not happen as doEditContent() saves the parser cache,
  so only the rare casing if incompatible options should have misses
* The bug could also cause post-save misses with edit stashing
* Avoid the second page parse post-redirect by making sure cache
  timestamps match up instead of calling time() at several points
* Likewise for null edits, which used a different code path
* Removed redundant purge in onArticleCreate() as the new row sets _touched
* Removed pointless purge in onArticleDelete() as there is no row to update
  (the method no-ops in that case to avoid contention already)

Change-Id: I178fe334a3f8691ffd9452bec30561a0c5d37c6c
2015-06-09 01:01:03 +00:00
daniel
a43af3bc0e Reset Title cache when importing titles.
WikiImporter now uses NaiveImportTitleFactory, which in turn uses Title::makeTitleSafe,
bypassing the internal title cache. To avoid (potentially cached) Title objects obtained
via Title::newFromText getting out of sync, WikiImporter now clears the title
cache in addition to clearing the LinkCache.

NOTE: a test for this is provided by I2be12fa7d439b.

Bug: T89307
Change-Id: Ib50c48d4797fc21c62090c0be69e87f7e7d07428
2015-05-24 17:55:08 +02:00
Alex Monk
448c7ea03a Log callers that trigger Title::newFromText $text type warning
Follows-up Ic85d27d79, Ibedc31659. See T76305.

Change-Id: I8245744a9291d221f4e9302bb83db328a24f115f
2015-05-17 22:25:21 +00:00
Matthew Flaschen
ba03c0139a Support Title::GAID_FOR_UPDATE for Title->exists
Without this, you have to call:

getArticleID( Title::GAID_FOR_UPDATE )

then either use that directly (bypassing the TitleExists hook) or
call exists afterwards.

Change-Id: Ieec5579e4de2a289795364e7001028932535e435
2015-05-05 03:13:26 +00:00
jenkins-bot
e788bf54c7 Merge "Provide detailed information about invalid titles" 2015-05-04 17:26:03 +00:00
Bartosz Dziewoński
708918ccbf Provide detailed information about invalid titles
includes/Title.php
* The private method Title::secureAndSplit() now throws a
  MalformedTitleException instead of returning false on invalid
  titles.
* Added Title::newFromTextThrow(), which behaves exactly like
  Title::newFromText() but throws MalformedTitleException instead of
  returning null on invalid titles.

includes/title/MediaWikiTitleCodec.php
* Provide more information with the thrown MalformedTitleExceptions.

includes/MediaWiki.php
* Use the new Title::newFromTextThrow() to get detailed error
  information, display it.

Change-Id: I4da8ecb457a77473e32d745ba48ab8505b35e45f
2015-04-30 23:50:07 +02:00