Commit graph

555 commits

Author SHA1 Message Date
Timo Tijhof
6ea3f2f4f5 installer: Restore success messages
Bug: T384524
Change-Id: I688e310ab08d4fb83d5dc47bd1fa79617cead9d3
(cherry picked from commit 379d3842bd4fcc2bd0587ea85a81bb68ed5a285a)
2025-02-18 02:01:00 +00:00
Timo Tijhof
dff35eaa42 installer: Fix conflation between warning and info messages
* Fix getInfoBox to not be a warning box, but an information notice
  like it is intended to be.

* Update getInfoBox() to use codex class names, same as showMessage().

* Update getInfoBox() to bold the "Information" title, as per Codex
  examples and guidelines, e.g.
  https://doc.wikimedia.org/codex/latest/components/demos/message.html#multiline

* Remove infoBox() utility, it was used only once, in getInfoBox().
  The `mw-installer-box-*`, `mw-installer-infobox-*` CSS classes
  are also unusd now, however there is nothing to remove because
  these were already removed in a previous refactor.

* Introduce showWarning(), and apply it to showMessage() calls that
  convey non-fatal issues.

Bug: T384524
Change-Id: I6722346ef81a0a9cf8983153271be579905c7898
2025-02-17 03:57:42 +00:00
James D. Forrester
a5387c7c20 Namespace all remaining classes in includes/parser
Bug: T353458
Change-Id: If02cc9b1ff78e26c1cf8c91ee4695845eb133829
2024-10-15 23:54:32 +01:00
thiemowmde
b1c9ec74fa Remove meaningless @var documentation from constants
A constant is not a variable. The type is hard-coded via the value
and can never change. While the extra @var probably doesn't hurt much,
it's redundant and error-prone and can't provide any additional
information.

Change-Id: Iee1f36a1905d9b9c6b26d0684b7848571f0c1733
2024-10-09 09:33:12 +02:00
Tim Starling
11d1a1e13c installer: Merge manual table creation into the create-tables step
* In DatabaseInstaller, merge createTables with createManualTables, as
  was already done in the PG and SQLite subclasses.
* Sort out separation between data and code in stepApplySourceFile().
  Rename it to applySourceFile() and have it take the SQL path instead
  of the name of a method that returns the SQL path. Stop splitting the
  error messages based on step name.
* Fix query error handling. Errors are not ignored here so there is no
  point checking the return value of sourceFile(). Use a cancelable
  atomic section and catch the error.
* In PostgresInstaller, move the determineCoreSchema() call from the
  createSchema step to a getConnection() helper. Assert that the schema
  exists when the connection is requested instead of relying on
  previous steps to establish the state.

Change-Id: I5cc8fcd07a5087fa1df651180de8afcc009af6f2
2024-10-01 19:58:53 +00:00
Tim Starling
bbb4a81dd6 Move services state management out of DatabaseInstaller
* Remove the scattered enableLB() calls from DatabaseInstaller. The
  table creation step should not be responsible for managing the state
  of the service container. We have a full installer step called
  restore-services, and deferring enableLB() until then only affects
  populateInterwikiTable, populateSiteStats, generateKeys and
  insertUpdateKeys, which all use local connection management, not
  LBFactory. This is a breaking change only for the overrides mechanism,
  not for extensions.
* Move DatabaseInstaller::doUpgrade() and its helper outputHandler() to
  WebInstaller, since it is specific to web upgrade. Move state
  management logic from WebInstallerUpgrade to the new method.
* Fix the excessively narrow width of the upgrade output box, which was
  annoying me during testing.

Change-Id: Ica42c4c2e104d5581702e83ae8f9dafadd0053e5
2024-10-01 16:47:30 +00:00
Tim Starling
55ce478281 Unify installer connection handling
Postgres connection handling gave the caller a way to specify what sort
of domain it needed, whereas the base class was implicitly relying on
the sequence of installer steps to ensure that the current connection
was correctly configured. The PG way of doing this is better for planned
work in this area. Exposing PG-style connection management in the base
class reduces the number of differences between PG and everything else.

Instead of PG's method of having up to three connections open, I am just
holding a single connection open, with state transitions properly
implemented.

Also:
* Deprecate direct access to $this->db.
* Factor out definitelyGetConnection(), a throwing variant of
  getConnection().
