Commit graph

8871 commits

Author SHA1 Message Date
jenkins-bot
8d7015037d Merge "MultiTitleFilter: Use prefixed text for form display" 2020-06-02 15:58:03 +00:00
Kosta Harlan
d51ed7c3d2 MultiTitleFilter: Use prefixed text for form display
This allows us to distinguish between "Foo" and "User:Foo" in the UI.

Follows-Up: Ia0ddf78646ec4c8ae0b84b6d5b46ef5e51c8e8c1

Change-Id: I960cbd566e444380a253bde364bc9da7e2975823
2020-06-02 12:23:35 +00:00
DannyS712
1ccf066380 Add a new UserEditTracker service for user edit counts and timing
Moved to the new service are the following User:: methods:
* ::getEditCount
* ::getFirstEditTimestamp
* ::getLatestEditTimestamp
* ::getEditTimestamp
* ::initEditCountInternal

A subsequent patch will replace existing uses in core and deprecate the
User methods.

The new service has 100% test coverage with pure Unit tests.

Bug: T253431
Change-Id: If96f9d41026aa358c0fe269a3e078af5f6f058f2
2020-06-02 03:00:05 +00:00
jenkins-bot
a72ed25ea0 Merge "Bring RevisionRecord code coverage to 100%" 2020-06-02 00:40:41 +00:00
jenkins-bot
1fd6b9aee4 Merge "Test exceptions thrown in RenderedRevision" 2020-06-02 00:02:59 +00:00
DannyS712
b6f020ff66 ContentHandlerFactory: Inject LoggerInstance instead of using wfDebugLog
Change-Id: Ifed1f2e28a5fec365103b1588a8cabff10ce6007
2020-06-01 22:37:12 +00:00
jenkins-bot
9a5426d56c Merge "Stop throwing an exception in UploadStash::getExtensionForPath" 2020-05-31 02:58:50 +00:00
Reedy
d0d4d903cc Stop throwing an exception in UploadStash::getExtensionForPath
The exception serves no purpose, and can only really be triggered via
a test. The API prevents no file extension at all, as does UW js.

This function (for whatever reason, probably a seperate bug) cannot
get the extension from a stashed stl file (seems to work fine for
other types).

With what/how it's actually used, it doens't really matter if
we can't get the extension, we get it by more robust methods later
on.

This partially reverts 0a82600a27. Before the changes in that commit,
the exception was unreachable.

Bug: T254078
Change-Id: I0a7bd13fe8e08c7d4a75b4a3709661dbbf53d6cb
2020-05-31 02:02:35 +00:00
DannyS712
d6a38d0f10 Add ContentModelChangeFactory, implemented by PageCommandFactory
Bug: T253080
Change-Id: I62eda1163cd5b0472af912e8dbd5843df8303b8d
2020-05-30 22:36:16 +00:00
Daimona Eaytoy
2b37cfaf18 build: Bump mediawiki-codesniffer to 31.0.0
Done with `composer fix` and suppressing the rest (i.e. sniffs for
global variables, which for core should be suppressed anyway).

Additionally, add `-p` to `phpcbf`, as otherwise it just seems stuck.

Change-Id: Ide8d6cdd083655891b6d654e78440fbda81ab2bc
2020-05-30 14:56:28 +00:00
Tim Starling
68c433bd23 Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.

General principles:
* Use DI if it is already used. We're not changing the way state is
  managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
  is a service, it's a more generic interface, it is the only
  thing that provides isRegistered() which is needed in some cases,
  and a HookRunner can be efficiently constructed from it
  (confirmed by benchmark). Because HookContainer is needed
  for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
  SpecialPage and ApiBase have getHookContainer() and getHookRunner()
  methods in the base class, and classes that extend that base class
  are not expected to know or care where the base class gets its
  HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
  getHookRunner() methods, getting them from the global service
  container. The point of this is to ease migration to DI by ensuring
  that call sites ask their local friendly base class rather than
  getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
  methods did not seem warranted, there is a private HookRunner property
  which is accessed directly. Very rarely (two cases), there is a
  protected property, for consistency with code that conventionally
  assumes protected=private, but in cases where the class might actually
  be overridden, a protected accessor is preferred over a protected
  property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
  global code. In a few cases it was used for objects with broken
  construction schemes, out of horror or laziness.

Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore

Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router

setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine

Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-05-30 14:23:28 +00:00
Thiemo Kreuz
3f48ae3dcf Fix misplaced expected test value in WebRequestTest
Change-Id: I866344b1ecba1e1465f933a37973f7936bd6575d
2020-05-29 08:22:51 +02:00
jenkins-bot
bbce47b29d Merge "Call ob_start() before running tests" 2020-05-29 02:55:56 +00:00
jenkins-bot
5a412a6046 Merge "Use HTML5 semantics for self-closed HTML tags in wikitext" 2020-05-28 23:02:54 +00:00
jenkins-bot
8cbf108de7 Merge "immobile-source-namespace: use blanknamespace for main namespace" 2020-05-28 21:32:09 +00:00
jenkins-bot
24688cc0c5 Merge "mime: Update usage of MimeAnalyzer methods" 2020-05-28 20:32:05 +00:00
Ori Livneh
19931e069f mime: Update usage of MimeAnalyzer methods
Follow-up to I93bd71ec1.

Bug: T252228
Change-Id: I45c9fc592c9e41e0868e7d965206d4c04f4f92e1
2020-05-28 20:13:47 +00:00
jenkins-bot
aef18790c6 Merge "ExtensionRegistry: Remove exporting and caching of wgExtensionCredits" 2020-05-28 19:12:06 +00:00
Timo Tijhof
5d8f62bdd3 ExtensionRegistry: Remove exporting and caching of wgExtensionCredits
This data is the same as the 'credits' data that is already compiled,
cached and made available via ExtensionRegistry.

Similar to various other configuration variables previously, the
$wgExtensionCredits variable is now also required to only be used
for providing input to the system (e.g. from LocalSettings.php,
or from legacy extension PHP entry points). It is no longer
supported to use this variable to reliably read out a full view
of all extension credits (specifically those registered via
extension.json).

Doing so had the downside of adding processing cost to every
web request, as well as taking one the single largest portion
of the ExtensionRegistry APCu cache key, which in PHP7+ incurs
a linear cost for every string value, string key, of every
(sub)array in this huge structure; and does to on every request
just in case something reads from $wgExtensionCredits.

The new method to access this information reliably is owned
by SpecialVersion for now (could be moved elsewhere). This
also makes the merging logic more testable and incurs it on-demand
rather than upfront.

Details:

* Move 'type' internally from NOT_ATTRIBS to CREDIT_ATTRIBS.
  These two arrays behave identically for most purposes (they are
  both used to mean "don't export this as a global attribute").

  By placing it in CREDIT_ATTRIBS it becomes complete and makes
  it easy to refer to in docs. Previously, extractCredits()
  read the 'type' key outside the loop for CREDIT_ATTRIBS.

* Remove redundant code in ApiBase.php, that is now more obviously
  redundant. Looks like a left-over or merge conflict mistake
  from when ExtensionRegistry was first introduced.

Bug: T187154
Change-Id: I6d66c58fbe57c530f9a43cae504b0d6aa4ffcd0d
2020-05-28 18:46:41 +00:00
Ori Livneh
7e01e86e09 mime: Represent lists as arrays instead of space-delimited strings
Deprecate the interfaces in MimeAnalyzer that return lists as
space-separated strings in favor of replacement methods that return
arrays.

Deprecated:

 - ::getExtensionsForType( $mime ) : string|null
 - ::getTypesForExtension( $ext ) : string|null
 - ::guessTypesForExtension( $ext ) : string|null

Added:

 - ::getExtensionsFromMimeType( $mime ) : string[]
 - ::getMimeTypesFromExtension( $ext ) : string[]
 - ::getExtensionFromMimeTypeOrNull( $mime ) : string|null
 - ::getMimeTypeFromExtensionOrNull( $ext ) : string|null

- "From" is clearer than "For"[1] and is neatly symmetrical with "To"
  (viz. ::mExtToMime and ::mMimeToExt).
- "MimeType" is less ambiguous than "Type", which in this context may
  refer either to media type or MIME type.
- "{..}OrNull" is better because it helps users remember to handle a null
  return value. Putting the "OrNull" at the end (getXFromYOrNull) is
  better than putting it in the middle (getXOrNullFromY) because it's
  harder to ignore that way, at the cost of a very slight grammatical
  ambiguity.

Usage in Core will updated in a separate commit.

