multidimension-al / phpbbauth

A Mediawiki extension for phpBB authentication using Auth_remoteuser.
MIT License
5 stars 5 forks source link

Maintainence scripts don't work when plugin installed! #5

Open ajquick opened 5 years ago

ajquick commented 5 years ago

Occasionally the Mediawiki Maintenance scripts will error out.

Warning: require(./../forum/common.php): failed to open stream: No such file or directory in /home/user/public_html/wiki/extensions/Phpbbauth/PhpbbAuth.php on line 31

Fatal error: require(): Failed opening required './../forum/common.php' (include_path='/home/user/public_html/wiki/vendor/pear/console_getopt:/home/user/public_html/wiki/vendor/pear/mail:/home/user/public_html/wiki/vendor/pear/mail_mime:/home/user/public_html/wiki/vendor/pear/net_smtp:/home/user/public_html/wiki/vendor/pear/net_socket:/home/user/public_html/wiki/vendor/pear/pear-core-minimal/src:/home/user/public_html/wiki/vendor/pear/pear_exception:.:/opt/cpanel/ea-php72/root/usr/share/pear') in /home/user/public_html/wiki/extensions/Phpbbauth/PhpbbAuth.php on line 31

This will be fixed in the next version.

ajquick commented 5 years ago

This is a tricky thing to fix given the range of various different possible installs. Maintenance scripts DO work if accessed from the root MW directory.

This works:

php maintenance/script.php

This does not (from maintenance directory):

php script.php

ajquick commented 5 years ago

MediaWiki's extension page describes a potential fix: https://www.mediawiki.org/wiki/Manual:Extensions#Installing_an_extension

Some extensions can conflict with maintenance scripts, for example if they directly access $_SERVER (not recommended). In this case they can be wrapped in the conditional so maintenance scripts can still run.

//for mw.v 1.24.x or less
if ( !$wgCommandLineMode ) {
require_once "$IP/extensions/extension_name/extension_name.php";
}
//for mw.v 1.25.x or above
if ( !$wgCommandLineMode ) {
wfLoadExtension ( '<extension-name>' );
}