Commit graph

1299 commits

Author SHA1 Message Date
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
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
Ricordisamoa
2ae155da52 Fix phpcs errors in includes/
Mostly Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines

Change-Id: I678b2f0902f11cd1dfa1611b9da24e7237df9122
2015-01-08 20:15:07 +01:00
Aaron Schulz
4ff8136807 Removed remaining profile calls
Change-Id: I31c81c78715048004fc8fca0f27d09c1fa71c118
2015-01-08 02:49:33 -08: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
jenkins-bot
7746e1458b Merge "Use preview content when it transcludes itself" 2014-12-31 16:19:24 +00:00
Jackmcbarn
779f1024c1 Use preview content when it transcludes itself
When a page transcludes itself, such as <noinclude>foo
{{:{{FULLPAGENAME}}}}</noinclude><includeonly>bar</includeonly>, use the
preview content in its own transclusions. This code was basically ripped
straight from Extension:TemplateSandbox.

Bug: T85408
Bug: T7278
Change-Id: I1aa091a395a4f7b7b744e09e0bed59bc2e1176d0
2014-12-30 12:59:16 -05:00
Timo Tijhof
1dd14dcec0 EditPage: Optimise loading of mediawiki.toolbar module
Follows-up b3830611c4.

Unlike getEditToolbar(), which only runs if the user preference
is enabled, the loading of mediawiki.action.edit is unconditional.

As mediawiki.toolbar has already been separated from mediawiki.action.edit,
it's easy to load it conditionally instead of via a dependency
(mediawiki.action.edit doesn't depend on it for anything else).

Also:
* Remove odd 'false' values passed to User::getOption(). These
  options are part of MediaWiki core and always exist. The default
  value 'false' was ignored.
* Remove redundant closure. The domready callback already provides
  a closure and 'mw' is not used here (similar to jquery.mw-jump).

Change-Id: Ib2f4633b328cf8090df43b8d286cfcd77f95c5ea
2014-12-19 22:53:49 +00:00
umherirrender
e9586a8e36 Use more pretty output in ResourceLoader debug mode for arrays
Effected:
- mw.language.data
- mw.language.names
- mw.config.set
- mw.user.options.set for defaults
- mw.toolbar

Change-Id: I8a9e718ab15f0b3f80e12b817295c6843a570d46
2014-12-19 17:55:46 +01:00
Kevin Israel
9c2fb8b722 EditPage: Don't warn if the page already redirects to itself
Follows-up 0266068570.

Also improved the wording of the "selfredirect" message.

Change-Id: I89a4647c03ccc31db4812dedac107869b2721833
2014-12-15 19:52:01 +00:00
Tim Starling
90a3418cf2 Fix parenthesis placement in multi-line condition
After talking with the folks in #mediawiki-core, I decided that I can
put up with it, under protest, on the basis that it's arguably
consistent with PSR-2.

Change-Id: I5f0c0f8f0172674797970d306efe6439ce1c2b67
2014-12-11 15:33:38 +11: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
jenkins-bot
6662eb079e Merge "API edit: allow ConfirmEdit to use the merged parse" 2014-12-10 20:22:05 +00:00