Lastly, this change prepares for the deprecation of mutating the public
'mExtToMime' attribute as a means of registering extensions. It will be
formally deprecated in a follow-up change.

  [1]: Positive signal: https://developer.android.com/reference/android/webkit/MimeTypeMap#getMimeTypeFromExtension(java.lang.String)

Bug: T252228
Change-Id: I93bd71ec18492722f05c66e0a2945d93281c3100
2020-05-28 15:15:43 +00:00
jenkins-bot
af7939b830 Merge "Add $originalOptions parameter to UserSaveOptions hook" 2020-05-28 11:03:05 +00:00
Timo Tijhof
45da13803d resources: Bundle ajax patrol and ajax rollback code
Create a small "curate"-related bundle of moderation and review
enhancements. The overlap between the two is not perfect, but the
scripts are small enough that it doesn't seem worth trying to
create separate bundles for.

Change-Id: Ibd00e0eddfafc57323b147e225ee668528dc1c1c
2020-05-28 07:22:07 +00:00
jenkins-bot
ff12b51ee5 Merge "Hard deprecate Revision::getParentId and ::getVisibility" 2020-05-28 00:21:12 +00:00
Aaron Schulz
f0039707a2 Avoid HtmlCacheUpdateJob purges for content no longer in CDN
Bug: T250205
Change-Id: I0ddac44ec40e51acb8c76feff37c11481d724798
2020-05-27 23:36:54 +00:00
DannyS712
511fd87645 Hard deprecate Revision::getParentId and ::getVisibility
Bug: T250980
Bug: T250714
Change-Id: I8084607090266687395612be26ad2c06f9a60baa
2020-05-27 23:35:18 +00:00
jenkins-bot
d535ebeb51 Merge "WatchedItemStore: Enforce a maximum watchlist expiry duration" 2020-05-27 22:32:06 +00:00
jenkins-bot
1a5db8c1c5 Merge "Inject SpamChecker where needed, hard deprecate EditPage static methods" 2020-05-27 18:48:58 +00:00
jenkins-bot
5249fa5139 Merge "Hard deprecate Revision::getUserText, ::isMinor, and ::isCurrent" 2020-05-27 18:29:50 +00:00
C. Scott Ananian
05bc687111 Use HTML5 semantics for self-closed HTML tags in wikitext
This behavior has been deprecated and with a tracking category since
1.28.  Time to remove the temporary parameter added to
Sanitizer::removeHTMLtags() and (finally) tweak the behavior to match
HTML5.

Bug: T134423
Change-Id: I5c725175d05854139c95a2b3d8d35ff63cb6707b
2020-05-27 11:59:18 -04:00
Petr Pchelko
82bf390ed5 Add $originalOptions parameter to UserSaveOptions hook
Since the hook interfaces are not yet released and adding a parameter
to the hook is b/c, I have just added a parameter without introducing
a new version of the hook interface

Bug: T253149
Change-Id: Iac6c4b706ddbc7b0c9fb0b40eba05bd3530b1fdf
2020-05-27 08:32:40 -07:00
jenkins-bot
2f7fbab5ea Merge "Add tests for Hook run call sites" 2020-05-27 03:41:50 +00:00
DannyS712
1e36b2c12f Hard deprecate Revision::getUserText, ::isMinor, and ::isCurrent
Bug: T250579
Bug: T250580
Bug: T250608
Change-Id: I89ac77c436245cad3e746b33aec5a42247fda67d
2020-05-26 22:19:54 +00:00
jenkins-bot
f11aee48da Merge "CreationHandler: fix redirect URL" 2020-05-26 19:07:43 +00:00
Reedy
229b2c15e8 Fix a plethora of class and function call case mismatches
Bug: T231412
Change-Id: I597a25de3294a6673424f30475760280ef209a8a
2020-05-26 14:14:46 +01:00
jenkins-bot
9d1bd65aa2 Merge "REST Handler: add unit tests for base class" 2020-05-26 10:53:00 +00:00
daniel
ad6879e6b6 REST Handler: add unit tests for base class
This adds unit tests for the Handler base class.

This includes tests for public and protected methods.
Since the Handler base class is an extension point, the protected methods
are part of the stable public interface.