* Deprecate caling getConnection() with no parameter.
* Remove setupSchemaVars(), since this was a sequence-dependent pattern.
  Instead configure schema vars on transition to the create-schema
  connection type.
* Use SelectQueryBuilder in databaseExists().
* Remove the pg-commit install step. This commit dates back to
  bca55fa58f (March 2007), where in the old installer a commit was
  done after all installation. It was moved here in 2010, but now we
  have a commit in createTables() serving the same purpose. If we need a
  transaction around interwiki insertion, we could do that in the base
  class, but that's not what the original code was trying to do.

Change-Id: I073fb57c1b578361ac2a46ecd0cd1312c31747d4
2024-09-26 12:42:18 +10:00
jenkins-bot
dbb984360a Merge "objectcache: Remove WinCache support" 2024-09-06 01:19:59 +00:00
Máté Szabó
f89aa38f69 objectcache: Remove WinCache support
WinCache is an APCu equivalent for use with Microsoft IIS, but in recent
years has been unmaintained and lacks support for PHP 8 and newer.[1]
So, remove support for it as MediaWiki will be raising the minimum
supported PHP version to 8.1.

[1] https://www.php.net/manual/en/install.windows.recommended.php

Bug: T365691
Change-Id: I4d2dc01a9119bb1f858132f0146b894750c1e86d
2024-09-05 17:59:26 +00:00
Umherirrender
be39a18332 build: Use inline ignore for Generic.CodeAnalysis.AssignmentInCondition
Avoid that new code contains this pattern.

Depends-On: I7a9b5c89129fe4b555d03861f2c3ce3e9e2b2446
Depends-On: Ic2bcc7eeb16d3333dcd019bd209bd7fde843dab9
Depends-On: If20eddd8376ae2e8e29c4e56cd51f7b8eb6642b0
Depends-On: I3414f7e17f4bcb801857bc986bae8eb97aa2bfb8
Depends-On: I38b2729418e8389c681c6cd84858f5e5ed25bd3e
Change-Id: I7cfd2e027edd327cf8be6471e348c137fefacda0
2024-09-01 00:15:10 +02:00
Isabelle Hurbain-Palatin
a3cf629d2f Remove ParserOutput::getText() calls from core (direct pipeline)
This is the second patch of a series of patches to remove
ParserOutput::getText() calls from core. This series of patches should
be functionally equivalent to I2b4bcddb234f10fd8592570cb0496adf3271328e.

This patch replaces the calls to getText where the legacy parser is
called directly by creating a pipeline and invoking it on the generated.
These should probably eventually use the Content framework to generate
output instead of using Parser directly (T371008), which will also allow
them to transparently support Parsoid.

Bug: T293512
Change-Id: I45951a49e57a8031887ee6e4546335141d231c18
2024-08-23 18:15:00 +02:00
James D. Forrester
bc662aec9b Move Language and friends into Language namespace
Bug: T353458
Change-Id: Id3202c0c4f4a2043bf97b7caee081acab684155c
2024-08-10 13:36:30 +02:00
Ebrahim Byagowi
697e19e461 Add MediaWiki\Registration namespace to registration classes
Bug: T353458
Change-Id: Ifa3b6a6e0353bb4ce21a3f4456f1fc696c8d377c
2024-08-10 10:08:22 +00:00
Ebrahim Byagowi
4c270a72ac Add namespace to WikitextContent
It adds MediaWiki\Content namespace to WikitextContent
and two classes related.

Change-Id: Ib74e4c5b3edac6aa0e35d3b2093ce1d0b794cb6d
2024-08-06 17:42:51 +03:30
Bartosz Dziewoński
c9f73efd5a Namespace MessageSpecifier under Wikimedia\Message\
In change I625a48a6ecd3fad5c2ed76b23343a0fef91e1b83 I am planning to
make Wikimedia\Message\MessageValue use it, and we try to pretend that
it is a library separate from MediaWiki, so it makes sense to move
MessageSpecifier to the same namespace under Wikimedia\.

Bug: T353458
Change-Id: I9ff4ff7beb098b60c92f564591937c7d789c6684
2024-07-28 14:21:32 +02:00
Ebrahim Byagowi
fab78547ad Add namespace to the root classes of ObjectCache
And deprecated aliases for the the no namespaced classes.

ReplicatedBagOStuff that already is deprecated isn't moved.

