Commit graph

911 commits

Author SHA1 Message Date
Adam Roses Wight
7f51cf22f9 Minor optimization to the AutoLoader
When MediaWiki autoloading fails, we should gracefully return false.
Instead, we have been calling strtolower roughly 1,000 times in the hope
of finding a case-insensitive match.

This patch preserves the legacy case-insensitivity, but improves its
performance by approximately 100x, by storing the case-insensitive class
lookups as a static variable.

There is a new global $wgAutoloadAttemptLowercase which will switch the
behavior if desired.  The default is to support case-insensitive loading.

Change-Id: Ifb12e05614a48390b730167e9d4ddcd8545db764
2013-10-28 21:39:57 +00:00
Ori Livneh
9590795b91 Add 'RedisPubSubFeedEngine' feed engine
This patch adds a class which implements the RCFeedEngine interface by
publishing recent change notifications to Redis. The class handles the
'redis://' URI scheme. Recent changes are PUBLISHed to the channel 'rc'; a
different channel name may be specified as a path component.

Change-Id: I846036c091c45059a8947245a1efe92c9800dcf4
2013-10-21 17:22:00 +00:00
jenkins-bot
b67c7bc0d2 Merge "Remove proxy check in EditPage.php" 2013-10-21 01:17:52 +00:00
Kevin Israel
d7b953c25c Remove proxy check in EditPage.php
$wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath, and
$wgProxyMemcExpiry have been removed, along with the open proxy
scanner	script they were added for.

Bug: 54597
Change-Id: Id4c7521443f04995df3d8762d23629c18ada76f8
2013-10-21 01:12:47 +00:00
jenkins-bot
694df5e7ea Merge "Split changes list classes into separate files" 2013-10-19 14:41:22 +00:00
aude
761b880e98 Split changes list classes into separate files
Having them separate improves readability of the code
and makes it easier to work with this code.

Change-Id: Ic6aaf1ace3640f66ad41c2d85b4f7d740b259e0c
2013-10-19 14:26:27 +00:00
Tim Starling
00299ecb95 Resubmit "Add support for mysqli extension"
This reverts commit 1d7e12179d.

Change-Id: Id1a3fc34e94006b880f58de83e5e7c70b21d26ed
2013-10-17 01:35:28 +00:00
Tim Starling
1d7e12179d Revert "Add support for mysqli extension"
Throws exception unconditionally, installer support is totally broken.

This reverts commit b2d64432ee.

Change-Id: I2edb78440806754c42d48c5da2ff74b4cb40fa2d
2013-10-16 23:49:24 +00:00
Jakub Vrana
b2d64432ee Add support for mysqli extension
DatabaseBase::factory()'s parameter array now takes an optional
'driver' variable to allow specifying a specific driver for the
database class if we support more than one.

This is so we can gracefully support mysql/mysqli as the former is
deprecated, but the concept could be extended to other databases
as well.

Bug: 45288
Co-Author: Chad Horohoe <chadh@wikimedia.org>
Change-Id: I6733fe21c4aa7443e409c5dfa7c789552b2b62b7
2013-10-16 23:17:57 +00:00
jenkins-bot
3780115bac Merge "Add meta=filerepoinfo for getting file repo info" 2013-09-30 14:26:39 +00:00
Mark Holmquist
d94d29a920 Add meta=filerepoinfo for getting file repo info
We currently only return the image repository name for imageinfo, which
is not particularly useful, especially since image repositories aren't
accessible via the API. This patch adds meta=filerepoinfo, which will
return a list of repositories and relevant information (like the API URL
for ForeignAPIRepo ones)

Also returns the local repo now, and defaults to "all" in a more useful
fashion.

Change-Id: I1aaed0895d2a0bc224c82e93975ecf6afd8cb6b8
2013-09-27 13:53:34 -07:00
Brion Vibber
006f136e79 Move LESS function definitions from DefaultSettings to ResourceLoaderLESSFunctions.php
Intermittent error in production from top-level lambda functions:
https://bugs.php.net/bug.php?id=52144

