Commit graph

1265 commits

Author SHA1 Message Date
umherirrender
2e871f7087 Fixed spacing
- Removed double spaces in arrays
- Added space after for
- Added spaces around string concat

Change-Id: Ifbcaf35f9bfef1f97226a38b5bd74c237f61c99e
2013-12-15 20:56:09 +01:00
Brian Wolff
1bddb65c2e Always give sane output for Title::getUserCaseDBkey()
Sometimes (e.g. via Title::makeTitle), the usercase db key is
not set. If that happens we should fallback to the normal db key.

This fixes file redirects on repos where initialCapital is set
to false.

Change-Id: I38bc4ebeb41b06f5c718cf5f64da158e6c1a9f49
2013-12-11 16:06:57 -07:00
umherirrender
c42684cca9 Make a single colon an invalid title in php and js
When secureAndSplit gets a single colon as input, the leading colon
is stripped and produces a title with a empty string. This change makes
that impossible by moving the empty string check to after the substring
removal of the colon.

Bug: 54044
Change-Id: I574168c9ed281c535901c36dea7c179a4e794d20
2013-12-06 17:44:43 +00:00
Siebrand Mazeland
01d41a7ccb Add more type hints in comments for static code analysis
This resolves a little over 100 "undefined method" warnings on
includes/filerepo/.

Change-Id: I87b6d875a4304d7beadfbc26a66e9a3f358707e6
2013-12-06 00:23:05 +01:00
umherirrender
0bc583af2c Move closing parenthesis from multi line if and function to own line
The Line continuation Coding conventions prefers the closing parenthesis
on the same line than the beginning curly braces. This is done for ifs
and functions.
Also move some boolean operator from the end of a line to the beginning
and changed some indentation to make the condition hopefully better
readable.

Change-Id: Id0437b06bde86eb5a75bc59eefa19e7edb624426
2013-12-01 21:39:00 +01:00
umherirrender
f153998317 Fixed spacing
- Removed double spaces
- Added space after if/switch/foreach
- Removed space on elseif
- Added space around parentheses
- Added newline at end of file
- Removed space before semicolon at end of line

Change-Id: Id40b87e04786c6111e6686d7f7eea1e588bdf37d
2013-11-19 19:03:54 +01:00
Siebrand Mazeland
f8f3ddea50 Update docs to reduce inconsistent type compatibility in api/
Change-Id: Iaf97aeb514ddb2176491c3820fe891be8e989939
2013-11-17 21:47:51 +00:00
jenkins-bot
a36b3c44ed Merge "Cache page content language in Title object" 2013-11-07 01:43:00 +00:00
Brian Wolff
8f4f9404ce Cache page content language in Title object
During the parsing process, $title->getPageLanguage() gets called
a large number of times for the same title. Apparently the value
can vary by user, but it should be safe to cache for the current
request (I believe).

On [[Commons:Commons:Featured_picture_candidates/Log/October_2013]],
it appears that this method is called 5118 times, and represents
20.58% (11.77 seconds) of the time to render the page.

Also checks if $wgLanguageCode has been changed, since Title
object are cached during a request, and the unit tests seem
to change $wgLanguageCode/$wgContLang while still using
the Title cache.

Bug: 55952
Change-Id: I84b2d86c7bcb32997acff47cfea0f789b5b960a6
2013-10-27 20:18:20 -03:00
Brad Jorsch
6e4a46c315 Add $wgSemiprotectedRestrictionLevels
It's possible that a wiki could introduce new protection levels that
should be considered "semiprotected". For example, if an
"emailconfirmed" protection level were added and an appropriate entry
were made in $wgAutopromote, that might be considered semi-protection
since anyone can automatically gain the ability to edit those pages
merely by setting and confirming their email address.

The most straightforward way to take care of this is to add a config
variable to specify which protection levels are considered
"semiprotected". So let's do that.

Also, let's take the opportunity to make
$title->isSemiProtected( 'create' ) works correctly.

