Commit graph

1112 commits

Author SHA1 Message Date
Max Semenik
b16eb8a42e New hooks ApiMain::moduleManager and ApiQuery::moduleManager
Needed to conditionally register API modules. The previous way, messing with globals
from extension functions, is getting problematic because Config class will make this
impossible.

Change-Id: I86b40aeec555dd6b3cd82cab31d96e85fdf0a665
2015-02-23 10:38:40 -08:00
jenkins-bot
61b2f07f6b Merge "Add hook for custom difference engine (WikEdDiff)" 2015-02-23 12:32:10 +00:00
Erik Bernhardson
8bf4496869 Allow override of page disply within CategoryViewer
Patch adds two hook which are described in hooks.txt.  This
is being used to allow Flow to offer two links instead of just
one that are relevant to the page that was categorized.

The default output without these hooks is:

   <a href="...">Topic:Soiasdf90f09</a>

This patch allows flow to provide context as to where this topic came
from, by replacing that with:

   <a href="...">Topic:Soiasdf90f09</a> on <a href="...">Talk:Help</a>

(Note that the names of pages within the Topic namespace will also
become more friendly soonish, but outside the scope of this patch).

Bug: T87793
Related-Flow-Change: Ia4f2953bcd807ba3990e762a2efcaab428c40147
Change-Id: I182e6e35fcc3a2a298e928e088579bdb22e145ff
2015-02-20 13:46:48 +01:00
jenkins-bot
0b10f2191e Merge "Maintenance script for importing site info." 2015-02-20 10:45:16 +00:00
Alex Monk
56c1c43dc5 Fix hook situation for Skin::doEditSectionLink
The old hook supplied a way to override the HTML used for the section link,
but two extensions both trying to use it was obviously not going to work.
Deprecate it in favour of a hook that goes around gathering info to build
the initial HTML, then shoves it through the old hook for back-compat.

So that WikiEditor can add in extra URL parameters as well as VE adding in it's
own link.

Bug: T88027
Change-Id: I5a7a23709805625bdefb69cd9379be0c95acd982
2015-02-19 16:03:22 +00:00
daniel
85e2086369 Maintenance script for importing site info.
Bug: T87176
Bug: T87183
Change-Id: I3936417bc79e08cf3d04270158a6e483b5515246
2015-02-18 18:39:14 +01:00
jenkins-bot
554967bf4a Merge "Allow adding of context-based LESS Variables" 2015-02-10 21:34:03 +00:00
Florianschmidtwelzow
6d9bb5d0d5 Allow adding of context-based LESS Variables
Add new hook (ResourceLoaderGetLessVars) called in ResourceLoader::getLessVars to
allow context-based less variables. Cache the resulting array to avoid multiple runs
of this hook.

Change-Id: I5a73bbd0ab58f8fe34519931c4f26c90998e3451
2015-02-10 16:25:37 -05:00
Kunal Mehta
912a5e5ec3 registration: Add resource template-like functionality to extension.json
This allows for extensions to specify common arguments to ResourceLoader
module definitions by only specifying them once.

The only supported values are "localBasePath" (which is relative to the
current directory), "remoteSkinPath", and "remoteExtPath". If a module
is using a custom class or is already specifying paths, the default paths
will not be added.

Tests are included to cover existing functionality and newly added
functionality. The convertExtensionToRegistration.php script was also
extended to try and guess what the default paths should be.