Change-Id: I9785a601fd5d57c9d8d84b90ee29eef61a6f2e77
2013-09-26 15:57:50 -07:00
Brion VIBBER
0dc6d85c0b Merge "Support LESS stylesheets in ResourceLoader" 2013-09-23 19:59:49 +00:00
Ori Livneh
b67b9e1b48 Support LESS stylesheets in ResourceLoader
This patch adds support for the LESS stylesheet language to ResourceLoader.
LESS is a stylesheet language that compiles into CSS. The patch includes
lessphp, a LESS compiler implemented in PHP. The rationale for choosing LESS is
explained in a MediaWiki RFC which accompanies this patch, available at
<https://www.mediawiki.org/wiki/Requests_for_comment/LESS>.

LESS support is provided for ResourceLoader file modules. It is triggered by
the presence of the '.less' extension in stylesheet filenames. LESS files are
compiled by lessc, and the resultant CSS is subjected to the standard set of
transformations (CSSJanus & CSSMin). The immediate result of LESS compilation
is encoded as an array, which includes the list of LESS files that were
compiled and their mtimes. This array is cached. Cache invalidation is
performed by comparing the cached mtimes with the mtimes of the files on disk.
If the compiler itself throws an exception, ResourceLoader constructs a
compilation result which consists of the error message encoded as a CSS
comment. Failed compilation results are cached too, but with an expiration time
of five minutes. The expiration time is required because the full list of
referenced files is not known.

Three configuration variables configure the global environment for LESS
modules: $wgResourceLoaderLESSVars, $wgResourceLoaderLESSFunctions, and
$wgResourceLoaderLESSImportPaths. $wgResourceLoaderLESSVars maps variable names
to CSS values, specified as strings. Variables declared in this array are
available in all LESS files. $wgResourceLoaderLESSFunctions is similar, except
it maps custom function names to PHP callables. These functions can be called
from within LESS to transform values. Read more about custom functions at
<http://leafo.net/lessphp/docs/#custom_functions>. Finally,
$wgResourceLoaderLESSImportPaths specifies file system paths in addition to the
current module's path where the LESS compiler should look up files referenced
in @import statements.

The issue of handling of /* @embed */ and /* @noflip */ annotations is left
unresolved. Earlier versions of this patch included an @embed analog
implemented as a LESS custom function, but there was enough ambiguity about
whether the strategy it took was optimal to merit discussing it in a separate,
follow-up patch.

Bug: 40964
Change-Id: Id052a04dd2f76a1f4aef39fbd454bd67f5fd282f
2013-09-23 12:55:19 -07:00
Max Semenik
19627682ac Move HtmlFormatter from MobileFrontend
This class is needed by CirrusSearch, another application will be API
prop=extracts which doesn't really belong to MobileFrontend and will also
be integrated into core soon.

Change-Id: Ic276e1604c5718e8568e120ddfb9a8fc13a682fc
2013-09-20 11:52:46 -07:00
kaldari
e517e9be57 Removing all disambiguation code from core
Disambiguation related functions have been re-implemented in the
Disambiguator extension.

Bug: 35981
Change-Id: I4afa30bf2677c6541ef355013f8eaef46abfbe03
Dependency: I41637ea43a9e5000bcb8a782441ce36f1068881f
2013-09-05 14:07:51 -07:00
bsitu
04a1021425 Add a deferrable update class for callback/closure udpates
Change-Id: Ifdf2a0937df50eb2f04d514b5cc2ef39a54ebe8f
2013-09-03 23:15:36 -07:00
Brian Wolff
2dd30d0c6d Allow listing old files in Special:ListFiles. Add Special:AllMyUploads
This solves the problem of new users on commons wanting a list of
their files, but something like cropbot modifying it and taking
it off Special:MyUploads.

I'm worried this is a bit hacky to make TablePager work with
two queries. If anyone has any suggestions on how to do this
in a less hacky way, please say.

Some notes:
* This totally removes any revdeleted entries instead
  of dealing with them. Some future iteration can do selective
  deletion.
* Should maybe add links to old versions of files description
  page somewhere. Not sure where in ui that would fit (The date maybe)
  (by old file description page I mean something like flagged revs
  filetimestamp parameter)
* The latest version column should perhaps have "latest" and "old"
  instead of "yes" or "no"
* This is slightly different from the suggestion on the bug report
  as it shows all revisions (instead of say just first revisions).
  I think showing all revisions makes more sense for the "where
  are my uploads" use case. Second of all, the checkbox is not on
  by default.

Bug: 30607
Change-Id: I9e58db1f212e3bb361316c05ef32d4b9c31c6490
2013-08-28 21:42:05 +02:00
Victor Vasiliev
2961884b43 Provide a JSON recent changes feed.
This introduces a new configuration variable, $wgRCFeeds, which allows the user
to configure multiple destinations for RC notifications. It also allows the
notification format to be customized. Two formats are included by default: the
older IRC format and a new JSON format.