Bug: 43462
Change-Id: Ic9db6ff6cbd84bd9734be09efbea5a5891197fa0
2013-10-23 23:19:25 +00:00
umherirrender
bc8f309bda Clean up old title on move before reset article id
Calling WikiPage::onArticleDelete without a page_id will reload the
page id, maybe from a (lagged) slave, than the title has the page id
set, and a call to Title::exists return true, which shows the link in
blue and the wrong message.

Bug: 45348
Change-Id: If415dc1729b0bb1cfe7fc75f9e29638a6797d478
2013-10-20 17:34:24 +00:00
jenkins-bot
8115ec8685 Merge "Allow appending text to redirects from moved pages" 2013-10-04 14:57:57 +00:00
Jackmcbarn
528590ccec Allow appending text to redirects from moved pages
Add message move-redirect-text, which is appended to redirects created by
page moves (empty by default). This could be used on enwiki to automatically
add {{R from move}} while still allowing non-admins to revert the move, for
example.

Change-Id: Ic2158897ce46177b695a7fb90c8ed3349df18bde
2013-10-04 10:40:47 -04:00
Timo Tijhof
4894793ab6 mw.Title: Rewrite from scratch (porting logic from Title.php)
Changes:

* Add support for fragments.

* Use wgLegalTitleChars instead of the old clean() method
  that stripped out characters instead of throwing an exception.

* Implemented various other parts of Title.php to make it more
  strict like Title.php. It is still slightly looser, but it
  now takes care of the following that Title.php did already:
  - Directory patterns ("../" etc.)
  - Extra initial colons
  - Titles in NS_TALK that don't round-trip to NS_MAIN
  - 3 or more consecutive tildes
  - Limited title size (255 bytes)

* Extracted parsing logic into a private static #parse method
  and introduced mw.Title.newFromText (a constructor that returns
  null|Title instead of throwing an exception).

* Extended test suite to cover the added features and fixed bugs.

* Since the PHP test suite was lacking these, added them there
  as well.

Bug fixes:

* Fragments are now excluded from the title instead of causing
  the input to be invalid or malformed (e.g. "Foo#bar" was being
  normalised to "Foo_bar").

* ".com" now parses and round-trips properly. The extension and
  rest of title are still separated, but only at the very end
  after all other processing, so though title cannot be empty,
  since we only do a lazy split afterwards, it will split into
  title="", ext="com" internally and join back together when
  needed (bug 38081).

* "Example.js " (trailing space after extension) was previously
  incorrectly parsed as title=Example.js,ext=null.

* "Foo    bar" (multiple consecutive spaces) was transformed
  into 1 space correctly, but "Foo___bar" was not. This has been
  fixed to match the PHP implementation (it merges underscores
  and whitespace of any kind).

Clean up:

* Removed various redundant private helper methods.

* Removed fixNsId as getNsIdByName uses wgNamespaceIds which
  always yields a valid value. The fixNsId was verifying
  something that was already valid.

* Yoda conditional in Title.php, got rid of.

* Use newFromText in jquery.byteLimit.test. It was previously
  using a very basic invalid test (=== '') and no try-catch.
  Since we're getting more strict, typing 'User:' results in
  an invalid title, which should result in the same behaviour
  as it previously did for the lazy === '' check.

Bug: 38081
Change-Id: Ief1c11dabadc2f822065c40be91e04d655933e4f
2013-10-01 23:38:53 +02:00
Timo Tijhof
dc9c9ee7fc Title: Add byte class to unicode class conversion for js
The upcoming rewrite of mw.Title needs to use wgLegalTitleChars,
but for that to work, it needs to be converted into something
that can work in javascript.

