For compliance with the new version of the table interface policy
(T255803).
This patch was created by an automated search & replace operation
on the includes/ directory.
Bug: T257789
Change-Id: If560596f5e1e0a3da91afc36e656e7c27f040968
The following glasses are marked as newable per the
Stable Interface Policy, even though logically, they should not be
newable. This is done for classes that are currently instantiated
by extensions, and lack an alternative.
A better way for obtaining an instance of these classes should be
created in the future. At that point, direct instantiation should
be deprecated and replaced.
- includes/ApiMain.php - needs factory
- includes/media/BitmapMetadataHandler.php - should become a stateless service or use handler pattern
- includes/GitInfo.php - should become a stateless service
- includes/logging/LogPage.php - should become a stateless service or use command pattern
- includes/logging/ManualLogEntry.php - should become a stateless service or use command pattern
- includes/poolcounter/PoolCounterWorkViaCallback.php - needs a factory
- includes/context/RequestContext.php - needs to be narrowed down, and should use a factory
- includes/search/SearchHighlighter.php - should have a factory
- includes/TitleArrayFromResult.php - should perhaps be part of TitleFactory
- includes/user/User.php - should at least get a factory method for anons
- includes/diff/Diff.php: needs a TextDiffGenerator service or a factory
- includes/EditPage.php: needs a factory
Bug: T247862
Change-Id: I033158e693c98630ee167d9528fc8c9936f978d4
Use AtEase::quietCall() to check $wgGitBin,
instead of direct check. Because `is_file( $wgGitBin )` may
produce a warning if the path is not within open_basedir.
Bug: T74445
Change-Id: I9d7111bea74b859e03873ceccf31ba0b5822b6aa
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
In GitInfo, the debug sentence "Computed cacheFile" could imply that some
file is written, but in reality "computed" refers to the name. Change to
"Candidate cacheFile".
Bug: T215722
Change-Id: I19448e5790a0f2fcb5202170ca03ab0f5e16d24e
Submodules have their git directory in the master repository's directory
(../.git/modules/<name>). firejail does not allow whitelisted paths to
have ".." in them, so use realpath() to get rid of that.
`git show` still wants to be able to access the main repository
directory though, so we also need to whitelist the $repoDir itself.
Bug: T181919
Change-Id: I928df92b47733bc7fbb9c796bcfc1504d4a4598c
Introduces a FirejailCommand class, which can be used to add additional
restrictions to a command, for increased security. For now, firejail
containment needs to be enabled on a per-command basis.
The following restrictions are implemented:
* NO_ROOT - disallows any root access, including via setuid binaries
* SECCOMP - block dangerous syscalls with seccomp
* PRIVATE_DEV - create a private /dev
* NO_NETWORK - deny all network access
* NO_EXECVE - block the execve syscall
A convenient Shell::RESTRICT_DEFAULT is equivalent to NO_ROOT | SECCOMP
| PRIVATE_DEV, with the expectation that more restrictions may be added
to it in the future.
In addition, specific paths can be whitelisted with
Command::whitelistPaths(). Any file/directory that isn't whitelisted in
that top level directory (e.g. /srv) won't exist inside the firejail.
$wgShellRestrictionMethod can be set to false for no restriction system,
'firejail' to explicitly use it, or 'autodetect' to autodetect whatever
system is available. In the future the default should be changed to
autodetection once firejail is tested more.
Bug: T173370
Change-Id: Id74df0dbba40e1e7c07c4368aacffb6eb06a17c5
GitInfo only reads branches in files /refs/heads/*; it should also
read those in /.git/packed-refs.
There are 4 tests in this commit to test this new "feature" and add some
code coverage to other methods. Given this class tests Git behaviour and
MediaWiki itself is versioned with Git, the test data are created during
the tests and removed at the end to avoid interference with Git as CVS.
Bug: T155747
Change-Id: Icccdf3ec797788582f836e2d8e267a1d714d50dc
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.
Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.
This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.
Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
- Provide new %R parameter for $wgGitRepositoryViewers that gives
a non-URL-encoded version of the repo name.
- Don't force repos to end in .git. That's not required and never
has been.
- Finally swap Gitblit urls for Diffusion equivalents
Change-Id: I7d2fb3eea1587be66b88acc6a9b9d17382cb01d5
For ExtensionDistributor to provide git metadata, we need to be able to
store the cache file inside the extension directory itself. The GitInfo
class will now first check if the $wgGitInfoCacheDirectory is populated,
otherwise it will fallback to "$extensionDir/gitinfo.json".
Bug: T122769
Change-Id: Ib3457589ca6899925ae4610cfcdae22af8eaaaeb
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.
Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.
Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.
Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling
Change-Id: I783e4dbfe5f6f98b32b9a03ccf6439e13e132bcc
Depending on the configuration used in LocalSettings.php, $IP can be
changed between the time that configuration is loaded and the wiki
runtime by logic in WebStart.php. Attempt to mitigate the effects of
such changes on the cache file name computation by canonicalizing both
$IP and the path using PHP's realpath() function.
Related but distinct is the possible need to configure the canonical
location for finding cache files on disk separately from
$wgCacheDirectory. This change introduces a new configuration variable
named $wgGitInfoCacheDirectory that can be set to a path that diverges
from the default location of $wgCacheDirectory/gitinfo. This will be
useful in the WMF cluster where $wgCacheDirectory points to a directory
that is not managed by the deployment system.
Finally add wfDebugLog logging to make tracking down issues such as
miscomputed cache paths easier.
Bug: 53972
Change-Id: Iceb9e1ce8d3b4bb08f89fa6ec5d5e7392aaafd46
Ensure that GitInfo::getHead returns a valid value before attempting to
use the git binary to extract a commit date.
Bug: 64948
Change-Id: Ib0d245306842706dbb5d4b9522bb381a5f55526c
Support reading git repository information from a JSON file in the cache
directory. When present, this file serves to provide information needed
by getHead, getHeadSHA1, getHeadCommitDate, getCurrentBranch and a new
getRemoteUrl method. A GitInfo::precomputeValues method is also provided
which can generate the cache file for a given GitInfo instance.
This support can be combined with a deployment step to reduce the need
to repeatedly gather information from the .git files/git binary. It also
allows computing information that can be lost when directory structures
differ between deployment staging hosts and hosts running MediaWiki.
This change also adds memoization of computed values for a given GitInfo
instance which may provide a small performance boost even for
deployments which are not using precomputed cache files.
Bug: 53972
Change-Id: I66e058acc5a71e5d82644f85d819f49d6ee9d1e6
It's possible to have a ')' in a .git/config file, but
parse_ini_file will claim that's invalid and display a warning.
Also prevent another warning from occurring if the parse_ini_file
failed and $configArray is null.
Change-Id: Iba54220be266cb885e83cddfa6c8e9782aa77d01
- Place commas correct
- Moved comments
- Add space after if/foreach/catch
- Reformat some conditions
- Removed trailing spaces/tabs
Change-Id: I40ccda72c418c4a33fcd675773cb08d971510cdb
The patch adds the localised commit date of i) core and ii) extensions
in the Special:Version page tables. It requires the Git version control
system being installed, which is checked during the installation.
Introduces a new parameter for the git binary in DefaultSettings.php:
$wgGitBin = '/usr/bin/git';
Patch authored by DaSch <dasch@daschmedia.de> and updated and fixed
by Wikinaut<mail@tgries.de>.
Bug: 38783
Change-Id: I0931400ecacf91ed2ab4fc7aa46dceac17661768
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.
Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
On my windows under eclipse with EGit there is a directory named .git,
but that gives warning, when read with file_get_contents:
Warning: file_get_contents(/.git) [function.file-get-contents]: failed
to open stream: Permission denied in \includes\GitInfo.php on line 49
Follow up Ieb79c0b4
Change-Id: I7c3ba323460a2fd3739d3912ee6420aa29311f4f
I implemented "the gitfile mechanism" in the GitInfo class so it
can access gitdirs for submodules again.
Bug: 44599
Change-Id: Ieb79c0b401a6bb0f5ca8bff98bb382a8c6ffbb01
My git remote is configured just to be ssh://review/mediawiki/core.git
and I have "review" set up in $HOME/.ssh/config.
Unfortunately, I need to change git remote URLs to make sure
the repository is linked from Special:Version.
This shouldn't be necessary; either we should fallback to the
official MediaWiki git repository or we should add the configuration
option to adapt to local needs.
Change-Id: I2e0b6470c16ec36d0e94cceab844f4a4c4334067
This adds a GitViewers hook to GitInfo, and slightly refactors the
$viewers variable to be called through a function so the hook can be
called. This is so extensions can add their own git repository viewer
to the Special:Version git sha field.
Change-Id: Ifc8396984de6a51be85fb63cd9754d57333bde03
Now that there is a link on the revision hash in Special:Version, do the same in the debug toolbar.
Change-Id: I953ac70e17e72be68251e3908e164dfa46c68bf5
The URL we are crafting are using a short sha1 (7 chars long) which can
have some good chance of pointing to two different sha1. I have seen git
log to use 8 chars from time to time because of sha1 collisions, 62
occurences outu of 45315 commits as of now.
So to play it safe, this patch makes the URL points to the full sha1.
Follow https://gerrit.wikimedia.org/r/43355734eac351 (commit)
9afc1eff1c (merge)
Change-Id: Ic65d0ca89916fe43999b9e3f257d9f322198f9f8
This adds GitInfo which is used by Special:Version to get the SHA1 of
the git repo.
It's also useful for development to put blocks of config in
LocalSettings.php that only apply to branches where you are developing
large features:
if ( GitInfo::currentBranch() == 'myrewriteproject' ) {
// […]
}
Change-Id: I2a76662bb40080be6556d4edf60ac6714f36a727