Browse Source
Replace the use of screen-scraping in the test environment
installation with simply invoking MediaWiki's command-line
installer.
The old code being deleted here relied on our own hardcoded POST
parameter names & the precise layout of MediaWiki's GUI installer at a
given version. Somewhere between [1] and now this inevitably broke.
As far as I can tell there was never a reason for this screen-scraping
hack, when [1] was introduced it hardcoded MediaWiki 1.19.0, the CLI
installer was introduced in 1.17.0. Perhaps the authors weren't aware
of it, or this code was written for an older version.
This allows us to simply delete our own template version of
LocalSettings.php, it'll instead be provided by the CLI installer.
While we're at it let's fix a few things, these changes weren't
practical to split up (I'd need to fix code I was about to mostly
delete)
* Use MediaWiki's own defaults where possible, e.g. before we'd name
the database "wikidb.sqlite", now we'll simply use whatever name
MediaWiki prefers (currently my_wiki.sqlite) by only supplying the
directory name the SQLite file will be dropped into, not the full
path.
* Put all of our database & download assets into a new "mediawiki/"
folder. This makes it easier to reason about as the current &
template "backup" database the tests keep swapping around live
next to each other.
This'll also prevent future potential breakage as there isn't a
single SQLite database. MediaWiki also creates a job queue
database and a couple of cache databases. In practice it seems we
got away with not resetting these when we reset the main database,
but it's the sort of thing that could break in the future (reset,
main store doesn't have the article, but the cache does).
* The "delete" function now only deletes the MediaWiki installation
& database, not the downloaded .tar.gz file. This makes us
friendlier to a developer on a slow connection.
1. 5ef6ad1785
("git-remote-mediawiki: scripts to install, delete and
clear a MediaWiki", 2012-07-06)
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Ævar Arnfjörð Bjarmason
4 years ago
committed by
Junio C Hamano
6 changed files with 79 additions and 334 deletions
@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
|
||||
WEB/ |
||||
wiki/ |
||||
mediawiki/ |
||||
trash directory.t*/ |
||||
test-results/ |
||||
|
@ -1 +0,0 @@
@@ -1 +0,0 @@
|
||||
wikidb.sqlite |
@ -1,129 +0,0 @@
@@ -1,129 +0,0 @@
|
||||
<?php |
||||
# This file was automatically generated by the MediaWiki 1.19.0 |
||||
# installer. If you make manual changes, please keep track in case you |
||||
# need to recreate them later. |
||||
# |
||||
# See includes/DefaultSettings.php for all configurable settings |
||||
# and their default values, but don't forget to make changes in _this_ |
||||
# file, not there. |
||||
# |
||||
# Further documentation for configuration settings may be found at: |
||||
# http://www.mediawiki.org/wiki/Manual:Configuration_settings |
||||
|
||||
# Protect against web entry |
||||
if ( !defined( 'MEDIAWIKI' ) ) { |
||||
exit; |
||||
} |
||||
|
||||
## Uncomment this to disable output compression |
||||
# $wgDisableOutputCompression = true; |
||||
|
||||
$wgSitename = "Git-MediaWiki-Test"; |
||||
$wgMetaNamespace = "Git-MediaWiki-Test"; |
||||
|
||||
## The URL base path to the directory containing the wiki; |
||||
## defaults for all runtime URL paths are based off of this. |
||||
## For more information on customizing the URLs please see: |
||||
## http://www.mediawiki.org/wiki/Manual:Short_URL |
||||
$wgScriptPath = "@WG_SCRIPT_PATH@"; |
||||
$wgScriptExtension = ".php"; |
||||
|
||||
## The protocol and server name to use in fully-qualified URLs |
||||
$wgServer = "@WG_SERVER@"; |
||||
|
||||
## The relative URL path to the skins directory |
||||
$wgStylePath = "$wgScriptPath/skins"; |
||||
|
||||
## The relative URL path to the logo. Make sure you change this from the default, |
||||
## or else you'll overwrite your logo when you upgrade! |
||||
$wgLogo = "$wgStylePath/common/images/wiki.png"; |
||||
|
||||
## UPO means: this is also a user preference option |
||||
|
||||
$wgEnableEmail = true; |
||||
$wgEnableUserEmail = true; # UPO |
||||
|
||||
$wgEmergencyContact = "apache@localhost"; |
||||
$wgPasswordSender = "apache@localhost"; |
||||
|
||||
$wgEnotifUserTalk = false; # UPO |
||||
$wgEnotifWatchlist = false; # UPO |
||||
$wgEmailAuthentication = true; |
||||
|
||||
## Database settings |
||||
$wgDBtype = "sqlite"; |
||||
$wgDBserver = ""; |
||||
$wgDBname = "@WG_SQLITE_DATAFILE@"; |
||||
$wgDBuser = ""; |
||||
$wgDBpassword = ""; |
||||
|
||||
# SQLite-specific settings |
||||
$wgSQLiteDataDir = "@WG_SQLITE_DATADIR@"; |
||||
|
||||
|
||||
## Shared memory settings |
||||
$wgMainCacheType = CACHE_NONE; |
||||
$wgMemCachedServers = array(); |
||||
|
||||
## To enable image uploads, make sure the 'images' directory |
||||
## is writable, then set this to true: |
||||
$wgEnableUploads = true; |
||||
$wgUseImageMagick = true; |
||||
$wgImageMagickConvertCommand ="@CONVERT@"; |
||||
$wgFileExtensions[] = 'txt'; |
||||
|
||||
# InstantCommons allows wiki to use images from http://commons.wikimedia.org |
||||
$wgUseInstantCommons = false; |
||||
|
||||
## If you use ImageMagick (or any other shell command) on a |
||||
## Linux server, this will need to be set to the name of an |
||||
## available UTF-8 locale |
||||
$wgShellLocale = "en_US.utf8"; |
||||
|
||||
## If you want to use image uploads under safe mode, |
||||
## create the directories images/archive, images/thumb and |
||||
## images/temp, and make them all writable. Then uncomment |
||||
## this, if it's not already uncommented: |
||||
#$wgHashedUploadDirectory = false; |
||||
|
||||
## Set $wgCacheDirectory to a writable directory on the web server |
||||
## to make your wiki go slightly faster. The directory should not |
||||
## be publicly accessible from the web. |
||||
#$wgCacheDirectory = "$IP/cache"; |
||||
|
||||
# Site language code, should be one of the list in ./languages/Names.php |
||||
$wgLanguageCode = "en"; |
||||
|
||||
$wgSecretKey = "1c912bfe3519fb70f5dc523ecc698111cd43d81a11c585b3eefb28f29c2699b7"; |
||||
#$wgSecretKey = "@SECRETKEY@"; |
||||
|
||||
|
||||
# Site upgrade key. Must be set to a string (default provided) to turn on the |
||||
# web installer while LocalSettings.php is in place |
||||
$wgUpgradeKey = "ddae7dc87cd0a645"; |
||||
|
||||
## Default skin: you can change the default skin. Use the internal symbolic |
||||
## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector': |
||||
$wgDefaultSkin = "vector"; |
||||
|
||||
## For attaching licensing metadata to pages, and displaying an |
||||
## appropriate copyright notice / icon. GNU Free Documentation |
||||
## License and Creative Commons licenses are supported so far. |
||||
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright |
||||
$wgRightsUrl = ""; |
||||
$wgRightsText = ""; |
||||
$wgRightsIcon = ""; |
||||
|
||||
# Path to the GNU diff3 utility. Used for conflict resolution. |
||||
$wgDiff3 = "/usr/bin/diff3"; |
||||
|
||||
# Query string length limit for ResourceLoader. You should only set this if |
||||
# your web server has a query string length limit (then set it to that limit), |
||||
# or if you have suhosin.get.max_value_length set in php.ini (then set it to |
||||
# that value) |
||||
$wgResourceLoaderMaxQueryLength = -1; |
||||
|
||||
|
||||
|
||||
# End of automatically generated settings. |
||||
# Add more configuration options below. |
@ -1,120 +0,0 @@
@@ -1,120 +0,0 @@
|
||||
<?php |
||||
/** |
||||
* This script generates a SQLite database for a MediaWiki version 1.19.0 |
||||
* You must specify the login of the admin (argument 1) and its |
||||
* password (argument 2) and the folder where the database file |
||||
* is located (absolute path in argument 3). |
||||
* It is used by the script install-wiki.sh in order to make easy the |
||||
* installation of a MediaWiki. |
||||
* |
||||
* In order to generate a SQLite database file, MediaWiki ask the user |
||||
* to submit some forms in its web browser. This script simulates this |
||||
* behavior though the functions <get> and <submit> |
||||
* |
||||
*/ |
||||
$argc = $_SERVER['argc']; |
||||
$argv = $_SERVER['argv']; |
||||
|
||||
$login = $argv[2]; |
||||
$pass = $argv[3]; |
||||
$tmp = $argv[4]; |
||||
$port = $argv[5]; |
||||
|
||||
$url = 'http://localhost:'.$port.'/wiki/mw-config/index.php'; |
||||
$db_dir = urlencode($tmp); |
||||
$tmp_cookie = tempnam($tmp, "COOKIE_"); |
||||
/* |
||||
* Fetches a page with cURL. |
||||
*/ |
||||
function get($page_name = "") { |
||||
$curl = curl_init(); |
||||
$page_name_add = ""; |
||||
if ($page_name != "") { |
||||
$page_name_add = '?page='.$page_name; |
||||
} |
||||
$url = $GLOBALS['url'].$page_name_add; |
||||
$tmp_cookie = $GLOBALS['tmp_cookie']; |
||||
curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie); |
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
||||
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); |
||||
curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie); |
||||
curl_setopt($curl, CURLOPT_HEADER, true); |
||||
curl_setopt($curl, CURLOPT_URL, $url); |
||||
|
||||
$page = curl_exec($curl); |
||||
if (!$page) { |
||||
die("Could not get page: $url\n"); |
||||
} |
||||
curl_close($curl); |
||||
return $page; |
||||
} |
||||
|
||||
/* |
||||
* Submits a form with cURL. |
||||
*/ |
||||
function submit($page_name, $option = "") { |
||||
$curl = curl_init(); |
||||
$datapost = 'submit-continue=Continue+%E2%86%92'; |
||||
if ($option != "") { |
||||
$datapost = $option.'&'.$datapost; |
||||
} |
||||
$url = $GLOBALS['url'].'?page='.$page_name; |
||||
$tmp_cookie = $GLOBALS['tmp_cookie']; |
||||
curl_setopt($curl, CURLOPT_URL, $url); |
||||
curl_setopt($curl, CURLOPT_POST, true); |
||||
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); |
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $datapost); |
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
||||
curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie); |
||||
curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie); |
||||
|
||||
$page = curl_exec($curl); |
||||
if (!$page) { |
||||
die("Could not get page: $url\n"); |
||||
} |
||||
curl_close($curl); |
||||
return "$page"; |
||||
} |
||||
|
||||
/* |
||||
* Here starts this script: simulates the behavior of the user |
||||
* submitting forms to generates the database file. |
||||
* Note this simulation was made for the MediaWiki version 1.19.0, |
||||
* we can't assume it works with other versions. |
||||
* |
||||
*/ |
||||
|
||||
$page = get(); |
||||
if (!preg_match('/input type="hidden" value="([0-9]+)" name="LanguageRequestTime"/', |
||||
$page, $matches)) { |
||||
echo "Unexpected content for page downloaded:\n"; |
||||
echo "$page"; |
||||
die; |
||||
}; |
||||
$timestamp = $matches[1]; |
||||
$language = "LanguageRequestTime=$timestamp&uselang=en&ContLang=en"; |
||||
$page = submit('Language', $language); |
||||
|
||||
submit('Welcome'); |
||||
|
||||
$db_config = 'DBType=sqlite'; |
||||
$db_config = $db_config.'&sqlite_wgSQLiteDataDir='.$db_dir; |
||||
$db_config = $db_config.'&sqlite_wgDBname='.$argv[1]; |
||||
submit('DBConnect', $db_config); |
||||
|
||||
$wiki_config = 'config_wgSitename=TEST'; |
||||
$wiki_config = $wiki_config.'&config__NamespaceType=site-name'; |
||||
$wiki_config = $wiki_config.'&config_wgMetaNamespace=MyWiki'; |
||||
$wiki_config = $wiki_config.'&config__AdminName='.$login; |
||||
|
||||
$wiki_config = $wiki_config.'&config__AdminPassword='.$pass; |
||||
$wiki_config = $wiki_config.'&config__AdminPassword2='.$pass; |
||||
|
||||
$wiki_config = $wiki_config.'&wiki__configEmail=email%40email.org'; |
||||
$wiki_config = $wiki_config.'&config__SkipOptional=skip'; |
||||
submit('Name', $wiki_config); |
||||
submit('Install'); |
||||
submit('Install'); |
||||
|
||||
unlink($tmp_cookie); |
||||
?> |
Loading…
Reference in new issue