Commit graph

338 commits

Author SHA1 Message Date
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
addshore
93547747e3 Use LinkTarget in Revision::newFromTitle
Change-Id: Ib1c58c30106d535daa736feb17e9b9b76c1cf10e
2016-02-03 16:49:29 +01:00
jenkins-bot
ba4a2394fc Merge "Avoid races on null revision insertion" 2016-01-25 20:20:10 +00:00
This, that and the other
8fc9222c7e Prevent revisions with rev_page = 0 from being inserted into the DB
There's no good reason to ever do this, or to write code that lets it
happen. The revisions are just going to sit around in the DB, not
connected to anything (except maybe in some page's page_latest field,
if you're lucky). Any operations that do this should fail fast instead
of spamming the DB and appearing to "succeed".

Bug: T18674
Change-Id: I8219153a09adb1c556d0159a4fb0799895370a94
2016-01-20 10:30:32 +11:00
Aaron Schulz
279281b94a Avoid races on null revision insertion
Bug: T51581
Change-Id: I7bfa9a4b20458e76ab3c4659e7041cd68aac13a4
2016-01-13 13:50:18 -08:00
Reedy
00c426e3c2 Replace wfBaseConvert with Wikimedia\base_convert
Change-Id: Iadab3d018c3559daf79be90edb23d131729bdb68
2015-11-24 22:51:42 +00:00
Marius Hoch
787cd8a788 Don't claim model validation failed if the content couldn't be loaded
Also include the corresponding revision id in the exception message.

Bug: T118747
Change-Id: If3e5694f8b471045cf62d672f414446cf5365ed5
2015-11-16 23:13:55 +01:00
Aaron Schulz
4f781c7bf9 Convert some users to WANObjectCache for consistency
These callers don't need to do purges, but can still perfectly
take advantage of this instance over a plain BagOStuff. Namely:
* Replication and snapshot lag awareness
* Preemptive regeneration
* Easy process cache support

The idea is for there to only be one caching class/factory
to use, instead of having rules for picking which one to use.

Change-Id: I8e362df451c0c28731fc853c044c4c4b8e097f01
2015-10-19 16:46:52 +00: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
c37d6549fd Fix Generic.Files.LineLength phpcs failure in 11 files under includes/
Bug: T102614
Change-Id: I0d759be6ef568c2c6f28606d3002484ad77a1830
2015-10-03 17:08:26 +00:00
addshore
a1094b42db Retry getting CatChange RC from master
This adds optional flags to Revision::getRecentChange
And uses them in CategoryMembershipChange

Bug: T109700
Change-Id: I197ebccf1f62cdcb03ce4daa2527b973e495236c
2015-09-30 23:09:12 +01:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Kunal Mehta
e84868d256 Revision::newNullRevision: Make sure the Title is set in the constructor
Revision::__construct() calls Revision::getContentModel() to initialize
the 'content_model' field. If a Title object is not set, it will try to
look up the page in the slave database, which might be behind. At that
point it will default to wikitext, which is problematic during imports.

By passing the Title object in the constructor instead of afterwards,
the content model should be intialized properly.

Bug: T91170
Change-Id: I7fea996ea5b723967272af8cb344150aea10bb54
2015-07-31 17:00:48 -07:00
Kunal Mehta
a5bc9f49cd Revision: Interpret a NULL rev_content_model as the default model
If a revision using the default content model is saved, the
rev_content_model field will be set to NULL in order to save space.
However, Revision::getContentModel() was using Title::getContentModel()
when it found a NULL, which will return the current content model rather
than the default. So change that to use the default content model, as
returned by ContentHandler::getDefaultModelFor() rather than the current
one.

Change-Id: I7011812b6b131170b3c593917ad263bcba83898d
2015-07-02 00:40:40 -07:00
umherirrender
70f3afd548 Remove unneeded empty lines at begin of if/else/foreach body
An if body must not begin with an empty line

Change-Id: I62b058be337fcc85a120fcd3dadce564db59a271
2015-06-19 20:05:45 +02:00
daniel
abb86661c3 Avoid data loss if compression fails
Change-Id: I0b6de030b101fdc3b2ea2cd0c15913e33e9da98d
2015-06-04 17:02:19 +02:00
jenkins-bot
edca0d035c Merge "Add checks to try to catch T92046" 2015-04-02 23:41:06 +00:00
Aaron Schulz
4d58457784 Added slave/master fallback logic in Revision
* This is a more specific form of the logic removed in 3c2bc32ae1.
  It does not suffer the problem of causing constant master DB
  queries due to a bad template reference or such.
* It will use the master if writes from the current thread
  are pending or were recently committed. This deals with the
  common problem of code that needs to read things it just wrote,
  such as diffs on rollback or edit hooks.
* This commit reverts 8624e261f by making the hack obsolete.

Bug: T93866
Bug: T94407
Change-Id: Ib9ecb75e1236e767bdc86d124d5e22a03ae0fb5f
2015-03-31 23:39:28 +00:00
Brad Jorsch
58dba7d8b2 Add checks to try to catch T92046
Somehow, revisions are getting added to the database without issue but
page_latest is being set to 0 rather than the newly-added revision ID.
Grepping through the code, the only places page_latest gets set are
WikiPage::insertOn() (which isn't relevant for an edit of an existing
page) and WikiPage::updateRevisionOn(). And the only relevant-looking
place WikiPage::updateRevisionOn() gets called seems to be
WikiPage::doEditContent(), which calls Revision::insertOn() just before
which *should* be setting the mId on the revision object.

Since there's no obvious bug in the code, let's add some checks to make
sure that the revision ID isn't 0. If we see exceptions being thrown, at
least we'll have narrowed down the places we need to look more deeply.
And if not (and the bug continues to be reported), we'll at least know
this part is working right.

Bug: T92046
Change-Id: I8cc60593fafb5702e29186ec14cb9d87f1767ef4
2015-03-31 13:33:50 -04:00
jenkins-bot
8028800125 Merge "Truncate null revision comment for whole multibyte characters" 2015-03-18 08:02:03 +00:00
jenkins-bot
2b1ee195a0 Merge "Removed newFromConds master fallback logic; obsoleted by $flags" 2015-03-13 18:01:46 +00:00
umherirrender
fa95cb9d73 Truncate null revision comment for whole multibyte characters
Added a truncate for multibyte characters to Revision::newNullRevision.
This avoids broken characters for long comment, mostly the comment for
move or protection in the history.
The whole comment is still visible on Special:Log.

Bug: T85700
Change-Id: Ie0863261484ee99006407c12c3a920ea476925e3
2015-03-12 18:17:45 +00:00
Aaron Schulz
7480b9250c Avoid excess master queries in getTimestampFromId
Bug: T92357
Change-Id: Id5cf7a5620daeee12abfa778f9be19435f3e5e84
2015-03-11 14:37:14 -07:00
Aaron Schulz
3c2bc32ae1 Removed newFromConds master fallback logic; obsoleted by $flags
Bug: T86862
Change-Id: I6867a61fff9828fb32b063c1e84872e910c4b273
2015-03-10 20:53:44 -07:00
jenkins-bot
2c4c338100 Merge "Made Revision::newFromPageId avoid master queries like newFromTitle does" 2015-02-05 01:24:53 +00: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
Aaron Schulz
abd49a9dec Made Revision::newFromPageId avoid master queries like newFromTitle does
Change-Id: I8b8092467d2e6ef7755b5e9aa1986f73fbd1d324
2015-01-15 17:55:39 -08: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
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
Jackmcbarn
e3c3e55b83 Remove negative caching from Revision::getContentInternal
Negative caching in Revision::getContent can cause race conditions, so
stop doing it.

Bug: 71545
Change-Id: Iac32b2d4f90c4c1ce37820288f757e47b6d895e7
2014-10-13 20:50:19 -04:00
Jackmcbarn
4fb4ad91b4 Don't clobber revision size of 0
When a revision's size is 0, don't clobber it by changing it to null. This
causes, among other things, moves of empty pages to not show a revision
size. If we get to where the else used to be, either mSize is 0 (and doing
nothing is correct), or mSize is already null, in which case this didn't
do anything anyway. We know this because, above, we initialized it with
$this->mSize = isset( $row['len'] ) ? intval( $row['len'] ) : null;

Change-Id: I3d9b9163368c57b9a7906f6569119081b945d57e
2014-09-29 10:46:18 -04:00
umherirrender
63dc5abc9a Fixed spacing
- Added space after reserved words: function, foreach, if
- Combined 'else if' into elseif
- Added braces to one-line statements
- Added spaces after comma, before parentheses

Change-Id: Ie5bbf680d6fbe0f0872dab2700c16b1394906a72
2014-08-27 18:31:50 +02:00
Kunal Mehta
87cbe68f33 Revision: Allow for userCanBitfield to check per-page restrictions
Change-Id: I13ded8328cac59466b691e63183a16d321659ea4
2014-08-18 11:25:49 -07:00
umherirrender
1c68a1ee86 Cleanup some docs (includes/*.php)
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I783e4dbfe5f6f98b32b9a03ccf6439e13e132bcc
2014-07-24 19:42:24 +02:00
umherirrender
7ff005407e Remove colon after @deprecated/@param/@todo/@note
Change-Id: I4e66dad85eecf7e8e03ac760af900395e1bc11b6
2014-07-24 11:30:25 +02:00
Leon Liesener
3091b49e77 Shortened too long lines
Change-Id: Ia82162dd52b3fea7e76c1f47cb66bce3b7927cef
2014-07-20 20:10:37 +02:00
eikes
2f002458d5 Split "suppressrevision" into two user rights
In this change, a new passive user right named "viewsuppressed"
which can be used in order to view suppressed page content was added
to MediaWiki core.
Furthermore, this right was also added to the list of available rights,
to qqq.json and to en.json where also the description of the
"suppressrevision" right was adjusted in order to reflect reality.

Bug: 20476
Change-Id: Id1baacb9c782763db5e05ef8b5c1b761997efcc9
2014-07-19 18:11:15 +02:00
Alexandre Emsenhuber
5694b8671f Don't use isset() to check for null
- Remove isset for defined member variables
- Add a missing definition of member variable $mTextId
- Fix documentation of $mTextRow
- Standardize checks for null to use "=== null" or "!== null"
  instead of is_null()

Change-Id: I56e364bc14b5a3961a2538371ae4b0088babc5c7
2014-07-03 21:41:05 +02:00
jenkins-bot
74a77b0db6 Merge "(bug 56849) Deprecate dangerous edittime-based content update functions" 2014-06-03 21:23:05 +00:00
Joerg
90302be475 Add ar_text to the list from Revision::selectArchiveFields(). It is checked later.
See Revision::newFromArchiveRow().  This is called from
populateRevisionLength.php's upgradeRow() which ultimately populates
$row from the fields returned by Revision::selectArchiveFields().

Revision::newFromArchiveRow() has the following condition:

	if ( isset( $row->ar_text ) && !$row->ar_text_id ) {

And from the bug report:

> for old archived revisions, the rows in the archive table do _not_
> contain a pointer to the text in the text table, but that the text
> is stored in the archive table directly. Obviously the above code
> cannot handle this situation properly.

Credit goes to Joerg who found this and figured out the problem.

Bug: 65765
Change-Id: Iadcaae5e531d439780f5b6095286df78926ccaa7
2014-05-27 09:44:56 -04:00
Adam Roses Wight
2521f8b5b9 (bug 56849) Deprecate dangerous edittime-based content update functions
Existing edit conflict logic relies on second-resolution timestamps,
which can fail in many exciting ways.  This patch provides new support
functions which take an explicit revision ID instead of a timestamp.

No functionality is changed.  Hopefully.

TODO:
* Make use of this code by replacing all edittime and starttime logic
with an explicit baseRevId.

Change-Id: I83cdd4adaaa67f81e933654228eccdc9fcdf9009
2014-05-24 05:23:39 +00:00
Siebrand Mazeland
a7fbdd6503 Make phpcs-strict pass on includes/ (7/7)
Change-Id: Ia9baaf0b3cdbe1a3c6b50ef8c4fe86fead88f909
2014-05-15 20:07:09 +02:00
Marius Hoch
92c4dffd55 Fix doc for Revision::newFromPageId
Change-Id: Ice5b7f42facd30f856f06c1bc1f4408d61a4121d
2014-05-05 21:45:53 +02:00
umherirrender
e10ee4304e Adjust indent of some comment blocks
Change-Id: Ic25419490fa6a35c11ccc2b7810527e6661e027c
2014-05-01 18:46:34 +00:00
umherirrender
26e705f808 Add $user param to Revision::newNullRevision
This avoids the use of $wgUser in Revision constructor and makes the
dependency on the global visible.

Change-Id: Ib67bd706a3c4ef081f475406e9aa1094c42222ef
2014-04-28 18:59:20 +02:00
umherirrender
986eead588 Fixed some @params documentation (includes/[Block.php|Revision.php])
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.

Change-Id: Ie592d31e85651663e3b3e1aa4ee7c270d06d0c81
2014-04-23 11:25:56 +02:00
Bartosz Dziewoński
59002d8935 Consistently use '@deprecated since <version>'
Variants included 'in <version>', 'as of <version>' and just the
version number.

Some @deprecated annotations do not have the version number at all,
I want to hunt them down separately.

Change-Id: I8208c6097098f4735d4f51bc42254675f1f27f6d
2014-04-15 22:18:19 +02:00
Siebrand Mazeland
130517e6d4 Update docs for Revision::getRevisionText()
Change-Id: I9e4218bec9fd69a50e06ba9fcd8bdf8461163a47
2014-01-01 15:32:48 +00:00
Siebrand Mazeland
4e8687a884 Remove deprecated methods from Revision, SkinTemplate, and WikiPage
No uses found in core of Gerrit extensions.

- Revision::revText() (deprecated in 1.17)
- SkinTemplate::jstext() (deprecated in 1.21)
- WikiPage::quickEdit() (deprecated in 1.18)
- WikiPage::useParserCache() (deprecated in 1.18)
- WikiPage::viewUpdates() (deprecated in 1.18)

Change-Id: I9eee23ea3ce381b6b8373da899287bcaea4cead4
2013-12-27 19:44:14 +01:00