Commit graph

1395 commits

Author SHA1 Message Date
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
Florianschmidtwelzow
0eeed48cc9 Remove throws from Title::getContentModel()
ContentHandler::getDefaultModelFor() always returns a contentmodel,
so this exception is never thrown.

Change-Id: I7678964f229da8fcd15eb49e9e8c8e9a258e35a1
2015-04-27 11:51:53 +02:00
Aaron Schulz
14979be39d Moved $wgShowUpdatedMarker checks to the right place
Change-Id: Icee2ec24aac5fe78f7204aabf434640251791cae
2015-04-14 18:56:39 -07:00
Aaron Schulz
65b0335134 Removed some code duplication in Title::getNotificationTimestamp
Change-Id: I02114258448c1dec894e51c2d4c84cb2517eccb7
2015-04-14 18:06:04 -07:00
jenkins-bot
6809566094 Merge "Avoid page_restrictions field queries for templates on edit form" 2015-04-15 00:50:31 +00:00
jenkins-bot
dd7df34a22 Merge "Clean up handling of 'infinity'" 2015-04-14 18:57:16 +00:00
Aaron Schulz
5e513509c9 Avoid page_restrictions field queries for templates on edit form
* Title::newFromRow() will actually load page_restrictions, which
  should normally be empty. This avoids queries in getRestrictions().
  Those queries could add 100-200ms to edit form views.
* getLinksFrom() has been simplified to use newFromRow(), thus
  loading the old restrictions in passing.

Change-Id: I225955589a82e4accbf059d17390a5e28e2fa1ca
2015-04-13 23:04:23 +00:00
Niklas Laxström
7ab1858c84 Add second param to Title::newFromText warning so that called from works correctly
Change-Id: Ib977acb9abfcc6e07019013c6f9fc20ece16245d
2015-04-12 15:34:24 +00:00
Alex Monk
156bcbec81 Mostly revert "Verify parameter for MapCacheLRU::has() can be passed to array_key_exists()"
This broke a few things, and the debug line was basically pointless.

Instead, continue to only throw an exception if $text is an object, but only
warn if it's otherwise not a string.

This reverts commit 372ded2fea.

Change-Id: I060da9191cdbd00c4873caba875bfb77c917bcd7
2015-04-07 02:08:11 +00:00
Mark A. Hershberger
372ded2fea Verify parameter for MapCacheLRU::has() can be passed to array_key_exists()
This prevents warnings from PHP from array_key_exists().

Also make sure Title::newFromText throws an exception before it can trigger this.

Bug: T76305
Change-Id: I2b36b7a3b96b37e29fe06f69c13a185b3ec592a7
2015-03-23 15:26:59 -07:00
jenkins-bot
badc035712 Merge "Drop outdated "documentation reviewed" tags" 2015-03-18 16:56:58 +00:00
Thiemo Mättig
40342aba58 Drop outdated "documentation reviewed" tags
We review documentation all the time. Even if this was a big, notable
review, it was 5 years ago. It's probably outdated again, e.g. because
methods changed but the corresponting documentaion did not. In my
opinion the fact that a review happened 5 years ago is not useful any
more.

Change-Id: I6f4fb88ea790520bf2443aae4144cdde394b5e78
2015-03-18 17:43:01 +01:00
Brad Jorsch
ac6f81d9ad Clean up handling of 'infinity'
There's a bunch of stuff that probably only works because the database
representation of infinity is actually 'infinity' on all databases
besides Oracle, and Oracle in general isn't maintained.

Generally, we should probably use 'infinity' everywhere except where
directly dealing with the database.

* Many extension callers of Language::formatExpiry() with $format !==
  true are assuming it'll return 'infinity', none are checking for
  $db->getInfinity().
* And Language::formatExpiry() would choke if passed 'infinity', despite
  callers doing this.
* And Language::formatExpiry() could be more useful for the API if we
  can override the string returned for infinity.