Change-Id: I270bde418a82985c94372ac4579100435b6ee026
2013-08-25 21:23:16 -07:00
umherirrender
24bfde2710 Fix spacing and break some lines
Change-Id: Ia57685d8858e02e399ad5c75ce64d12609d340ac
2013-08-24 17:06:25 +02:00
Brian Wolff
14b3f8767b New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
  JS also justifies the images.
  (I think this one is the one that will go over best
  with users.)
*packed-overlay - like packed, but caption goes over
  top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
  visible on hover. Degrades gracefully on screen
  readers, and falls back to packed-overlay if
  you are using a touch screen. I kind of like
  this mode when the caption is not that important
  (ex a category where its just the file name).

This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select

What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").

Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.

Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).

One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.

This should be merged at the same time as Ie82c1548

Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-08-14 20:56:05 -03:00
Aaron Schulz
450e9c3258 jobqueue: cleaned up JobQueue exception handling
* Added JobQueueError exceptions.
* Periodic tasks that fail are logged and skipped.
* JobQueueFederated properly fails over now.

Change-Id: I9d9f0dae548a9dde693a7cd25c255a8bfbf37899
2013-08-13 02:37:35 +00:00
Brian Wolff
ed1c89b884 Add Special:RandomInCategory.
The method used is quite biased, but I believe its the best
possible without a schema change and still being efficient.
I think it is good enough for many of the use cases that
need different articles to pop up, but not "real" randomness.

The method used
is to chose a random timestamp and look at cl_timestamp. This method
will give good results if the timestamps are uniformly distributed
(which probably is not usually true). I think it may give acceptable
results in general, especially given most people are not interested
in true randomness, but more in "give me a result I haven't seen before".
(For example, to pick a random entry in a maintenance category to clean
up).

It also fudges the result a little bit using offset to stop really
biased results from happening. This is mostly meant to stop a
category with an extremely clumped distributed from returning
the exact same article every time. It is not meant to generally
increase randomness.

Bug: 25931
Change-Id: I0c48e4a236b50fb627af94f0df47fef8372ea14d
2013-08-01 10:33:04 -07:00
MatmaRex
ed7979a970 Refactor watchlist token handling
Do not allow the user to change it directly; instead create a form
where they can reset it. (The token can still be changed via the API.)
The token is autogenerated whenever it is shown or otherwise used.

This really should have never used the preferences; however, trying to
change that now would be lots of work for very little gain, so this
keeps using that mechanism, adding a little abstraction over it.

It's not unconceivable that similar tokens could be used for other
pieces of data, like Echo's notifications; this enables that with one
new hook.

----

Things done here:

* Add getTokenFromOption() and resetTokenFromOption() methods to User,
  abstracting out the get-and-generate-if-empty process of handling
  tokens. Respect $wgHiddenPrefs (Watchlist didn't do that
  previously).

* Create Special:ResetTokens, inspired by Special:Preferences and
  Special:ChangeEmail, presenting the token resetting interface
  (HTMLForm-based with CSRF protection).

* Create a new hook, SpecialResetTokensTokens, allowing extensions to
  register tokens to be shown in the resetting form. Each token needs
  information about the preference it corresponds to and a short
  description (used for checkbox label).

* Hide the preference on Special:Preferences (use type=api to achieve
  this), display a link to aforementioned special page instead. Move
  info blurb to its own section at the bottom.

Bug: 21912
Change-Id: I0bdd2469972c4af81bfb480e9dde58cdd14c67a8
2013-07-24 22:06:15 +02:00
Aaron Schulz
1fbb0404f5 Allow for IDatabase to be used as type hints for DatabaseBase|DBConnRef
* Use this in LogEntry to avoid needless type errors

Change-Id: I8644b35b0d9cd171243dd28de52e94ef39d361a7
2013-07-18 03:43:20 +00:00
Aaron Schulz
d921b2fd7e database: added DBConnRef wrapper to manage calling reuseConnection()
Change-Id: Ifc9db62d1ac34d0c6a072d6f2d05bdcf73af14bb
2013-07-15 15:10:45 -07:00
Aaron Schulz
c61d48f87e Stop spamming exception log with random upload stash failures
* Things like authorization and validation problems do not belong in the
  exception log.