Bug: T353458
Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
2024-07-10 00:14:54 +03:30
Umherirrender
9879723ef3 Use namespaced classes (1)
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: Ic4d4dd61de5ab896fb6173eb579c81f164a1e4a3
2024-06-16 20:18:23 +02:00
Catrope
0493cdd6ec Revert "Installer: Add env check for composer.lock file"
This reverts commit 6e185545a2.

Reason for revert: broke CI in the mediawiki/vendor repo

Change-Id: I7181dcc6689445413be1186bcf9c64a13033e7a0
2024-06-11 17:41:30 -07:00
RazeSoldier
6e185545a2 Installer: Add env check for composer.lock file
Similar to what maintenance/update.php does already.

Bug: T283389
Change-Id: I14dd6c5c944bd6d6d41cf55c264100c713629e74
2024-06-01 23:31:02 +01:00
Tim Starling
917f0a5996 Replace all instances of "per default" with "by default"
According to the dictionary, "per" (or more conventionally "as per")
means "according to". Refer OED "per" sense II.3.a. For example:

"No value was passed, so return null, as per default".

In this sentence, we are not specifying the default, we are referring
to the default. This correct usage of "per default" was used nowhere
in MediaWiki core as far as I can see.

Instead we have "per default" being used to mean "by default", that is,
giving the value to use when no explicit value was specified.

In OED, the phrase "by default" is blessed with its own section just
for computing usage:

"P.1.e. Computing. As an option or setting adopted automatically by a
computer program whenever an alternative is not specified by the user
or programmer. Cf. sense I.7a."

There are highly similar pre-computing usages of the same phrase,
whereas the phrase "per default" is not mentioned.

As a matter of style, I think "per default" should not be used even
when it is strictly correct, since the common incorrect usage makes it
ambiguous and misleading.

Change-Id: Ibcccc65ead864d082677b472b34ff32ff41c60ae
2024-04-29 10:47:54 +10:00
Umherirrender
fb074a584e installer: Migrate to IDatabase::newInsertQueryBuilder
Bug: T353219
Change-Id: I11275c80d81797c8734c99e40b9ca60687e38993
2024-04-14 21:40:35 +02:00
Bartosz Dziewoński
02044a5ba1 Document more methods that accept MessageSpecifier, not just Message
These methods can already handle any MessageSpecifier, but their
documentation didn't show this.

Change-Id: I1323d18baf17a8a27cc9bed31860c4cc89e61a22
2024-04-09 20:25:18 +02:00
daniel
c95fe74bfb Installer: Make the server URL available to init scripts.
Scripts that initialize the database may need to know about the wiki's
URL, see If76b68098512.

Change-Id: I04a43a54c79c6c11146b89b67e1d30ac78520da3
2024-04-09 03:29:31 +00:00
Timo Tijhof
f60c46485a phpunit: Use StaticUserOptionsLookup when storage is disabled
This is an alternate for the workaround in I5987c4f1c3 (c98aeff078).
The service class should not need awareness of MW_PHPUNIT_TEST, or
otherwise have a mixed kind-of-yes/kind-of-not DB dependency.

With this patch, DefaultOptionsLookup is reverted to remove the
test-specific workaround in favour of using StaticUserOptionsLookup
in MediaWikiServices::disableStorage.

This is already called by MediaWikiIntegrationTestCase for tests
that don't enable the database.

Bug: T155147
Depends-On: I906450a4ac2dc51cdc536fbc978661b06f62f0a4
Change-Id: I8720d32fcfb18f7468e2c4b82412fe8664e28ddc
2024-03-27 03:40:14 +00:00
Tim Starling
3f852f7ddc Split web-specific code out of DatabaseInstaller
DatabaseInstaller had some LSP violations, such as calling undeclared
methods of the supplied Installer object, assuming that it was a
WebInstaller. It was also large.

So, split the web form parts of DatabaseInstaller into separate classes.
We have a class hierarchy for the connect forms, and a class hierarchy
for the settings forms, with a base class DatabaseForm mostly as a place
to put protected helper methods.

Also, have DatabaseInstaller::getConnection() return a special subclass
of Status, so that we can remove many Phan type overrides.