* As for core, Title is using Language::formatExpiry() with TS_MW which
  is going to be changing anyway. Extension callers mostly don't exist.
* Block already normalizes its mExpiry field (and ->getExpiry()),
  but some stuff is comparing it with $db->getInfinity() anyway. A few
  external users set mExpiry to $db->getInfinity(), but this is mostly
  because SpecialBlock::parseExpiryInput() returns $db->getInfinity()
  while most callers (including all extensions) are assuming 'infinity'.
* And for that matter, Block should use $db->decodeExpiry() instead of
  manually doing it, once we make that safe to call with 'infinity' for
  all the extensions passing $db->getInfinity() to Block's contructor.
* WikiPage::doUpdateRestrictions() and some of its callers are using
  $db->getInfinity(), when all the inserts using that value are using
  $db->encodeExpiry() which will convert 'infinity'.

This also cleans up a slave-lag issue I noticed in ApiBlock while
testing.

Bug: T92550
Change-Id: I5eb68c1fb6029da8289276ecf7c81330575029ef
2015-03-13 11:19:53 -04:00
Timo Tijhof
840d01d05d Title: Consider empty edit notices to not exist
Don't include edit notices that parse to nothing in the output
array.

Similar filtering logic currently exists in VisualEditor. This
helps support systems like the one on English Wikipedia where an
Editnotice page may exist, but conditionally outputs the actual
notice.

Bug: T91715
Change-Id: Ic8fb038fd6acf18830cafdd09a8ca86f3950c7a5
2015-03-12 21:15:43 +01:00
Timo Tijhof
3bfe4eca3f Title: Clean up getEditNotices()
Change-Id: I4ad5e16dfe42494ee6d8c43cfc50ae57e2b9a2d4
2015-03-12 21:12:30 +01:00
Aaron Schulz
5085a4b5cf Made wfFindFile/wfLocalFile callers use explicit "latest" flags
* Callers that should not use caches won't
* Aliased the old "bypassCache" param to "latest"

bug: T89184
Change-Id: I9f79e5942ced4ae13ba4de0b4c62908cc746e777
2015-03-06 04:18:50 +00:00
Aaron Schulz
52724de028 Made EditPage avoid querying the master block table on form view
* Refactored getUserPermissionsErrors "expensive" checks flag to be
  a bit more general.

bug: T51419
Change-Id: Ic1882aa2957eed2b978761b5fc34ea9bdd8981b5
2015-02-16 22:52:23 +00:00
Aaron Schulz
477a5bf658 Do not call purgeExpiredRestrictions on simple page views
* Also cleaned up the on-the-fly expiry check.

bug: T88445
Change-Id: I0f601df978cc7cdd0a0b7861d39e59dae9bdda00
2015-02-11 05:24:04 +00:00
Kunal Mehta
978fc13da2 Check $auth parameter in Title::isValidMoveOperation()
This also includes the integration test from SemanticMediaWiki that
caught this issue.

Bug: T74870
Change-Id: I699e14958ee36ec5e86278e5dc0caed2a015d9af
2015-02-05 10:52:10 -08:00
Kevin Israel
50c9bbfbd5 Title: Always add title to LinkCache when necessary (in 3 methods)
Unless Title::GAID_FOR_UPDATE is specified, Title::getArticleID() will not
use the link cache if the Title already has the ID of the page. Account for
this by directly calling LinkCache::addLinkObj() in three other methods of
Title: getContentModel(), isRedirect(), and getLength().

Follows-up r33008 (aed9d4b912) and dd5c1b7fb7, and reapplies part of
388b14a15d.

Bug: T86974
Change-Id: I7eff0bffd4f632ceb8d2124af317d684dbcaf2cb
2015-01-23 12:19:32 -08:00
Kevin Israel
65f81d2843 Use DatabaseBase::selectRowCount() in two more places
Change-Id: Ic6e03a96c03499f7d62539f12e677b4407def673
2015-01-21 21:05:44 -05:00
Ricordisamoa
4ece7f53aa Revision: mark getRaw*() methods as deprecated
Revision->getRawUser()
=> Revision->getUser( Revision::RAW )

   Revision->getRawUserText()