Change-Id: I3c4c1bab65cfe9111dc2161bda6d023234112900
2013-06-25 16:10:42 -07:00
Chad Horohoe
84528e2c8b Remove unused class, SearchUpdate is backend-agnostic
Change-Id: I8c91c28ff2bde361490691b4abc107329f0d8194
2013-06-19 16:10:06 -04:00
jenkins-bot
9815539fae Merge "filebackend: throw exceptions during file iteration." 2013-06-19 19:57:32 +00:00
jenkins-bot
8a9576ab5a Merge "Only new vertical format login and signup forms" 2013-06-19 09:13:31 +00:00
S Page
44840d1592 Only new vertical format login and signup forms
* The "VForm" templates replace existing templates.
* Remove useNew switch logic and $wgUseVForm{UserLogin,CreateAccount}.
* The CSS and JS files for forms lose the .vform qualifier, except for
  the CSS for styling vform elements.
* Merge tiny mediawiki.special.userLogin.signup.js into createAccount.js.
* Remove replaced and obsolete messages (see
  https://www.mediawiki.org/wiki/Account_creation_user_experience/Strings
  for details), and remove mention of "new" forms and useNew from
  MessagesQqq.php.

Bug: 46333
Change-Id: I50f25583c3aa9a4a263fb40f50256f92c18ddb4d
2013-06-17 23:29:50 -07:00
Aaron Schulz
754b8babca filebackend: throw exceptions during file iteration.
* This lets calling code be far more robust rather than just
  silently ignoring entries due to some temporary problem.

Change-Id: I3ce2ae34f6cff5e40a80b8da5688503a387ce2a6
2013-06-15 23:01:47 -07:00
Jakub Vrana
b1cc3511fd Prepare DatabaseMysql for mysqli
PHP extensions mysql and mysqli have lots in common.
In order to support mysqli, this diff separates common MySQL behavior to abstract class DatabaseMysqlBase and implements the mysql-extension specific in DatabaseMysql.
Outside behavior remains the same.

I've tried to minimize future code duplication by introducing mysql*() methods even if the parent method just unwraps the result.

Bug: 45288
Change-Id: I905d4a4550377bc849a860f0962dad710d9dc71f
2013-06-12 23:44:24 +00:00
Daniel Friesen
ed6e876688 Drop __autoload.
spl_autoload_register exists in >=5.1.2, we require >=5.3.2
We no longer support hphpc and it looks like hhvm supports spl_autoload_register

We've got no reason to keep using __autoload.
We'll also need to exclusively use spl_autoload_register when we start using composer.json stuff.

Change-Id: I694b7b96825e5d136fa76461511efc9a002149fa
2013-06-11 00:21:42 +00:00
Aaron Schulz
3bc539e1af Moved job queue aggregator classes to a subdirectory.
Change-Id: Iabbf566b05d44e19770db7b4519abfe00e4a8d90
2013-05-27 14:14:29 +00:00
csteipp
4233341283 SECURITY: Do checks on all upload types
Also, verify file before stashing it

Change-Id: Ib2474cb778d53959a4f479e53d0392f916b18d83
2013-05-21 13:20:06 -07:00
Antoine Musso
ea14e46965 autoloader missed some entries
Jenkins does not run the autoloader test (will be fixed in a different
commit).  This patch fix the main and test autoloader to add in all the
missing entries.

bug: 47750
Change-Id: I285fa7ed24a6fc45a4dc475b54d80cf3816436fb
2013-05-21 11:56:26 +02:00
Timo Tijhof
50e7985d4d phpcs: Fix WhiteSpace.LanguageConstructSpacing warnings
Squiz.WhiteSpace.LanguageConstructSpacing:
   Language constructs must be followed by a single space;
   expected "require_once expression" but found
   "require_once(expression)"

It is a keyword (e.g. like `new`, `return` and `print`). As
such the parentheses don't make sense.

Per our code conventions, we use a space after keywords like
these. We appeared to have an unwritten exception for `require`
that doesn't make sense. About 60% of require/include usage
was missing the space and/or had superfluous parentheses.

It is as silly as print("foo") or return("foo"), it works
because keywords have no significance for whitespace between
it and the expression that follows, and since experessions can
be wrapped in parentheses for clarity (e.g. when doing string
concatenation or mathematical operations) the parenthesis
before and after basiclaly just ignored.