Change-Id: Ie84025f8f70b895fa6882848b9a21ba1750d60e2
2024-03-13 13:04:13 +11:00
Subramanya Sastry
e55cc517da Move Parser to Mediawiki\Parser namespace
Bug: T166010
Co-Authored-By: Daimona Eaytoy <daimona.wiki@gmail.com>
Co-Authored-By: James Forrester <jforrester@wikimedia.org>
Co-Authored-By: Subramanya Sastry <ssastry@wikimedia.org>
Change-Id: I79b4e732c45095eedbaa80afa5eb7479b387ed8a
2024-02-16 09:18:38 -05:00
James D. Forrester
102a4f8a35 build: Upgrade mediawiki/mediawiki-phan-config from 0.13.0 to 0.14.0 manually
* Switch out raw Exceptions, mostly for InvalidArgumentExceptions.
  * Fake exceptions triggered to give Monolog a backtrace are for
    some reason "traditionally" RuntimeExceptions, instead, so we
    continue to use that pattern in remaining locations.
* Just entirely give up on PostgresResultWrapper's resource vs. object mess.
* Drop now-unneeded false positive hits.

Change-Id: Id183ab60994cd9c6dc80401d4ce4de0ddf2b3da0
2024-02-10 02:22:41 +00:00
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
Reedy
e2f9bea62b Fix casing of Mediawiki to MediaWiki
Change-Id: I0f266a034a99255b27fd96d82335d6e710a61f20
2024-01-29 17:15:04 +00:00
Reedy
1c0692d19e installer: Namespace remaining classes
Change-Id: I11a8df30a2117ef29a4ade25f1082f25eb18490a
2024-01-13 23:45:14 +00:00
Reedy
8600ee105c installer: Namespace more installer classes
Change-Id: If58d96c311bef728446b517bb7a81316b23aad4d
2024-01-13 23:42:08 +00:00
jenkins-bot
9ba2b79a5b Merge "Namespace WebInstaller classes" 2024-01-12 01:23:25 +00:00
Reedy
29b4540718 Namespace WebInstaller classes
Change-Id: Iac081a08681048c56b20c7789c5efb50a756d167
2024-01-11 23:29:14 +00:00
Tim Starling
9e0ab669f0 Installer: Remove Creative Commons license chooser iframe
This chooser has been removed from the Creative Commons website, and the
URL we are using now redirects to an apparently random 2006 blog post.

There is a new license chooser, with source at
https://github.com/creativecommons/chooser , but it does not support the
kind of embedding we need.

So, remove the feature.

Change-Id: I400777b2ae80198ba1db6bd105de38903afced6f
2024-01-11 14:05:11 +11:00
Amir Sarabadani
f9489bf422 installer: Add support for adding schema updates on virtual domains
It is not elegant but it works. Any other solution involved rewriting
all of db updater since the db gets directly injected.

Bug: T314908
Change-Id: Ic9ee73e8e47582abe3f3d79fd107ea2845ee32aa
2023-12-21 13:26:38 +00:00
Kosta Harlan
06176a71b4
mw-install:sqlite: Load DevelopmentSettings
Why:

- We want developers to have DevelopmentSettings loaded by default

What:

- Define a new `--with-developmentsettings` argument for install.php,
  Set it to true in the `composer mw-install:sqlite` invocation

For now, this option is not supported in the web installer.

Bug: T347347
Change-Id: Icba2d614fd1349463fb745ef31f53a3b3834e5ad
2023-11-29 10:00:48 +01:00
James D. Forrester
67217d08df Namespace remaining files under includes/deferred
Bug: T166010
Change-Id: Ibd40734b96fd2900e3ce12239d09becfb4150059
2023-11-22 10:08:53 -05:00
Ammarpad
25dff148d1 Installer: Make Minerva works correctly for $wgDefaultSkin
Bug: T346332
Change-Id: Icac11717b6f26fa844008ec394ba6054f4299bb5
2023-10-05 12:41:29 +01:00
James D. Forrester
c1599c91b3 Namespace Config-related classes under \MediaWiki\Config
Bug: T166010
Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
2023-09-21 05:41:58 +00:00
James D. Forrester
1d0b7ae1e2 Namespace User under \MediaWiki\User
Bug: T166010
Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
2023-09-19 19:18:16 +00:00
Amir Sarabadani
f4e68e055f Reorg: Move Status to MediaWiki\Status\
This class is used heavily basically everywhere, moving it to Utils
wouldn't make much sense. Also with this change, we can move
StatusValue to MediaWiki\Status as well.