Signed-off-by: Timo Tijhof <krinklemail@gmail.com>
Signed-off-by: David Chan <david@sheetmusic.org.uk>
Change-Id: I163f3d7e3a680d52640a93f4bd195d8209669918
2013-09-27 19:21:14 +02:00
jenkins-bot
73c6a7e4dc Merge "Add TitleMove hook" 2013-09-17 15:52:27 +00:00
Jan Gerber
386ba287d7 Add TitleMove hook
some things need access to the old file before its moved,
adding hook to allow extensions to do something before
file is moved.

Change-Id: Ic5e659abc79c41e3331d42074e7f21eec9b9ba7c
2013-09-17 08:07:17 +00:00
umherirrender
d8c1083e04 Always pass user to LogPage::addEntry
This avoids getting $wgUser in LogPage::addEntry

Change-Id: Ie105cef4ebc3d69aeaef5ee40ce6ee0087a74c69
2013-09-13 21:14:36 +02:00
Liangent
dd841c2a56 Don't use $wgVariantArticlePath for variants of non-content languages
Currently PathRouter understands variants of $wgContLang only, and it
wouldn't be easy to extend it to variants of the given title because at
the time of preparing PathRouter for parsing, the title is unknown yet.

Bug: 52852
Bug: 52850
Change-Id: I7dcf7dc73e36945e420a66d99329c09c75b17882
2013-08-14 16:04:51 +00:00
Roan Kattouw
6bf642d80a Add a hook to Title::getEditNotices() so extensions can add them
FlaggedRevs will have to use this to expose its edit notices to
VisualEditor.

Also add an $oldid parameter so edit notices can be generated based
on the revision ID being edited.

Change-Id: Ie44a01ebfa7002fa3a89f081e0f831442666ac03
2013-07-23 17:31:27 -07:00
Platonides
86825162c6 Remove unused globals.
Change-Id: Icde0bbfcfe5e560a3db0ccb8020b9c9a27f4fba3
2013-07-12 20:25:14 +02:00
Brad Jorsch
76623e75da Add User::isEveryoneAllowed function
User::groupHasPermission is used for various purposes, from checking
whether it makes sense to show a "hide logged-in users" on
Special:NewPages to showing different error messages in some places when
'user' or 'autoconfirmed' is allowed the action to avoiding unstubbing
$wgUser to check $wgUser->isAllowed( 'read' ) in the common case where
'read' permission is granted to everyone.

For the OAuth work, we need to be able to catch that last type of use
without interfering with the others. This change introduces
User::isEveryoneAllowed() to be used for that type of check, which both
makes sure the right granted to '*' isn't revoked from any group and
calls a hook to allow extensions to indicate that they might remove the
right.

Change-Id: Idfee1b4d0613aaf52e143164acd6022459415c49
2013-07-12 11:18:15 -04:00
Brad Jorsch
d24779328e Fix protection rights usage
It has long been recognized that using the 'protect' right to control
the ability to edit sysop-protected pages is troublesome. r31247 fixed
this by adding an 'editprotected' right, but for some reason in r32164
this was changed to bypass protection completely instead of fixing the
bug identified in r31462.

This patch goes back to do it the right way: editprotected no longer
bypasses all protection, and it is used instead of 'protect' for
controlling access to sysop-protected pages. For good measure, the same
is done with autoconfirmed protection (semiprotection): a new
editsemiprotected right is created instead of overloading the
existing autoconfirmed right.

This also fixes bug 27152 by making editprotected no longer special.

Bug: 13137
Bug: 27152
Change-Id: I6bf650a3fbdab8589ae6945c8c916eafd949e41c
2013-07-04 15:38:36 +10:00
Brad Jorsch
18062eb3b0 Add user rights 'viewmywatchlist', 'editmywatchlist'
These are needed for OAuth grants.

Note that, even if 'editmywatchlist' is not granted, various actions
will still allow for adding but not removing of pages.