=> Revision->getUserText( Revision::RAW )

   Revision->getRawComment()
=> Revision->getComment( Revision::RAW )

The body of Revision->getRawUserText() has been moved
into Revision->getUserText().
Every usage has been replaced.

Change-Id: Ic6fbfbc0507dcf88072fcb2a2e2364ae1436dce7
2015-01-18 06:57:56 +01:00
jenkins-bot
4d78d40d82 Merge "Surround edit notices with appropriate classes" 2015-01-11 13:25:49 +00:00
Ricordisamoa
2ae155da52 Fix phpcs errors in includes/
Mostly Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines

Change-Id: I678b2f0902f11cd1dfa1611b9da24e7237df9122
2015-01-08 20:15:07 +01:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08:00
Marius Hoch
28f9d1c546 Make use of DatabaseBase::selectRowCount in Title
Change-Id: I686f4f785ffa6323ac94b679794ba50539d951f0
2015-01-04 17:08:24 +00:00
Evan McIntire
7fd9739c9c Moved getTitleInvalidRegex() from Title to MediaWikiTitleCodec
Deprecated it in Title, and updated all current references to use the
non-deprecated version in MediaWikiTitleCodec

Change-Id: I2b9c36992028c97f695f2b95ba027fbb11904b57
2014-12-31 11:29:36 +00:00
jenkins-bot
a300fabb68 Merge "Add and use Title::getOtherPage()" 2014-12-25 15:22:36 +00:00
kaldari
bdaca5751d Explaining why user groups are sometimes returned by getRestrictions
Title::getRestrictions is assumed to return user rights, but in most
real contexts it actually returns user groups. This is super
confusing and has caused serious permission bugs. Adding an
explanation to the function comments.

Change-Id: I58013ba5e553d1feecacf6bfef066e1569fcc236
2014-12-14 11:12:47 +00:00
jenkins-bot
68644e2d34 Merge "Remove obsolete note from Title->canExist()" 2014-12-12 17:33:27 +00:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
Ricordisamoa
f86a5590aa Always use 'bool' instead of 'boolean' after '@param' and '@return'
The former is by far the most common.

Skipped:
* resources/lib/jquery.ui/jquery.ui.datepicker.js
* resources/src/mediawiki.special/mediawiki.special.upload.js

Change-Id: I73c93797e745128ba703e4865080c36784caa474
2014-12-10 11:57:31 +00:00
Ricordisamoa
c2b916d69b Remove obsolete note from Title->canExist()
A bit of history:
* when added by Aaron Schulz with commit
  df1f744757, the method made use of
  a hardcoded `0`;
* Lisa Ridley noted that with
  commit bc1023ac89 by adding
  "uses hardcoded namespace index instead of constants";
* Max Semenik changed `0` to `NS_MAIN`, thus making the comment
  obsolete, with commit a35fe1f5f2.

Change-Id: I0c2dad773219da80cc4db04ad6a8007a03207e5c
2014-12-09 19:30:48 +00:00
Kunal Mehta
24c000ea80 Add and use Title::getOtherPage()
Change-Id: I40a51c14ce07c301c15c6c2128cc18bb12e71103
2014-12-04 17:45:05 -08:00
Timo Tijhof
00f7c07c02 content: Deprecate TitleIsCssOrJsPage and TitleIsWikitextPage hooks
They're currently documented as a 'compatibility hook'
in docs/contenthandler.txt. No longer used in any Wikimedia-hosted
git repository.

Superseded by the ContentHandlerDefaultModelFor hook.

Change-Id: I212230da7d6080cf500f930d4aa5a9024959d5f9
2014-12-03 04:11:33 +00:00
Brad Jorsch
b27e460b26 Make Title::makeTitleSafe() not need user variant
In trying to avoid hitting RequestContext::getLanguage() from a call to
User::idFromName(), I05aacd30 made it no longer safe for user input.