Change-Id: Ibe9fcbb139683dad03b92cd0618c3c0e8feb8b94
2020-05-26 10:33:36 +00:00
DannyS712
35c0518959 Inject SpamChecker where needed, hard deprecate EditPage static methods
Bug: T251015
Change-Id: I2df950d5ac9a7fc342409f778d7f9c2418cdd7af
2020-05-26 03:17:29 -07:00
daniel
504e9c446f CreationHandler: fix redirect URL
Add missing version prefix to Location header emitted after successful
creation.

Bug: T253143
Change-Id: I6262f61668cefacce12ed6f2a976340e10cf105b
2020-05-25 11:13:18 +02:00
Tim Starling
bd5420da23 Call ob_start() before running tests
The policy introduced for T206476 creates a subtle failure mode: any test
writing to stdout will cause headers to be sent, causing later tests to
fail when they try to call header().

Instead, call ob_start() to intercept test output. Any buffered output is
still seen when PHPUnit exits.

Bug: T206476
Change-Id: Id085efeab67d1e700ffcbf37868b5107e3a7e5d5
2020-05-25 13:55:28 +10:00
jenkins-bot
67d6d6d14a Merge "Revision: Ensure getRevisionByTitle() works for foreign wikis" 2020-05-25 01:59:01 +00:00
jenkins-bot
78b1ff0ec9 Merge "linker: Move Linker::normaliseSpecialPage to LinkRenderer class" 2020-05-24 23:31:43 +00:00
jenkins-bot
a5f1fe5827 Merge "ParserOptionsTest: Rename non-global variable $wgLang" 2020-05-24 23:31:34 +00:00
Derick A
707567bd73 linker: Move Linker::normaliseSpecialPage to LinkRenderer class
Would have love to just kill Linker::normaliseSpecialPage() but
the deprecation policy has to be followed and we'll drop the above
method in 1.36.

For now, we'll just soft and hard deprecate it, also, callers have
been updated.

Dependency inject SpecialPageFactory to LinkRenderer service and
note that ->normalizeTarget() is only for internal use by Linker
& DummyLinker via their `->normaliseSpecialPage()` methods.

Also, updated unit tests to capture injecting the special page
factory class.

Change-Id: I951403c89ff497fd1f7441ad0304dd5bc9442ad7
2020-05-24 23:11:55 +00:00
DannyS712
a8ba047008 ParserOptionsTest: Rename non-global variable $wgLang
Bug: T160814
Change-Id: I281e71e22f335427829e07b9fce25a753e7f5246
2020-05-24 23:10:55 +00:00
Ori Livneh
7c9e19ed5e mime: Document null return from MimeAnalyzer::improveTypeFromExtension()
This method returns null when $mime is 'unknown/unknown' and the file
extension is unknown to MediaWiki. The inline documentation and @return
annotation omitted this.

I don't think this was an intentional design choice, but it's the
existing behavior and I'm not sure it's safe to change.

Since it is the existing behavior, document it and add a test case, to
ensure that any changes to this behavior are intentional.

Bug: T253483
Change-Id: Ie6615a4bd9ae77e9ab59cfe76edb237cace693b1
2020-05-24 15:51:08 -04:00
jenkins-bot
c33ca73e03 Merge "VueComponentParser: Add test case for self-closing tags" 2020-05-23 20:01:19 +00:00
Aaron Schulz
88e17d3f7c filerepo: make LocalRepo::getSharedCacheKey() use makeGlobalKey()
Also rename image_redirect key to file_redirect while at it.
This assures that stale keys are not still in use.

Bug: T253405
Change-Id: I31a9bb6672b33fbfa1b974955d78fdfd8d58f5da
2020-05-23 17:32:55 +00:00
Roan Kattouw
f6135a5995 VueComponentParser: Add test case for self-closing tags
Some HTML parsers don't deal with this the way we want. libxml does, so
this test case passes, but I'm adding it for if we try switching to a
different HTML parser that breaks this.

Change-Id: I02d14e1d78320217646cda9691a78bcbf2005f52
2020-05-22 22:16:01 -07:00
Ori Livneh
9971d4dced mime: Add test for MimeAnalyzer::addExtra{Types,Info}
..and for adding file extensions by modifying the mExtToMime field.
All three interfaces will be deprecated in a follow-up change.

Change-Id: I7ec940a8b2fe02cd0fe01593cd6897f75777a8fa
2020-05-23 01:11:41 -04:00
jenkins-bot
276261bcf6 Merge "upload: Fix incorrect handling of missing file extension in UploadStash" 2020-05-23 01:08:58 +00:00