Change-Id: Ie33446a228dd6ed0114730935c1bf65667f5ce01
2013-06-26 10:20:40 -04:00
jenkins-bot
2361107a27 Merge "Remove unnecessary exception from Title::getLatestRevID()" 2013-06-11 07:02:43 +00:00
Tim Starling
22e2e96088 Remove unnecessary exception from Title::getLatestRevID()
Bug 37209: An exception was thrown where the data cached in the Title
object was inconsistent with the data in LinkCache. It shouldn't be
surprising that this happens, since there is no guarantee that the data
was derived from the same transaction or even the same DB server.

But I don't think it is a problem worth troubling the user over, since
with $flags=0, the slave DB server will be used, and no special guarantee
of consistency should be expected by callers. If callers do need
consistency, then they should make their own arrangements to get it,
such as clearing the LinkCache.

Since we have to pick a winner, and the choice is mostly arbitrary since
it's not possible to tell which is fresher, I think LinkCache is a better
choice since the lifetime of its cache entries can be controlled.

Change-Id: I0add48463341e56fe8c155b1007487278ad2705d
2013-06-11 08:58:32 +02:00
Brad Jorsch
fc989b468d Add user rights 'editmyuserjs' and 'editmyusercss'
These are needed for OAuth grants.

Change-Id: I52f8e4a5cb48573cb2dbc26fc508e61a95d748c3
2013-06-10 15:44:22 -04:00
Platonides
5e48bc1cc7 Remove unused global
Follow-up 22eb569

Change-Id: I2c34b1f02c7304bd6864a7402c8be0ab313c7162
2013-06-04 23:40:30 +02:00
Tyler Anthony Romeo
7120504bb9 Add TitleQuickPermissions hook to Title::checkQuickPermissions
Currently Title permissions hooks get called after
Title::checkQuickPermissions, preventing users from
overriding quick permission checks. Added a hook to
allow this. Needed for bug 45898.

Change-Id: Id672270741282778815b06eff8b234ca4d819744
2013-05-24 19:37:01 +00:00
jenkins-bot
7106407580 Merge "TitleSquidURLs hook for changing the URLs to purge" 2013-05-21 20:06:10 +00:00
daniel
e311f6f868 TitleSquidURLs hook for changing the URLs to purge
This allows extensions to purge derivative resources that need
updating when a wiki page is changed.

Change-Id: Ic28ce7f57f29376b041627288979981fcb218a44
2013-05-21 20:01:55 +00:00
Tyler Anthony Romeo
22eb569fb4 Fixed behavior of Title::invalidateCache.
Removed actions that should not be in Title::invalidateCache,
specifically the clearing of the InfoAction cache, and added
those actions to their appropriate locations.

Added a new method InfoAction::invalidateCache that clears the
cache for a given title.

Bug: 46816
Change-Id: Ic12c66446c0d71f567dceb5d4630382ff41ad8bf
2013-05-21 10:41:42 -07:00
Timo Tijhof
4bd5471ca3 docs: Remove odd colons after @todo
Most were this way already:
https://doc.wikimedia.org/mediawiki-core/master/php/html/todo.html

Ran a find/replace on the odd ones. Also made them all
lower case.

Change-Id: I70c6a69344ddebc603e9a1c1d87e3cc4f4f4c560
2013-05-15 06:23:40 +00:00
Alexandre Emsenhuber
7053baca03 Remove "will be removed in ..." comments
All of them are wrong, since 1.20 is out for a while now, and
these methods are still here.

Change-Id: I3b59b61490c9aea5252e25623b0b282295dcc3f6
2013-05-11 22:04:21 +02:00
Tim Starling
45ce72f907 Revert "Fixed behavior of Title::invalidateCache."
Causes jenkins build failure

This reverts commit 3b4c514efa

Change-Id: Ieeb54f1e7a9cfb5ac02b8a9f49bbe0644a064fa0
2013-05-06 00:52:46 +00:00
Tyler Anthony Romeo
3b4c514efa Fixed behavior of Title::invalidateCache.
Removed actions that should not be in Title::invalidateCache,
specifically the clearing of the InfoAction cache, and added
those actions to their appropriate locations.