Bug: T321882
Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3
Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
2023-08-25 15:44:17 +02:00
Umherirrender
1086958611 Replace array_keys in foreach to use $_ as value instead
When the value of the associated array is not used, there is no need to
use array_keys and create internal a copy of the array, just omit the
value with $_ to tell static analyzer that the var is unused.

Change-Id: I5c6d667e98c0167c0573c683f0d617bc1d4ca619
2023-07-10 02:53:52 +00:00
Amir Sarabadani
5e453406e5 Change the default skin from Vector to Vector-2022
Bug: T301527
Change-Id: I2ce293be5622f471dd140334a15b3a85abef51c1
2023-05-20 16:58:10 +02:00
Kevin Israel
07e0903051 Installer: Remove PCRE minimum version and Unicode support checks
PHP 7.3 and later require PCRE2 version 10.30 or later. The original
PCRE library is no longer supported, so it is no longer necessary to
check for old versions of it.

The check for Unicode support is also useless. As mentioned in the doc
comment, it does not run early enough in the installation process. (And
unlike the original PCRE, PCRE2 cannot be compiled with UTF-8 support
but without Unicode property support.)

That leaves one remaining PCRE check in the installer, which was added
not long ago in eaa534b189 and clearly is applicable to PCRE2. I
changed the error message to refer specifically to the "PCRE2 library",
as well as to the "--enable-newline-is-any" configure option (rather
than a value that is less likely to appear in package and port build
scripts and that had already been changed for PCRE2).

The --skip-compat-checks option is removed from update.php; the script
no longer performs checks beyond those performed by PHPVersionCheck. It
is possible to run environment checks manually from the command line
using install.php --env-checks.

Change-Id: Iab9a28451cfc9dd28fe3394cc24a7dd7cea3fd7e
2023-05-20 11:19:31 +03:00
Umherirrender
13cfcaea5d installer: Register autoload classes in Installer::includeExtensionFiles
The global was removed in be3018b but it is not unused,
it is needed to let the require_once put something into the array

Bug: T335626
Change-Id: I0b5b02fe8970ab3d7afa018c615e7cbc14e58512
2023-04-30 15:02:08 +02:00
Tim Starling
be3018b268 Just another 80 or so PHPStorm inspection fixes (#4)
* Unnecessary regex modifier. I agree with this inspection which flags
  /s modifiers on regexes that don't use a dot.
* Property declared dynamically.
* Unused local variable. But it's acceptable for an unused local
  variable to take the return value of a method under test, when it is
  being tested for its side-effects. And it's acceptable for an unused
  local variable to document unused list expansion elements, or the
  nature of array keys in a foreach.

Change-Id: I067b5b45dd1138c00e7269b66d3d1385f202fe7f
2023-03-25 00:39:06 +00:00
jenkins-bot
a9209f4749 Merge "Check images server responses for nosniff" 2023-03-21 10:11:38 +00:00
Derk-Jan Hartman
cd64644247 Check images server responses for nosniff
Bug: T309787
Change-Id: Ife72869e85be72aee27649b9bdbfacb196c9f493
2023-03-07 10:17:57 +00:00
James D. Forrester
ad06527fb4 Reorg: Namespace the Title class
This is moderately messy.

Process was principally:

* xargs rg --files-with-matches '^use Title;' | grep 'php$' | \
  xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1'
* rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \
  xargs rg --files-with-matches 'Title\b' | \
  xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1'
* composer fix

Then manual fix-ups for a few files that don't have any use statements.

Bug: T166010
Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a
Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
2023-03-02 08:46:53 -05:00
daniel
7dcfbf2a62 Allow some maintenance scripts to be called without a LocalSettings
Subclasses of Maintenance that can function without database access can
now override canExecuteWithoutLocalSettings to return true.
This is useful for scripts that need to be able to run before or without
installing MediaWiki.

When no config file is present, the storage backend will be disabled.
Any attempt to access the database will result in an error.

NOTE: This makes MediaWikiServices::disableBackendServices() more
comprehensive, to avoid premature failures during service
construction. This change makes it necessary to adjust how the
installer manages service overrides.

The CLI installer is covered by CI, I tested the web installer
manually.

Change-Id: Ie84010c80f32cbdfd34aff9dde1bfde1ed531793
2023-02-16 21:11:33 +00:00