4 * FusionForge/Mediawiki integration
8 * Copyright © 2012, 2014, 2015
9 * Thorsten “mirabilos” Glaser <t.glaser@tarent.de>
10 * All rights reserved.
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)
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.
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.
27 * Wrapper to call MediaWiki maintenance scripts on a forge project wiki.
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
38 if (count($argv) < 3) {
42 $wrapperscript = array_shift ($argv) ;
43 $fusionforgeproject = array_shift ($argv) ;
44 if ($fusionforgeproject == "-L") {
45 if (count($argv) < 2) {
48 $fusionforgeproject = array_shift($argv);
49 $preload_localsettings = true;
53 * works if the mwscript includes e.g. commandLine.inc
55 $preload_localsettings = false;
57 $mwscript = array_shift ($argv) ;
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';
64 require_once($gfcommon.'include/Plugin.class.php');
65 require_once($gfcommon.'include/PluginManager.class.php');
67 session_set_admin () ;
69 setup_plugin_manager () ;
71 $group = group_get_object_by_name($fusionforgeproject) ;
72 if (!$group || $group->isError()) {
73 fwrite(STDERR, "Wrong group! " .
74 ($group ? $group->getErrorMessage() : "") . "\n");
78 if (!$group->usesPlugin('mediawiki')) {
79 fwrite(STDERR, "Project doesn't use the Mediawiki plugin\n");
83 function ffmw_wrapper_fixup_searchpath($username) {
84 db_query_params("ALTER ROLE $username SET search_path = public",
87 register_shutdown_function('ffmw_wrapper_fixup_searchpath',
88 forge_get_config('database_user'));
90 $ff_localsettings = forge_get_config('source_path') .
91 '/www/plugins/mediawiki/LocalSettings.php';
92 if ($preload_localsettings) {
93 define("MEDIAWIKI", true);
94 require_once($ff_localsettings);
97 $src_path = forge_get_config('src_path', 'mediawiki');
98 $mwscript = $src_path . '/maintenance/'.$mwscript ;
100 array_unshift($argv, $mwscript, '--conf', $ff_localsettings);
102 while (@ob_end_flush()) {
105 require_once $mwscript ;