Add a "silent" flag to DeprecatedHooks which causes relevant deprecation
warnings to be suppressed, but still allows call filtering to be used.
Add existing hooks that are documented as deprecated to the array.
Change-Id: Ieeb5e1840fd06d2b7979ef7827ba82bd2a35a2ba
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
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
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
This helps with the common task of resizing a thumbnail without
doing an extra imageinfo API request.
Bug: T244210
Change-Id: I77c68c99a708d3e0a91de31d8a95e217230d2734
Add a third sort order, which returns the column to the initial
order. Use the title and the sort icon to indicate that a third
click will return to the original order.
If sorting multiple columns, the clicked-on column will use the
initial sort order, but restricted by the current orders of any
other sorted columns.
If cells were initially merged, but then became unmerged due to
sorting, this patch does not re-merge them. That could be added
in the future.
Bug: T226697
Change-Id: I11cd7c734e2ff9679db0cdd431a33d040daf2e32
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
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
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
In brief, the BlockLevelPass looks at opening and closing tags on a line
to determine whether it should do paragraph wrapping. The blockElems
want to stop wrapping when opened and start again when closed. The
antiBlockElems want the opposite, to start when they're opened and stop
when closed. "table" is a blockElems and "td"|"th" are anitBlockElems
so that content found in the interstitial spaces of tables are never
paragraph wrapped.
That means that, to date, "caption" elements are always found in a place
where paragraph wrapping is always suppressed and so adding them to that
set won't change any test results. However, a new test is added to spec
out this behaviour.
In the legacy parser, "captions" are always found in the right place
because handleTables runs at an earlier stage. In Parsoid, however, the
treebuilder is relied on to close table cells [0] so when we get to the
token stream paragraph wrappping pass, "caption"s are found in table
cells and therefore get wrapped, even though the treebuilder is about to
be induced to close the cell before opening the caption.
Therefore, in Parsoid, the fix would require us to make captions always-
suppressing to match the legacy parser behaviour. Thus, this change
here is just to keep these lists [1] consistent between the two
parsers.
[0] 5e11a3f390/src/Wt2Html/TokenizerUtils.php (L138-L151)
[1] 5e11a3f390/src/Wt2Html/TT/ParagraphWrapper.php (L71-L78)
Bug: T210647
Change-Id: I8ccefd69d47dca740f50924b235dffa3873d1f99
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
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
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
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
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
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