1
|
|
|
#! /usr/bin/php -f |
2
|
|
|
<?php |
3
|
|
|
/*- |
4
|
|
|
* FusionForge/Mediawiki integration |
5
|
|
|
* |
6
|
|
|
* Copyright © 2010 |
7
|
|
|
* Roland Mas |
8
|
|
|
* Copyright © 2012 |
9
|
|
|
* Thorsten Glaser <[email protected]> |
10
|
|
|
* All rights reserved. |
11
|
|
|
* |
12
|
|
|
* This file is part of FusionForge. FusionForge is free software; |
13
|
|
|
* you can redistribute it and/or modify it under the terms of the |
14
|
|
|
* GNU General Public License as published by the Free Software |
15
|
|
|
* Foundation; either version 2 of the Licence, or (at your option) |
16
|
|
|
* any later version. |
17
|
|
|
* |
18
|
|
|
* FusionForge is distributed in the hope that it will be useful, |
19
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
20
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21
|
|
|
* GNU General Public License for more details. |
22
|
|
|
* |
23
|
|
|
* You should have received a copy of the GNU General Public License along |
24
|
|
|
* with FusionForge; if not, write to the Free Software Foundation, Inc., |
25
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
26
|
|
|
*- |
27
|
|
|
* Wrapper to call MediaWiki maintenance scripts on a forge project wiki. |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
function usage($rv=1) { |
|
|
|
|
31
|
|
|
echo "Usage: .../mw-wrapper.php [-L] <project> <script> [ arguments... ] |
32
|
|
|
For instance: .../mw-wrapper.php siteadmin importDump.php /tmp/wikidump.xml |
33
|
|
|
.../mw-wrapper.php siteadmin rebuildrecentchanges.php |
34
|
|
|
" ; |
35
|
|
|
exit($rv); |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
if (count($argv) < 3) { |
39
|
|
|
usage(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
$wrapperscript = array_shift ($argv) ; |
43
|
|
|
$fusionforgeproject = array_shift ($argv) ; |
44
|
|
|
if ($fusionforgeproject == "-L") { |
45
|
|
|
if (count($argv) < 2) { |
46
|
|
|
usage(); |
47
|
|
|
} |
48
|
|
|
$fusionforgeproject = array_shift($argv); |
49
|
|
|
$preload_localsettings = true; |
50
|
|
|
} else { |
51
|
|
|
/* |
52
|
|
|
* saves some warnings |
53
|
|
|
* works if the mwscript includes e.g. commandLine.inc |
54
|
|
|
*/ |
55
|
|
|
$preload_localsettings = false; |
56
|
|
|
} |
57
|
|
|
$mwscript = array_shift ($argv) ; |
58
|
|
|
|
59
|
|
|
require_once dirname(__FILE__).'/../../../common/include/env.inc.php'; |
60
|
|
|
require_once $gfcommon.'include/pre.php'; |
61
|
|
|
require_once $gfcommon.'include/cron_utils.php'; |
62
|
|
|
|
63
|
|
|
// Plugins subsystem |
64
|
|
|
require_once($gfcommon.'include/Plugin.class.php'); |
65
|
|
|
require_once($gfcommon.'include/PluginManager.class.php'); |
66
|
|
|
|
67
|
|
|
setup_plugin_manager () ; |
68
|
|
|
|
69
|
|
|
$group = group_get_object_by_name($fusionforgeproject) ; |
70
|
|
|
if (!$group || $group->isError()) { |
71
|
|
|
die("Wrong group! " . |
72
|
|
|
($group ? $group->getErrorMessage() : "") . "\n"); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
if (!$group->usesPlugin('mediawiki')) { |
76
|
|
|
die ("Project doesn't use the Mediawiki plugin\n") ; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
function ffmw_wrapper_fixup_searchpath($username) { |
80
|
|
|
db_query_params("ALTER ROLE $username SET search_path = public", |
81
|
|
|
array()); |
82
|
|
|
} |
83
|
|
|
register_shutdown_function('ffmw_wrapper_fixup_searchpath', |
84
|
|
|
forge_get_config('database_user')); |
85
|
|
|
|
86
|
|
|
$ff_localsettings = forge_get_config('source_path') . |
87
|
|
|
'/www/plugins/mediawiki/LocalSettings.php'; |
88
|
|
|
if ($preload_localsettings) { |
89
|
|
|
define("MEDIAWIKI", true); |
90
|
|
|
require_once($ff_localsettings); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
$src_path = forge_get_config('src_path', 'mediawiki'); |
94
|
|
|
$mwscript = $src_path . '/maintenance/'.$mwscript ; |
95
|
|
|
|
96
|
|
|
array_unshift($argv, $mwscript, '--conf', $ff_localsettings); |
97
|
|
|
|
98
|
|
|
while (@ob_end_flush()) |
99
|
|
|
/* nothing */; |
100
|
|
|
|
101
|
|
|
require_once $mwscript ; |
102
|
|
|
|
This check looks for functions that have already been defined in other files.
Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the
@ignore
annotation.See also the PhpDoc documentation for @ignore.