Added a new method InfoAction::invalidateCache that clears the
cache for a given title.

Bug: 46816
Change-Id: I38ac616d2e99fb339aca33425745368ba85b6350
2013-05-06 00:21:25 +00:00
Aaron Schulz
db11362b97 Avoid use of __METHOD__ in closures.
Change-Id: If633400bc915e3e0582d420826c30761678f4878
2013-04-26 15:50:06 -07:00
umherirrender
9f14ecf829 Added space after switch/Removed spaces after unset
While at it, added/removed some other spaces in the same files

Change-Id: I84d8001aa123a008807ad5eb76f396aed7c899a4
2013-04-26 16:42:31 +02:00
Platonides
e371ba1ef6 Remove globals unneeded after 47d1060
Change-Id: I39b6fa829e0d6ea7861b06edd8f5c599edcf4b76
2013-04-25 16:31:01 +02:00
Kevin Israel
47d1060398 Remove is_numeric check from Title::checkUserBlock
This should allow the usernames of administrators such as "7"
to show correctly on permissions error pages.

I extracted the working code from UserBlockedError::__construct
into a separate method Block::getPermissionsError, called from
both places with context provided as an argument.

Additional changes to get the test suite to pass are included.

Bug: 46768
Change-Id: I49d973992a99e03b4e8de112b47b737037a85338
2013-04-24 01:05:23 +00:00
Aaron Schulz
4738bc315a Moved Block and Title purgeExpired() functions to onTransactionIdle().
Change-Id: I82b2f4689a42481cd2a476351354f55ded581ff5
2013-04-18 22:53:28 +00:00
Ori Livneh
0bb7a68398 Fix @return type hint for Title::newFromID
Change-Id: I7f9ff81b91dcabb68c9c86eedf391b3e6160c6d4
2013-04-18 14:57:03 -07:00
umherirrender
dbd0b590e9 else if -> elseif
Also fixed some spacing while at it
Added some braces for one line statements

Change-Id: Iebfa2b17091509daabc76248121c7763e2295d20
2013-04-17 16:52:47 +02:00
Hashar
572ee81c0b Revert "Remove is_numeric check from Title::checkUserBlock"
Breaks unit testing (see bug 47031). The commit managed to land in
the branch because of a bug in Jenkins (bug 46723).

This reverts commit 8cc0b601aa

Change-Id: I4b3fadccaae9c35964a0c47d63b22c4f35148a24
2013-04-09 08:20:12 +00:00
Kevin Israel
8cc0b601aa Remove is_numeric check from Title::checkUserBlock
This should allow the usernames of administrators such as "7"
to show correctly on permissions error pages.

I extracted the working code from UserBlockedError::__construct
into a separate method Block::getPermissionsError, called from
both places with context provided as an argument.

Bug: 46768
Change-Id: Ic3fa926a5a4c109faff35fffbccb60fb06ea4a18
2013-04-09 02:40:35 +00:00
Reedy
38dd67f747 bug 42649 - PHP Fatal error: Call to a member function isLocal() on a non-object in Title.php
Change-Id: Ie6027c818785b12f6be9c47caab77ffa4a587a79
2013-04-08 23:29:57 +01:00
umherirrender
42b711ec0a Fix doc and deprecated warning of Title::fixUrlQueryArgs
Break long line

Change-Id: Iaeef8ce87c3ffd4609651f7cc0e8340a0f4bebfc
2013-04-08 19:28:54 +00:00
Aaron Schulz
5b77487e85 Deferred page_touched update via onTransactionIdle.
* This should reduce deadlocks and lock wait timeouts.

Change-Id: I595bc33d7643e7964d796b1d3da31f7cfab55024
2013-04-02 23:35:36 +00:00
Alexandre Emsenhuber
15833dafdf Fix case of some Title methods
Change-Id: I1a37ffb0e8cde4deac027721b0e463585b58d634
2013-03-26 10:54:15 +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