A closer analysis of the call stack involved reveals that
Title::makeTitleSafe() is constructing a prefixed dbkey using the
localized name for NS_USER, and then Language::getNsIndex() is needing
to get the variant in order to handle that localized name. But if we use
the canonical name for NS_USER, Language::getNsIndex() short-circuits
and skips the problematic code path.

And it turns out that it doesn't actually matter which prefix
Title::makeTitleSafe() uses, since the prefix doesn't make it anywhere
into the resulting Title object. So let's revert I05aacd30 and Ibeef0409
and just do that instead.

Change-Id: Ib902573996c69d1e77527cc7b2faf4e7fa5d3daf
2014-11-19 18:22:32 +00:00
Kunal Mehta
ac53e45035 Fully replace Title::moveTo() with MovePage
* AbortMove hook is removed in favor of two more specificly focused
  hooks: MovePageCheckPermissions and MovePageIsValidMove.
** MovePageIsValidMove is for extensions to specify whether a page
   cannot be moved for technical reasons, and should not be
   overridden.
** MovePageCheckPermissions is for checking whether the given user
   is allowed to make the move.

* Title::moveNoAuth() deprecated
* Title::moveTo() deprecated
* Title::isValidMoveOperation() broken down into
  MovePage::isValidMove() and MovePage::checkPermissions().

* Title::getTitleProtection() is now public, and returns
  unprefixed fields

Change-Id: Ic5026384b92a0d68d628397ffe1de6e5b6183f02
2014-10-28 12:52:36 -07:00
Chad Horohoe
6c30fff0ba Swap and for &&
Change-Id: I7821a62586cc2d2f929fb3d7d5046958a70efbd0
2014-10-23 13:03:14 -07:00
Marius Hoch
e57a60dad1 Only link local titles on Special:Search
Anything else is confusing, especially given the message text
we have there.

Example:
https://www.mediawiki.org/wiki/Special:Search?search=en%3Afoo&fulltext=1

Also fix the documentation of Title::isLocal as that was misleading
and fooled me (in PS1).

Change-Id: Iccb69de4c7243bf144a12deb8b86505e56a111dd
2014-10-20 03:25:48 +02:00
Kunal Mehta
39fffcedb0 Move non-user specific things from Title::isValidMoveOperation() to MovePage
Change-Id: Ieffeb0c7a15b202dcbdaf2a9d0b9bcdc10e360d2
2014-09-19 20:11:59 +00:00
jenkins-bot
7e6420a764 Merge "Add TitleExists hook" 2014-09-17 17:11:29 +00:00
Jackmcbarn
c15616690e Add TitleExists hook
Bug: 70495
Change-Id: I4f9a04d09ff8c4bdda678a591aea7f1153cb0a40
2014-09-15 18:46:25 -04:00
Kunal Mehta
52f1d0d7b3 MovePage::move(): Return a Status object
Change-Id: I17e6f6d36ae2052bd09d21eb94546d94bda9bce9
2014-09-14 19:31:38 -07:00
Kunal Mehta
77698193f9 Start moving page move logic out of Title
This moves most of the Title::moveTo() function into a new MovePage
class, and the entirety of the Title::moveToInternal() function.

No actual code was changed except for requiring a User object in
function arguments instead of relying up on $wgUser, and changes
to "$this" as necessary.

Change-Id: I5479fa8f3920a51ddf789d55edae7dd0d9b24382
2014-09-14 19:29:53 -07:00
Bartosz Dziewoński
e0ff770ade Update categorylinks.cl_type when moving a page
cl_type might need to be changed if the page was moved between
special-cased namespaces (Category ↔ File ↔ (other)).

Also update cl_collation, which also might have changed in the
meantime.

Bug: 69740
Change-Id: I46032a8ba04d77005731c02680f77a8808974087
2014-09-15 00:17:02 +00:00