4 * FusionForge/Mediawiki integration
9 * Thorsten 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 if (count ($argv) < 3) {
31 echo "Usage: .../mw-wrapper.php <project> <script> [ arguments... ]
32 For instance: .../mw-wrapper.php siteadmin importDump.php /tmp/wikidump.xml
33 .../mw-wrapper.php siteadmin rebuildrecentchanges.php
38 $wrapperscript = array_shift ($argv) ;
39 $fusionforgeproject = array_shift ($argv) ;
40 $mwscript = array_shift ($argv) ;
42 require_once dirname(__FILE__).'/../../../common/include/env.inc.php';
43 require_once $gfcommon.'include/pre.php';
44 require_once $gfcommon.'include/cron_utils.php';
47 require_once($gfcommon.'include/Plugin.class.php');
48 require_once($gfcommon.'include/PluginManager.class.php');
50 setup_plugin_manager () ;
52 $group = group_get_object_by_name($fusionforgeproject) ;
53 if (!$group || $group->isError()) {
55 ($group ? $group->getErrorMessage() : "") . "\n");
58 if (!$group->usesPlugin('mediawiki')) {
59 die ("Project doesn't use the Mediawiki plugin\n") ;
62 function ffmw_wrapper_fixup_searchpath($username) {
63 db_query_params("ALTER ROLE $username SET search_path = public",
66 register_shutdown_function('ffmw_wrapper_fixup_searchpath',
67 forge_get_config('database_user'));
69 define( "MEDIAWIKI", true );
70 require_once $gfwww.'plugins/mediawiki/LocalSettings.php' ;
72 $src_path = forge_get_config('src_path', 'mediawiki');
73 $mwscript = $src_path . '/maintenance/'.$mwscript ;
75 array_unshift ($argv, $mwscript, '--conf', $fusionforge_basedir . '/plugins/mediawiki/www/LocalSettings.php') ;
77 while (@ob_end_flush());
79 require_once $mwscript ;