Commit graph

324 commits

Author SHA1 Message Date
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
umherirrender
2dade3b9da Break long lines and remove some spaces in Revision.php
Change-Id: If62a01096319dddaa898daaabdd6e881316a0ad7
2013-12-07 21:58:53 +01:00
umherirrender
299eb8d27d Fixed spacing of exception message in Revision::checkContentModel
Change-Id: Ibbd693719d03569a4d9c5cf0b61079edd4bc40ff
2013-12-02 06:41:30 +00: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
5ca5672aac Fixed spacing
- Place commas correct
- Moved comments
- Add space after if/foreach/catch
- Reformat some conditions
- Removed trailing spaces/tabs

Change-Id: I40ccda72c418c4a33fcd675773cb08d971510cdb
2013-12-01 20:58:51 +01:00
Reedy
b0aebdaa0a Fix populateRevisionLength.php so it's not trying to select revision
fields from the archive table (they won't exist!)

Follows up https://gerrit.wikimedia.org/r/#/c/54111/

Change-Id: Ie161a08097a2cd3393d69574263cfe78e4329bb4
2013-10-28 22:08:50 +00:00
Tim Starling
e6b1baf240 Avoid master queries in Revision::newFromTitle(..., Revision::READ_NORMAL)
The fallback to master makes sense in Revision::newFromId(), since a
revision ID known to exist by some other means might be present in the
master but not in the slave. But it doesn't make sense for
Revision::newFromTitle(), where by far the most common cause of this
case being hit is the page being nonexistent.

Change-Id: I41189fcde1b8065ac134982241376d63b78732a1
2013-10-23 00:22:50 +00:00
Aaron Schulz
f1ed25f095 Fixed trx isolation bug that could cause text not to be found
* Also added some logging for when revision text is not found

bug: 53687
Change-Id: I0993e8f49d36771cc526fd4afef67455209b8e3a
2013-10-09 17:14:53 +00:00
jenkins-bot
4800843495 Merge "Make revision content decompression publicly available" 2013-08-07 21:00:02 +00:00
Matthias Mullie
7e6107b555 Make revision content decompression publicly available
compressRevisionText() is already publicly available, but the decompression was
not. For others using compressRevisionText(), the only way to decompress was to
duplicate the gzinflate code.

Change-Id: I61cd87acb52a482ba88f7c9d3826ecee66c89911
2013-08-07 20:53:34 +02:00
Petr Onderka
942dd53f97 Force lazy loading of text in Revision::getSerializedData()
Change-Id: Ic47fd482523e0a2c705c24e93525959eca52409a
2013-08-06 19:10:20 +02:00
Marius Hoch
50faf2138c Allow patrolling pages by revision id
This became necessary as it's quite hard to
get the rc id of a change from the html after
I1e24733c.

Bug: 49259
Change-Id: Ia7d3960cf11bf8ae0fc06ae1a0f7fcfb3c080f21
2013-06-10 20:54:43 -04: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
umherirrender
ef2f507d23 Fixed spacing in files direct in includes folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b
2013-04-21 06:38:49 +00:00
umherirrender
978bb31c5e Add missing wfProfileOut before throwing an exception
Change-Id: I1d830da0597f19efd0b2ae48642389975e736e23
2013-04-08 18:37:24 +00:00