Change-Id: I2df2f80b8123714bea7e0771bf94b51ad5bb4b87
2013-05-09 05:56:26 +02:00
jenkins-bot
afd141c543 Merge "Remove Parser_LinkHooks and CoreLinkFunctions classes" 2013-05-08 19:56:11 +00:00
Chad Horohoe
a6d2365015 Revert "Remove Special:ActiveUsers"
This reverts commit 27104686ab.

Revert "Remove link to Special:ActiveUsers from Special:Statistics"

This reverts commit 62949af09e.

I used a sledgehammer where a scalpel would've done--and I should
be whacked with the cluebat. This should be done per-wiki, plus
improvements.

Change-Id: Ib43b42057b8d9f714a8a71ba9cbe375385254b7c
2013-05-05 23:14:21 +00:00
Reedy
612afc2533 Remove Parser_LinkHooks and CoreLinkFunctions classes
Bug: 45371
Change-Id: I06f890153df0cb8f4fb84a73a06a6f5f4817cf3b
2013-05-02 16:43:39 +01:00
jenkins-bot
85e881945d Merge "Create a Special:Redirect page." 2013-04-30 18:34:11 +00:00
C. Scott Ananian
2849d8a6b3 Create a Special:Redirect page.
The primary purpose of this page is to redirect to a user page given a
numeric id.  The numeric User ID is stable across renames, and is
therefore an appropriate primary key for identifying the user
associated with a given revision.  The Parsoid API would like to
export semantic RDFa in its DOM identifying the author of a revision
by their userid, but in order to do so requires a MW redirect from
userid to the appropriate User page.  (A "permalink" for the user.)

This patch adds that redirect, as
  http://somewiki/Special:Redirect/user/1234

(https://bugzilla.wikimedia.org/show_bug.cgi?id=45206 is the related
Parsoid feature.)

Rather than adding a set of ad-hoc redirection pages, this patch
sets up an infrastructure for redirections.  Special:Redirect also
subsumes the functions of:

* Special:Filepath (Special:Redirect/file/xxxx)
* Special:PermanentLink (Special:Redirect/revision/xxxxx)

This structure is extensible for other redirect types.

Change-Id: I8b0785f4fbdb3dd438a7a45263c5f375ff9d2208
2013-04-30 13:40:54 -04:00
Aaron Schulz
32ac151803 Created ProfileSection class to avoid wfProfileOut() whack-a-mole.
Change-Id: I9f7e0638edd99e1ac07b83054e8f7ef255179281
2013-04-28 23:54:33 +00:00
Matthew Flaschen
af7b20570c Create account form with vertical form appearance
Similar to the login form (change 55847), this presents a compact
vertically-stacked form, if a global variable is set or if you add
?useNew=1 to the query string.

The redesigned create account form also:

* Removes the remember me checkbox (see bugzilla 47267)
* Displays some wiki statistics in a benefits column.
* Repositions the FancyCaptcha image if present using JavaScript (see
  bugzilla 47372).
* Sets the template skin as in change 59577.

Bug: 44628
Bug: 47267
Change-Id: I9b03d519af43de147bff0ac509a1154f67cd3a0a
2013-04-23 15:56:02 -07:00
Alexandre Emsenhuber
98a22b0b58 Update AutoLoader
- Move files in includes/externalstore to their own location for consistency
- Order MWCryptRand alphabetically
- Add missing HTMLButtonField

Change-Id: Ib3798dce6080960df68badd6237968a33473e36b
2013-04-23 16:48:24 +02:00
Aaron Schulz
b41a2f8f68 Moved CryptRand.php to MWCryptRand.php
Change-Id: I03e3742f270ccf05ea923a46e8f8171e6f73ffcd
2013-04-23 11:39:39 +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
Aaron Schulz
fc81192a06 [JobQueue] Added JobQueueFederated class for partitioned queues.
* This lets queues be horizontally partitioned onto
  different servers, with weights assigned to each.
  The queue classes used by the different partitions
  can be hetereogenous or homogeneous.
* How partitioning is done is setup similar to LBFactory,
  where wikis belong to sections and sections have config.

Change-Id: I44d59b67cf417dca28a3e9b25371dac5a7ffcb47
2013-04-19 03:27:15 +00:00
Aaron Schulz
ed01e81359 [LockManager] Added a RedisLockManager class.
Change-Id: I7ade74eb307a5075533f36836768af60f106a6b9
2013-04-18 20:18:54 -07:00