Bug: T88786
Change-Id: I802461796e8d8584dacf3b0c811b5ba97a4a8f7f
2015-02-09 15:14:06 -08:00
This, that and the other
878523f622 Creation, deletion and improved management of change tags
This allows users with the `managechangetags` right to create tags for
use by wiki users. (Currently there is no way for editors to apply tags
to their edits; that's to come in a later patch.)

Extensions can reserve tag names for their own use, even if they do not
define them or mark them as active.

Tag managers can also delete tags with <= 5000 uses. Currently, if a tag is
misspelt ("vandlaism") or no longer wanted (testing of OAuth, etc), the
wiki is stuck with it forever. This change allows users with the
"managechangetags" right to delete change tags from the database,
including removing them from all revisions to which they are applied.

Obviously this is a powerful thing to be able to do, but I view change
tags as a "light" kind of interface, useful for revision patrolling and
spam/vandalism fighting but not something that necessarily needs to hang
around forever. It's not a big deal for this kind of data to be thrown
away without being archived anywhere.

Tags defined by an extension can only be deleted if the extension allows
it.

Changes to tags are logged in the new "tag management" log. There's even
a nice API module, just for fun.

Bug: T20670
Change-Id: I77f476c8d0f32c80f720aa2c5e66869c81faa282
2015-02-04 14:14:18 -05:00
jenkins-bot
aec3f5231d Merge "LSG: Fix Makefile" 2015-01-24 01:41:32 +00:00
jenkins-bot
9a0e7169fc Merge "Introduce ApiFeedContributions::feedItem hook" 2015-01-23 19:59:03 +00:00
Prateek Saxena
064ce94c80 LSG: Fix Makefile
- Updated the list to actually be in alphabetical order
- It wasn't working on MacOS, removed the '<' and it works now

This is a follow up patch to I3d66bcacf99da7eecc91a421c521dc650ed9cf82

Change-Id: Ief0cd90ebaf36b3df6279f4ca39456bbd1bda6b8
2015-01-23 11:27:15 -08:00
jenkins-bot
dfcf9ffd67 Merge "registration: Sync extension.schema.json with reality" 2015-01-23 18:35:05 +00:00
Erik Bernhardson
dbc3c5306e Introduce ApiFeedContributions::feedItem hook
ContribsPager, which is used by ApiFeedContributions, can return more
than just revision rows.  This is handled in the html side within the
ContributionsLineEnding hook.  ApiFeedContributions had no special
handling so here I have added a simple hook the provides the data
from ContribsPager and allows subscribers to provide the appropriate
FeedItem instance.

Bug: T85229
Change-Id: I27c77cc682ba801c40361c76b67398108ca1a592
2015-01-23 10:11:22 -08:00
Bryan Davis
56b70b61af Replace MWLogger with MWLoggerFactory
Time wounds all heels. During the code review for the PSR-3 logging
introduction, several people asked me why we needed a wrapper
for Psr\Log\LoggerInterface if the point was to use the standard. At the
time I was convinced that it would be better to introduce the dependency
via a wrapper class so that we could use the wrapper to patch over any
deficiencies that we might find in the PSR-3 API. After going on to work
on a project to disentangle other MediaWiki components from internal
project dependencies I have suddenly and clearly seen the error of my
ways.

We still need a logger factory as PSR-3 does not specify
a standard mechanism for creating Psr\Log\LoggerInterface instances. My
solution is to convert MWLogger into MWLoggerFactory to retain a static
factory interface for creating PSR-3 loggers but remove the MWLogger
wrapper class itself in favor of direct exposure of
Psr\Log\LoggerInterface to the MediaWiki consumer classes.

Change-Id: Ie47467657dcf341991ada00827dca5e8eff95438
2015-01-22 22:10:49 +00:00
Matthew Flaschen
4c098d0530 LSG: Break module list into text file for readability
Change-Id: I3d66bcacf99da7eecc91a421c521dc650ed9cf82
2015-01-19 23:37:48 +00:00
Kunal Mehta
a969555c2d registration: Sync extension.schema.json with reality
* info-files was never implemented
* path is no longer needed since we already know it

Change-Id: I0212620cb3a32e506717bd39a2fff4c9589f11cd
2015-01-13 11:37:17 -08:00
Kunal Mehta
e1425750fa registration: Add ConfigRegistry to the extension.json schema
Change-Id: I6918215e3b5b2dd4c993d8a8767dc3ce998bd5ed
2015-01-13 01:25:09 +00:00
Kunal Mehta
bfe4ddd810 Implement extension registration from an extension.json file
Introduces wfLoadExtension()/wfLoadSkin() which should be used in
LocalSettings.php rather than require-ing a PHP entry point.

Extensions and skins would add "extension.json" or "skin.json" files
in their root, which contains all the information typically
present in PHP entry point files (classes to autoload, special pages,
API modules, etc.) A full schema can be found at
docs/extension.schema.json, and a script to validate these to the
schema is provided. An additional script is provided to convert
typical PHP entry point files into their JSON equivalents.

The basic flow of loading an extension goes like:
 * Get the ExtensionRegistry singleton instance
 * ExtensionRegistry takes a filename, reads the file or tries
   to get the parsed JSON from APC if possible.
 * The JSON is run through a Processor instance,
   which registers things with the appropriate
   global settings.
 * The output of the processor is cached in APC if possible.
 * The extension/skin is marked as loaded in the
   ExtensionRegistry and a callback function is executed
   if one was specified.

For ideal performance, a batch loading method is also provided:
 * The absolute path name to the JSON file is queued
   in the ExtensionRegistry instance.
 * When loadFromQueue() is called, it constructs a hash
   unique to the members of the current queue, and sees
   if the queue has been cached in APC. If not, it processes
   each file individually, and combines the result of each
   Processor into one giant array, which is cached in APC.
 * The giant array then sets various global settings,
   defines constants, and calls callbacks.

To invalidate the cached processed info, by default the mtime
of each JSON file is checked. However that can be slow if you
have a large number of extensions, so you can set $wgExtensionInfoMTime
to the mtime of one file, and `touch` it whenever you update
your extensions.

Change-Id: I7074b65d07c5c7d4e3f1fb0755d74a0b07ed4596
2015-01-08 01:40:01 +00:00
jenkins-bot
9581677601 Merge "Proper namespace handling for WikiImporter" 2015-01-05 22:40:15 +00:00
wctaiwan
8e78387b55 Add JSON to docs/contenthandler.txt
Bug: T85580
Change-Id: I70edfbe4e50fec0701484d5004a5c673c0dd69b7
2014-12-30 20:39:38 -05:00
Brad Jorsch
29951907f7 Format multiple autocomments in edit summaries
Before r39373, all autocomments in an edit summary were formatted. In
fixing a bug with page titles containing "/*" this was accidentally
broken.

To use a single preg_replace_callback call to replace multiple
autocomments, we need to make sure that the match of one autocomment
doesn't overlap the match of another, which means we can't have "(.*)"
before and after. But we do still need to detect whether there is
anything before or after. "(?=(.?))" and "(?<=(.?))" would do nicely,
except the latter isn't actually supported. "(?=(.))?" and "(?<=(.))?"
work too, but older versions of PCRE don't support that. They do,
however, support "(?:(?=(.)))?" and "(?:(?<=(.)))?", so that's what
we'll go with.

This change does change the values for $pre and $post passed to the
FormatAutocomments hook; extensions need to be updated to accept (and
not prepend/append) booleans for these parameters.

Bug: T18530
Bug: T70361
Change-Id: I36c3a9e548a4ef72f93974bb35f9add8c29e9287
2014-12-31 10:24:05 +11:00
Florianschmidtwelzow
03bf64c84c Really allow Extensions to make a new gallery format
Adjust GalleryGetModes call to fit Hooks::run() signature.

Follow up: I33462a8b52502ed76aeb163b66e3704c8618ba23

Change-Id: I916dade31d6d67de4bb82582cc71585e83fec1c9
2014-12-22 19:09:52 +00:00
jenkins-bot
d34a6ca677 Merge "Fix some stuttering in comments and documentation" 2014-12-17 22:28:27 +00:00
Ricordisamoa
12dec5d85d Fix some stuttering in comments and documentation
Change-Id: I9c0088b9aab37335203cad45a1d6fa8ac3f43321
2014-12-17 19:44:10 +00:00
Nik Everett
a3a7415eb4 Fix prefix search for special pages
Prefix search for special pages was returning only the first match.

Change-Id: I5849696de76ca588f7e626d7da319b8bddb3dce9
2014-12-15 11:25:16 -05:00
Ricordisamoa
fc5fd5c37a Typo fixes and non-code tweaks
Skipped replacements:
* prefered → preferred
* prolly → probably

Skipped files:
* resources/lib/jquery.ui/jquery.ui.mouse.js
* resources/lib/jquery/jquery.form.js

Change-Id: Ib7923f362ddfca1b892bf5d601785d6b5aa5d44c
2014-12-12 18:31:15 +00:00
jenkins-bot
6662eb079e Merge "API edit: allow ConfirmEdit to use the merged parse" 2014-12-10 20:22:05 +00:00
Ricordisamoa
6519c35def Fix documentation of hook 'BeforeParserFetchFileAndTitle'
By placing the notice "If 'broken' is a key in $options
then the file will appear..." added by Aaron Schulz with
commit 9d572d1844.
This solves a 'FIXME' added by Siebrand Mazeland with
commit b33c77a525.

Change-Id: I9d100588276faac5d5b2be979d8140389e5ed85a
2014-12-10 15:54:35 +00:00
This, that and the other
37b4cd5da2 Proper namespace handling for WikiImporter
Up until now, the import backend has tried to resolve titles in the XML
data using the regular Title class. This is a disastrous idea, as local
namespace names often do not match foreign namespace titles.

There is enough metadata present in XML dumps generated by modern MW
versions for the target namespace ID and name to be reliably determined.
This metadata is contained in the <siteinfo> and <ns> tags, which
(unbelievably enough) was totally ignored by WikiImporter until now.
Fallbacks are provided for older XML dump versions which may be missing
some or all of this metadata.

The ForeignTitle class is introduced. This is intended specifically for
the resolution of titles on foreign wikis. In the future, an
InterwikiTitle class could be added, which would inherit ForeignTitle
and add members for the interwiki prefix and fragment.

Factory classes to generate ForeignTitle objects from string data, and
Title objects from ForeignTitle objects, are also added.

The 'AfterImportPage' hook has been modified so the second argument is a
ForeignTitle object instead of a Title (the documentation was wrong,
it was never a string). LiquidThreads, SMW and FacetedSearch all use this
hook but none of them use the $origTitle parameter.

Bug: T32723
Bug: T42192
Change-Id: Iaa58e1b9fd7287cdf999cef6a6f3bb63cd2a4778
2014-12-10 22:24:47 +11:00
Reedy
0456d8e272 Fix type hint in SkinTemplateOutputPageBeforeExec in hooks.txt
No Template class, it's QuickTemplate or subclasses

Change-Id: Ie0868a98f762ab13aaa075cf4b1a8bcc5aea0b8c
2014-12-09 16:28:21 +00:00
Tim Starling
09a5febb7b API edit: allow ConfirmEdit to use the merged parse
ConfirmEdit was tripling the amount of time it took to save a typical
page via the API, since it was assuming that the APIEditBeforeSave hook
was giving unmerged wikitext, requiring a full parse of the content
before and after the edit in order to check the addurl trigger.
Apparently nobody bothered to update it after Ia59fb6bb.

APIEditBeforeSave is unusable anyway, because it is given the serialized
content, without any information about the content model. It really
needs the Content object in order to do it properly. So instead, adapt
EditFilterMergedContent for the purpose. Incidentally, that avoids the
inelegant defined('MW_API') check in ConfirmEdit's
EditFilterMergedContent handler, since both API and normal edits are
handled by EditFilterMergedContent in the same way.

Unfortunately the interpretation of the 'value' member in the Status
object passed to EditFilterMergedContent is not extensible, being an
integer instead of an associative array. So we add a custom member in
order to get the result array back down the stack.

Another obstacle to this design was the lack of an EditPage object
passed to EditFilterMergedContent. ConfirmEdit was previously directly
calling EditPage::showEditForm() with a $formCallback which outputs the
necessary HTML. Instead, I hacked up runPostMergeFilters() a bit, to
allow the hook to request that the edit page be shown again even if
hookError is not set. Then a new EditPage::showEditForm:fields hook does
the necessary HTML output, instead of $formCallback.

Marked $formCallback as deprecated, since I think it is now unused.

Change-Id: I4b4270dd868a643512d4717927858b6ef0556d8a
2014-12-05 17:10:20 +11:00
Chad Horohoe
dbca12bf93 Stop using $wgProfileToDatabase
Was not completely removed and the remaining bits were mostly
broken. $wgProfiler['output'] = 'db' is the proper way.

Fixes T75917
Change-Id: I36565e2372db2ed49b219cf533ec433e8111c52f
2014-12-03 10:37:03 -08:00
Timo Tijhof
00f7c07c02 content: Deprecate TitleIsCssOrJsPage and TitleIsWikitextPage hooks
They're currently documented as a 'compatibility hook'
in docs/contenthandler.txt. No longer used in any Wikimedia-hosted
git repository.

Superseded by the ContentHandlerDefaultModelFor hook.

Change-Id: I212230da7d6080cf500f930d4aa5a9024959d5f9
2014-12-03 04:11:33 +00:00
Chad Horohoe
b702cb3b24 Support offsets in prefix searching
Fixes T75522
Change-Id: I7a27a64e295a1efcb1d9728d95cf254bb8bfbe92
2014-12-02 11:59:26 -08:00
Brad Jorsch
28e37f55c9 Merge OpenSearchXml extension into core
There's really no reason for the extension to exist separately from
core, and merging it reduces the risks of bitrot in both the extension
(lots of deprecated functions there) and core (missing integration with
PageImages and TextExtracts, for example).

Change-Id: Ie0ab90902ede9499879402290006466efba479e9
2014-11-26 21:07:22 -08:00
Prateek Saxena
1f769a67c5 mediawiki.ui: Add radio buttons
Design specification on Trello-
https://trello.com/c/df2N2KJx/8-radio-buttons

Change-Id: Idb3d5177b6b2e9374de02416447fee9286e10a65
2014-11-26 10:20:18 +05:30
jenkins-bot
c92a5a8129 Merge "Properly mark UserGetImplicitGroups hook as deprecated" 2014-11-21 20:58:59 +00:00
paladox
44b90af0fd Remove less.js
Change-Id: I2ec714e79463835016dcfbffcf03f052167a0b61
2014-11-19 18:42:52 +00:00
Bartosz Dziewoński
b35ebdb1f5 mediawiki.action.history.diff: Rework print styles
* Remove extremely old print styles for diffs from commonPrint.css,
  added back in r6970. These were created for the old yellow-green-red
  diff styles and look terrible now.
* Add new, minimal print styles, that replace background colors with
  text decoration (underline for inserted text, line-through for
  deleted). Motivation is the same as in r6970: light colored backgrounds
  work great on displays, but not very well in black-and-white print.
* Fixed diff styles demo (mediawiki.action.history.diff.html), updated
  with print styles and better example.

Bug: 73544
Change-Id: Ibf08fa11f84ac0cf8c7ed4da8af2b8804de6ab6f
2014-11-18 18:48:15 +01:00
cacycle@gerrit.wikimedia.org
ef55b2c7b5 Add hook for custom difference engine (WikEdDiff)
The new Extension:WikEdDiff is a custom inline difference engine.
There is currently no hook to integrate custom difference engines.
This patch adds a new hook called 'GetDifferenceEngine' in
/includes/content/ContentHandler.php in function
'createDifferenceEngine()'.

Passed variables:
$context: IContextSource context to be used for diff
$old: Revision ID to show and diff with
$new: Either a revision ID or one of the strings 'cur', 'prev' or 'next'
$refreshCache: If set, refreshes the diff cache
$unhide: If set, allow viewing deleted revs
&$differenceEngine: output parameter, difference engine object to be used
for diff

If the hook handler returns false, a valid difference engine object is
returned in the passed-by-reference variable $differenceEngine.
If the handler returns true, the default engine is used as fallback.

The specified diff engine class will typically be an extension of the
class DifferenceEngine (includes/diff/DifferenceEngine.php) with
modifications, e.g. of function generateTextDiffBody() and
__construct() (without deprecated parameter $rcid).

Also fixes a missing declaration in DifferenceEngine that is required for
extending this class.

Bug: 71916
Change-Id: I9da63c1ceb339bfeba7beddc712be51977b95f65
2014-11-13 18:02:29 +00:00
Kunal Mehta
fb7eec53e9 Properly mark UserGetImplicitGroups hook as deprecated
Change-Id: Idef74f9950d5f8e133cd19f67e8486e94ec95882
2014-11-10 14:21:51 -08:00
jenkins-bot
dd53b928b9 Merge "Add two hooks to allow for extensions to expose log_search values in the UI" 2014-11-06 23:00:16 +00:00
jenkins-bot
c1fab2ba1d Merge "Add an "ArticleDeleteAfterSuccess" hook" 2014-11-05 09:47:58 +00:00
Brad Jorsch
0eebd5e91e UserGetLanguageObject hook should accept any IContextSource
Bug: 72951
Change-Id: I7c385a2cac0696493dd1c97268e5c4d03829234a
2014-11-04 11:52:12 -05:00
Florianschmidtwelzow
1c0e593bc2 UserLogin: Allow extensions to add valid error messages
Add hook LoginFormValidErrorMessages to allow extensions, to add own valid
error messages to redirect to the login form.

Bug: 71769
Change-Id: I9e996a88e3972f09946726060916a21124de049c
2014-11-03 21:28:18 +01:00
Marius Hoch
e4cfd3da01 Add an "ArticleDeleteAfterSuccess" hook
So that we can show what Wikibase did after the deletion.

Change-Id: If99be002973e68c84125158ff9747b140fb38ea1
2014-11-01 21:58:12 +01:00
daniel
da3c19fb17 Change position of <model> and <format> tags in XML dumps.
Bug: 72417
Change-Id: I1d11ce8147cf0bf0018e3931202f533afd4ea93e
2014-10-31 16:49:58 +00:00
jenkins-bot
a75e07ccf5 Merge "Fully replace Title::moveTo() with MovePage" 2014-10-30 20:06:27 +00:00