Commit graph

1311 commits

Author SHA1 Message Date
Kunal Mehta
2b72964015 Improve change content model log entry for page creations
There really isn't a previous content model because the page didn't
exist beforehand, so say the page was created with a non-default
content model.

Bug: T128645
Change-Id: Ibe0b124e3f3ceaaf3775f82e2646b7639a146a42
2016-03-07 10:29:45 -08:00
jenkins-bot
c339459eb3 Merge "Improve code suffering from PHP 5.3's lack of support for foo()[]" 2016-02-29 09:53:31 +00:00
Bartosz Dziewoński
c161c46d26 Improve code suffering from PHP 5.3's lack of support for foo()[]
I searched for /\$(\S+) = (.+?\(.*?\);)\n.*?\$\1\[/, ignored
everything involving isset(), unset() or array assigments, then
skimmed through the remaining results and changed things where they
made sense. These changes were not automated, so please review them.

Change-Id: Ib37b4c66fc57648470f151ad412210b3629c2538
2016-02-28 22:49:20 +01:00
umherirrender
efd69e2e80 Fix case of id on EditPage for label
Avoids validation error:
The for attribute of the label element must refer to a non-hidden form
control.

Change-Id: I9501fda9ca1dbff3db530f5d9e0c2504b94b0ff3
2016-02-28 12:54:14 +01:00
jdlrobson
d9a3ae564c EditPage: Style anonymous editor warning as a warningbox for consistency
Most projects override this anyway, but for default installs, let's
be consistent with other warning messages so it's clearer what is
going on.

Bug: T127403
Change-Id: I22c51a46a249247abccda709d74356e8e31a19a8
2016-02-19 00:38:49 +00:00
Ebrahim Byagowi
0cdd5c5063 Make destination URL of a page save configurable
With this, if a gadget put a hidden input named "wpExtraQueryRedirect",
can guide MediaWiki to keep that extra query parameter even after the
save of the page.

Bug: T124986
Change-Id: Ie45d6d80e83298e4c349f1e2dedd4eaa66b7697a
2016-02-18 14:15:12 +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
cenarium
b009e0af21 Make change tagging of edits in RecentChange::notifyNew/Edit
Change tags to apply to an edit can now be passed directly to the
WikiPage::doEditContent function. They are then passed to the
RecentChange::notifyNew/Edit functions where tagging is made
after the recent change is saved. This ensures that other callers
of doEditContent will not run into the same issue as T100248.
ApiRollback is fixed in this way.
In addition, we'll have to pass tags in this way for core tagging
of edits (I2e48bd458fc8d7c289f04dc276f9287516e0b987), and this makes
it possible to merge the arrays of tags and call ChangeTags::addTags
only once.

Change-Id: I829960c7a33b70464065839d7504d7529dfd0b72
2016-02-10 13:03:30 +01:00
Alex Monk
d4ca1fd7f2 Move EditPage robot policy out into EditAction
So that it's default even when CustomEditor is used

Bug: T126145
Change-Id: If49d1dc39fb6ad9a2a0fa507ea9a0ccdc1088c59
2016-02-07 01:22:00 +00:00
addshore
98bf111dd2 Count the number of EditPage edit conflicts
edit.failures.* is already used for:
 - session_loss
 - bad_token
 - incomplete_form
hence the choice of metric name.

Bug: T120462
Change-Id: I7636cedaf3d589faec3153882f7d1e8ac7054a89
2016-01-28 00:38:12 +00:00
Aaron Schulz
6af3c39c07 Replace "squid" with "CDN" in various comments
Change-Id: Idcc528daf28e119349155d36e30a9bcf61b2e7d5
2015-12-09 17:35:37 -08:00
Adam Roses Wight
cf0ba44573 Fix incorrect annotation
Change-Id: Ia240bda6f8bcee52814e200c6118ed5713ca0ea7
2015-11-30 15:25:21 -08:00
jenkins-bot
7d48609b6a Merge "Split out WikiPage 'page' field for EditPage" 2015-11-26 00:26:48 +00:00
Aaron Schulz
fb4cb75e9f Split out WikiPage 'page' field for EditPage
* This fixes numerous IDEA warnings
* Also fixed some other warnings by fixing documentation

Change-Id: I2a76ce79c0d04a28a6cd74116dfce4e67435f44a
2015-11-25 16:14:01 -08:00
Aaron Schulz
c0ad2ad7bb Add comments to EditPage::getBaseRevision()
Change-Id: Ib0b9e26916f86f00a49c6007ae55896f7421de22
2015-11-25 21:53:08 +00:00
jenkins-bot
38ba6b620b Merge "Accessor to get EditPage parent revision ID" 2015-11-24 22:23:35 +00:00
Adam Roses Wight
dd230364d6 Accessor to get EditPage parent revision ID
Take from either the request parameter, calculated value, or the actual
revision ID of the fetched page content.

This will be used in more places, once we replace time-based conflict
detection with revision-based detection.

Bug: T58849
Change-Id: I29dcb4694cd9fee4622663b4d9787e975cb415ec
2015-11-24 13:49:33 -08:00
Aaron Schulz
bde1ab74c0 Completely defer EditPage::updateWatchlist
This should reduce their profile time shown on xenon

Change-Id: I8e92de22755b592cc7b2d3fab36cff2761ab2bb7
2015-10-26 21:10:54 -07:00
wctaiwan
5d6d3aa455 Handle revisions with different content models in EditPage
Disable editing and serialize using the default format if the revision
has a different content model from the current one.

Bug: T73163
Change-Id: If28de7a3612d414a4366e3d493598244c0754b90
2015-10-16 20:06:49 -04:00
daniel
d034329764 Clarify that ParserOutput::getDisplayTitle() returns HTML.
This change only improves documentation, it does not touch code.

For reference:
* CoreParserFunctions::displaytitle generates HTML, with &, < and so on
property escaped. OutputPage::setPageTitle() treats the input as wikitext,
which works for both plain text and HTML.

* Wikibase calls ParserOutput::setDisplayTitle() with HTML including <span>
structures.

In the API action=query&prop=pageprops returns HTML. There doesn't seem to
be a good place to document that fact, though.

Change-Id: I043b26b82f066abe2830a81d3bc073543b3748d8
2015-10-16 20:03:33 +02:00
Aaron Schulz
02d999ead6 Effectively remove EDIT_DEFER_UPDATES flag
* All DeferrableUpdates will be deferred as normal.
  In CLI mode this is just post-commit and would have
  happened before the doUpdates() call anyway. For web
  requests this will be at request-end (post-send on HHVM).
  Note that deferral was already the default for EditPage.
* Previously, it was easy to accidently not set EDIT_DEFER_UPDATES.
  Deferred updates are supposed to be deferrable by definition,
  and there is no longer the problem of them piling up in CLI in
  recent versions. Not deferring mostly just forfeits performance.
* Also, it is not really the responsibility of WikiPage to be
  running DeferrableUpdate instances itself.

Change-Id: I2bc47b82635e0a24b1df5d502ba66f6de737697e
2015-10-08 00:04:15 -07:00
Brad Jorsch
c3dc398514 FauxResponse: Honor cookie options, and other cleanup
We have this nice class for unit testing cookie-setting, but the
cookie-setting method ignores all the parameters! Fix that. Also provide
accessors to check the entire set of cookie data, and the set cookies as
a whole.

While this does change the semantics of FauxRequest::getcookie() in that
the name now needs to be prefixed, no extension in Gerrit uses this
method so we should be fine.

Also clean up the case of the setCookie and getCookie methods while
we're at it. Since PHP method names are case-insensitive, this doesn't
even break compatibility with extensions.

Change-Id: Ib44a074bf9796bc0b470d557e39465792f399d30
2015-09-29 22:45:56 +00:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
umherirrender
c572d18661 Fixed spacing
- Removed space after cast
- Removed spaces in array index
- Removed double spaces
- Added spaces around string concat
- Fixed mixed tabs and spaces at begin of line

Change-Id: I38e849723f055d2d4c05cba72f5c245a28e8d5da
2015-09-26 20:44:54 +00:00
Derk-Jan Hartman
8ab73061ce EditPage: Add text placeholders to view source page
These placeholders are already in use by the edit form, but were not
available to extensions. This gives us equal oppertunity to adapt the
contents surrounding the source textbox as we have in the editform.

I'm reusing the same placeholders. Most extensions fill these
placeholders through the showEditForm:initial hook however, so it
should not cause too many unexpected changes, since the readonly page
uses showReadOnlyForm:initial instead. I left out those that were very
specific to the editpage (afterEditTools etc).

This will be useful for Bug T110050.

Change-Id: Ia03265a907212ee7bac1b839dcdd4d2f24c79bbe
2015-09-01 12:46:41 +00:00
Aaron Schulz
f336e583c9 Defer spreadAnyEditBlock() post-send
* No need for these to be perfectly synchronous

Bug: T92357
Change-Id: I6863960c8170ef4c3f2e356841b4086ac98f0f03
2015-08-26 17:54:58 -07:00
umherirrender
22d4ef527e Pass user to WikiPage::doEditContent from EditPage
This avoids the use of $wgUser inside of WikiPage::doEditContent.
It does not avoid the use of $wgUser in general, because EditPage does
not know about context, but it will make the indirect use visible and a
rewrite of EditPage can address the issue better.

Change-Id: Ifbcf52f2f076dc5c177bea22f90eb3b9fb8e3224
2015-08-14 14:51:32 +02:00
This, that and the other
b3f897e971 Hide edit toolbar Signature button in non-discussion namespaces
Most wikis only use user signatures on pages set aside from discussion,
(Talk namespaces and sometimes project/main namespaces depending on
the wiki), so having the button available everywhere is confusing.
The few wikis that need the button (especially non-content,
internal/corporate/planning wikis), can add relevant namespaces to the
$wgExtraSignatureNamespaces array in LocalSettings.

This would make it possible to solve bugs like T59727 or T53154.

Since this is a change to default behavior, a release note is added.

Bug: T7645
Change-Id: I7ccf1093b888c7b33721234349ca0ac054c3cd3f
2015-08-03 11:20:44 -07:00
Aaron Schulz
377df958bf Avoid logging query in wasDeletedSinceLastEdit() if the page still exists
* This avoids hitting a long tail of logging table queries that
  cannot easily use the buffer pool all the time.

Change-Id: Id2ad6b9699f1a8c579ebb1c3c0319183772af1bd
2015-07-20 15:15:53 -07:00
Kunal Mehta
fa31bf1675 Add Special:ChangeContentModel
Special:ChangeContentModel allows for users with the 'editcontentmodel'
right to change the content model of a page.

Visiting Special:ChangeContentModel will contain an input field for a
page title. The user will then be sent to
Special:ChangeContentModel?pagetitle=<input> where the page title is
read only, with a content model selector and optional reason field.

The special page only allows converting between content models that
extend TextContent for simplicity. Advanced conversions should be done
via the API.

All content model changes via the special page or API generate a null
revision in the page history and a log entry at
Special:Log/contentmodel. The log entry has a revert link for
convenience (like the move log).

Bug: T72592
Co-Authored-By: Lewis Cawte <lewis@lewiscawte.me>
Change-Id: I296a67c09fcbc880c8c3a648eb5086580725ea46
2015-06-30 13:14:50 -07:00
Kunal Mehta
ed8ef675aa EditPage: Check $wgContentHandlerUseDB
Reject any edits that attempt to change the content model of a page if
$wgContentHandlerUseDB is false.

Change-Id: Ic2e0ed8f74c3a54864793a457a452f72fe637f73
2015-06-22 09:51:52 -07:00
umherirrender
6b24d10b6d Fix some line indent of string concat
Change-Id: I5883c9cd57d106168648b4502051b4b49046fea2
2015-06-19 20:52:43 +02: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
Ori Livneh
1e7076c6e1 Instrument edit failures
Users on enwiki's VPT are reporting a spike in the frequency of rejected edits
due to loss of session data. It is difficult to corroborate these reports when
we don't have any instrumentation for them in the code, and thus no visibility
into how frequently they are occurring in the wild.

Bug: T102199
Change-Id: I0c99f292002209cf2bf4376f97b8c70a6b1ec021
2015-06-11 23:44:42 +00:00
Aaron Schulz
549bfc0ee5 Fixed regression from 97b2a1dfd with URL specified edit tags
Bug: T100248
Change-Id: I2688356cd5f628dca395d1caaa82b9a5b21c025e
2015-05-26 02:44:10 +00:00
Timo Tijhof
9838eeb6f2 resourceloader: Add ResourceLoader::makeInlineScript utility and use it
Plucked from the e86e5f846 which got reverted.

Change-Id: I4bba3f3c31c5181867378ae174537429b49a50df
2015-04-20 19:45:27 +00:00
aude
2513086ec1 Add supportsDirectEditing methods to ContentHandler
This adds supportsDirectApiEditing and
supportsDirectEditing methods to ContentHandler. Both
return false by default for the ContentHandler base
class, and true for TextContentHandler and it's
derivatives. (everything in core)

Extension content types that directly extend
AbstractContent / ContentHandler, often / generally don't
support direct editing. EntityContent in Wikibase
and Flow boards are the two such content types currently
in gerrit-hosted extensions.

The use and direct settings of the allowNonTextContent
member variable is replaced by enableApiEditOverride and
a setter for that. The only place allowNonTextContent is
used in all of Wikimedia-hosted git repos is core itself
(EditPage and ApiEditPage), so should be safe to make
this change.

With this change, Wikibase can remove its ApiCheckCanExecute
hook handler that disallows editing there, and MobileFrontend
could check if direct editing is allowed before enabling it's
editing features, instead of Wikibase having to add
MobileFrontend hook handlers to disable the features.

Bug: T96382
Change-Id: I276cd6ecedf38108f1f2be16b38e699e8c5d2d0c
2015-04-17 15:55:20 +00:00
This, that and the other
ae3ab9eef0 Allow users to add, remove and apply change tags using the API
You can add tags at the same time as performing action=edit, as long as you
have the "applychangetags" right. Also, you can add or remove tags after
the fact from revisions and log entries using the API action=tags.

No UI is provided for either of these changes. The target audience is user
scripts, gadgets and similar tools.

Includes a new log parameter format type: "list", for a comma-separated
list of values.

Logging of change tag events is limited to those that do not accompany an
edit (i.e. those done after the fact), and is hidden from Special:Log by
default, similar to the patrol log.

Bug: T20670
Change-Id: I37275e0f73fa3127f55da0c320b892551b61ee80
2015-04-15 18:30:45 +00:00
Brad Jorsch
ff95a95437 SECURITY: Don't execute another user's CSS or JS on preview
Someone could theoretically try to hide malicious code in their user
common.js and then trick an admin into previewing it by asking for help.

Bug: T85855
Change-Id: I5a7a75306695859df5d848f6105b81bea0098f0a
2015-04-01 09:55:52 -07:00
jenkins-bot
b594c133f3 Merge "Use wikimedia/utfnormal library, add backwards-compatability layer" 2015-03-31 00:51:16 +00:00
Kevin Israel
ce0e2cf341 EditPage: Remove remnants of pre-1.16 live preview
Change-Id: I6cd0c56f7e934ce43f9bd101bfb5d4ca3d7bdbad
2015-03-30 19:33:24 +00:00
Ori.livneh
2b6eb60ce5 Revert "Optimize order of styles and scripts"
The patch did not improve performance. I'd like to think that the increased
control over when inline scripts are executed makes the patch worthwhile
regardless, but that is post hoc justification and possibly a bit of personal
ego. Krinkle agrees that we may use some of the ideas in this patch in the
future but he thinks we're better off not heading down this path before we
have a better sense of where we're going, and I trust his judgment.

This reverts commit e86e5f8460.

Change-Id: I151f74a41dd664b5a0aa5cfd99fcc95e2686a1e6
2015-03-25 04:40:46 +00:00
Fomafix
3eafa8dd37 Update HTML title with displaytitle on live preview
Set the new global JavaScript variable 'wgEditMessage' with the name of the message.

Document this global JavaScript variable in
https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#mw.config
after merge.

Bug: T88117
Change-Id: Ida5c1d470908cefd16925bd5455758d25db02113
2015-03-24 22:34:18 +00:00
Kunal Mehta
13975fe76a Use wikimedia/utfnormal library, add backwards-compatability layer
This drops support for the custom utf8 normal PHP extension in favor
of the intl extension.

Bug: T90825
Change-Id: Ifbaeb2ef684217cf6187ccc4fb4d303f89608300
2015-03-24 12:59:26 -07:00
jenkins-bot
1c844cb10c Merge "EditPage: Implement 'editnotice-notext' message" 2015-03-19 02:26:25 +00:00
Timo Tijhof
ca9f3f983f EditPage: Implement 'editnotice-notext' message
Bug: T91715
Change-Id: Iff6735d93da8b877063690ff67bda652a03d4906
2015-03-18 19:18:36 -07:00
Ori Livneh
e86e5f8460 Optimize order of styles and scripts
The current ordering of scripts and stylesheets in <head> causes all major
browsers to serialize and defer requests that could be performed in parallel.

The problem is that external stylesheets are loaded before inline scripts. As
Steven Souders explains, "all major browsers preserve the order of CSS and
JavaScript. The stylesheet has to be fully downloaded, parsed, and applied
before the inline script is executed. And the inline script must be executed
before the remaining resources can be downloaded. Therefore, resources that
follow a stylesheet and inline script are blocked from downloading."[1]

In other words: the browser could start loading body images, but it refuses to
do that until it has executed inline scripts in head. And it refuses to execute
those scripts until the external CSS is downloaded, parsed and applied. You can
see the effect of this in this image, showing the request waterfall for
[[en:Gothic Alphabet]]: [2]. Notice how no images were requested before the
browser had finished processing the three load.php requests at the top.

To fix this, we want to move the inline scripts above the external CSS. This is
a little bit tricky, because the inline scripts depend on mw.loader, which is
loaded via an external script. If we move the external script so that it too is
above the external stylesheet, we force the browser to serialize requests,
because the browser will not retrieve the external CSS until it has retrieved
and executed the external JS code. So what we want is to move the inline
scripts above the external stylesheet, but keep the external script (which the
inline scripts depend on) below the external stylesheet.

We can do this by wrapping the inline script code in a closure (which binds
'mw') and enqueuing the closure in a global array which will be processed by
the startup module at just the right time.

Net result: external CSS and JS is retrieved in parallel, retrieval of images
(and other external assets) is unblocked, but the order in which code is
evaluated remains the same.

[1]: <http://www.stevesouders.com/blog/2009/05/06/positioning-inline-scripts/>
[2]: <http://people.wikimedia.org/~ori/enwiki-waterfall.png> (excerpted from
 <http://www.webpagetest.org/result/150316_0C_7MB/1/details/>.

Change-Id: I98d383a6299ffbd10210431544a505338ca8643f
2015-03-17 03:10:49 +01:00
jenkins-bot
5e8a50dab4 Merge "LivePreview: Wrap content preview with mw-content-*" 2015-02-28 14:47:53 +00:00
Alex Monk
d69ffc8d6e Add a hook run after EditPage::attemptSave for WikiEditor
So that we can determine whether a save attempt succeeded or failed,
to log saveSuccess and saveFailure events from the server to Schema:Edit
on meta.

Bug: T88027
Change-Id: Ib861262603872e67600d1aab9bde3b58a8dd1738
2015-02-26 16:44:52 +00:00
Fomafix
12e031a99d LivePreview: Wrap content preview with mw-content-*
The content container is needed for CSS selectors based on the direction
of the page content language.

Bug: T85531
Change-Id: I78f6b82972621da8dddc24f0d6d6b2293f7d8876
2015-02-21 15:08:16 +00:00