News:

Wondering if this will always be free?  See why free is better.

Main Menu

SMF and MediaWiki Bridge

Started by rsw686, February 08, 2008, 08:28:51 PM

Previous topic - Next topic

gubius

Hi, I've tried your bridge today. Well it works fine as long as I am logged in as a user of SMF. But if i want to enter the wiki as "guest"(not logged in), I always get an "500 internal Server Error". The only question is, why? :) I could think of a problem with "register_globals" which is off on my server. Are you using globals in your Bridge?

Thanks for any Help, and keep up the work ;)

rsw686

Is this your own server? If so reload apache. I have php setup with fast-cgi and I know media wiki will segfault php once every couple of weeks. I haven't found the cause, but it happened whether or not I was using the bridge. At that point I would get the 500 internal server errors. However I did some research and I heard that disabling apc should stop the segfaults, I did that the other day and am waiting to see.
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

gubius

No it isn't my own server, it's hosted by "ovh.net". But I get the 500 error only when i set
"$wgSMFLogin = true;". When I leave the # befor it to comment it, everything works, but the autologin would be nice and easy :)

rsw686

The only thing I can think of is what I mentioned above. If php is being run by fast-cgi it will keep multiple threads open. One thread would segfault and I would receive the internal 500 error repeatedly on select pages being handled by that thread.

Other than that I'm not sure what the problem could be. The 500 server error issue is hard to diagnose without having access to the server logs to see what actually happened. You could make a page with <?php phpinfo(); ?> and see how php is being run and if apc is installed.

If so you might point your host to this link. I know multiple linux distros are affected. The fix is to disable apc or install an older version. Although since it is 2008 now the newest version of apc might work as well. It seems to occur most on 64-bit intel servers, which mine is.

http://pecl.php.net/bugs/bug.php?id=7141
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

gubius

well on my phpinfo I could find anything about apc, and the only thing with cgi was this:
"Server API    CGI "

rsw686

Hmm I'm not sure. Does the host put the error logs in your site folder? If so you could see what it states. Otherwise you might give your host the link to the page that gives the 500 server error and ask them to let you know what the error is. It should be easy enough for them to tail the error log and then click the link.
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

Skuzzy

#66
Well, i took a shot at installing this and am having major problems.

When I add the variables and so on to the LoclSettings.php file and make appropriate adjustments, when I try to use the mediawiki log out on th page, I get a page not found error.

I am not running any caching.  It is my own Solaris 5.10 server running, PHP 5.2.5, MySQL 5.1.23(rc), SMF 1.1.4, MediaWiki 1.12.0, and Apache 2.0.63.  Any thoughts?  What else do you need?

EDIT: More information.  If I change "$wgSMFLogin" to false, then everything seems to be fine.  What does that variable actually do?  When I set it to "true", I get page not found errors when I try to logout.

Slack

Sounds like the path to your forum is not correct, it cannot find your forum log out page - did you follow this example?

# Example: /public_html/forum and /public_html/wiki -> ../forum
$wgSMFPath = "../forum";


rsw686

Quote from: Slack on April 09, 2008, 04:11:12 PM
Sounds like the path to your forum is not correct, it cannot find your forum log out page - did you follow this example?

I don't think that is the issue as it checks for the Settings.php file existence and will give you an error stating "Check to make sure $wgSMFPath is correctly set in LocalSettings.php!"

Quote from: Skuzzy on April 09, 2008, 03:41:42 PM
EDIT: More information.  If I change "$wgSMFLogin" to false, then everything seems to be fine.  What does that variable actually do?  When I set it to "true", I get page not found errors when I try to logout.

Sounds like you are almost there. The wgSMFLogin allows the extension to use the SMF cookie to auto log you into the wiki.

There are two things to check. I'm going to copy/paste this.

# Make sure "Use database driven sessions" is checked in the
# SMF Admin -> Server Settings -> Feature Configuration section
# NOTE: Make sure to configure the wgCookeDomain below

# Make "Enable local storage of cookies" is unchecked in the
# SMF Admin -> Server Settings -> Feature Configuration section
# www.domain.org/wiki and www.domain.org/forums -> www.domain.org
# wiki.domain.org and forums.doman.org -> .domain.org
#$wgCookieDomain = 'www.domain.org';

Chances are it has to do with the Enable local storage of cookies. When changing this setting I've had to clear out my browser cookies for it to start working right. It seems like SMF gets confused as the cookie is written in a different format.
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

Skuzzy

'Enable local storage of cookies' has never been checked.
'Use database driven sessions' has always been checked.

That was the first things I checked.

rsw686

I just released version 1.12. I never made version 1.11 public so here are the changes from both versions.

The main reason I released this update was to correct an internal server error that started occurring when I upgraded to mediawiki 1.12.0. It turns out that calling the logout function when the user is already logged out will crash php. Not sure what this just appeared now, but it has been corrected.

1.12 - Keep the connection to the database open.
     - Fix segfault caused by logging out an already logged out user when wgSMFLogin is enabled.

1.11 - Don't allow banned or unactivated users to log on when wgSMFLogin is enabled.
     - Don't allow partially banned users to log on.
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

rsw686

Quote from: gubius on April 09, 2008, 10:06:42 AM
No it isn't my own server, it's hosted by "ovh.net". But I get the 500 error only when i set
"$wgSMFLogin = true;". When I leave the # befor it to comment it, everything works, but the autologin would be nice and easy :)

Quote from: Skuzzy on April 09, 2008, 03:41:42 PM
I am not running any caching.  It is my own Solaris 5.10 server running, PHP 5.2.5, MySQL 5.1.23(rc), SMF 1.1.4, MediaWiki 1.12.0, and Apache 2.0.63.  Any thoughts?  What else do you need?

EDIT: More information.  If I change "$wgSMFLogin" to false, then everything seems to be fine.  What does that variable actually do?  When I set it to "true", I get page not found errors when I try to logout.

Looks like you have the same php segfault error I just came across. Sorry I couldn't figure this out sooner. I had free time today and figured I'd upgrade to the latest mediawiki and then it happened to me.

It took a bit with some some echo '1'; exit; statements to find out exactly which line the segfault was happening on. Once I saw it was the logout line it just clicked.
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

gubius

Well, now when I got my error.log, you figure it out ;P

It was this error:

[2008 Apr 14 16:41:34] [error] [client 194.154.212.4] [host hxxp:www.mfcl.net [nonactive]] Premature end of script headers: /home/mfcljmmv/www/wiki/index.php

That was always posted...with your V12 it works now :)

rsw686

Glad to hear that it is working for you!

Version 1.13 was just released with the following changes

- Move hook initialization into class to prevent potential errors.
- Fix require errors when running wiki maintenance scripts.
- Cache the groups the user is a member of to save queries.
- Combine the group name lookups into one query.

What this means is that you can now run the scripts in the maintenance directory without receiving require errors. This is useful when upgrading mediawiki. You no longer need to comment out the extension in the LocalSettings.php file. Besides uploading the new extension you will need to change the require_once line that you added in LocalSettings.php.

# Load up the extension
require_once "$IP/extensions/Auth_SMF.php";
$wgAuth = new Auth_SMF();

For those that have multiple groups defined for $wgSMFGroupName and/or $wgSMFAdminGroupName I have decreased the number of database queries substantially. Before for each group name it have to make two queries. This caused extra load on the database server.

Now with no groups defined it will make 3 database queries (password check, partial ban check, group membership check) when loading a page. If you define $wgSMFGroupName it will only make one additional database query, and the same goes for  $wgSMFAdminGroupName.

As always you can download the latest version from http://wgnrs.dynalias.com/smf/Auth_SMF.php
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

Slack


Eliana Tamerin

Would this work with a wiki and forum on separate servers or could it be made to work? I'm planning on moving my forum (but not my wiki) and so I'm looking for the best solution for this.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

rsw686

Quote from: Eliana Tamerin on April 18, 2008, 10:13:19 AM
Would this work with a wiki and forum on separate servers or could it be made to work? I'm planning on moving my forum (but not my wiki) and so I'm looking for the best solution for this.

It could be made to work. The only SMF file it uses is the Settings.php to grab the database details. I thought this would be easier for most to setup then having to supply the correct credentials.

All you would have to do is replace the following in the extension


if(file_exists("$IP/$wgSMFPath/Settings.php"))
require_once("$IP/$wgSMFPath/Settings.php");
else
die('Check to make sure $wgSMFPath is correctly set in LocalSettings.php!');

$smf_settings['boardurl'] = $boardurl;
$smf_settings['cookiename'] = $cookiename;

$smf_settings['db_server'] = $db_server;
$smf_settings['db_name'] = $db_name;
$smf_settings['db_user'] = $db_user;
$smf_settings['db_passwd'] = $db_passwd;
$smf_settings['db_prefix'] = $db_prefix;


with this


$smf_settings['boardurl'] = 'boardurl';
$smf_settings['cookiename'] = 'cookiename';

$smf_settings['db_server'] = 'server';
$smf_settings['db_name'] = 'database';
$smf_settings['db_user'] = 'username';
$smf_settings['db_passwd'] = 'password';
$smf_settings['db_prefix'] = 'prefix';


Just fill it in with the appropriate values from Settings.php. Granted the wiki server needs to have access to the mysql server hosting your SMF database. Most hosts don't allow outside access to the mysql server.
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

Oldiesmann

I have a question...

From reading this, it appears that if you want to allow guests to edit the wiki, then SMF users are not automatically logged in to the wiki when they visit. Is this the case?

The reason I'm asking is because I have had problems with the other two bridges. Because they use SSI.php, SMF attempts to sanitize the query strings from the wiki as well, which prevents you from using apostrophes (and possibly other characters) in article titles.

I found a workaround for now - pull the title before extensions are loaded, then set the title to the original value later on, bypassing all checks and such - but it creates some sort of an infinite loop if I use it on a subdomain.

I'm trying to find a solution that doesn't involve modifying SMF or hacking Mediawiki.

rsw686

Quote from: Oldiesmann on May 11, 2008, 07:22:48 PM
From reading this, it appears that if you want to allow guests to edit the wiki, then SMF users are not automatically logged in to the wiki when they visit. Is this the case?

Nope that is not the case. The auto login will work whether or not guests can edit the wiki. The guest editing is defined by the below setting I suggest to add in LocalSettings.php

# This requires a user be logged into the wiki to make changes.
$wgGroupPermissions['*']['edit'] = false;

Quote from: Oldiesmann on May 11, 2008, 07:22:48 PM
The reason I'm asking is because I have had problems with the other two bridges. Because they use SSI.php, SMF attempts to sanitize the query strings from the wiki as well, which prevents you from using apostrophes (and possibly other characters) in article titles.

Mine doesn't use SSI.php. I tried using it and I can't remember the exact error message but I was having issues with the sessions conflicting. I only include the Settings.php file from SMF to grab the database values and SMF cookie name. Due to this you must being using database sessions in SMF and have the enable local storage of cookies option unchecked.

When I do the login redirect I destroy the MediaWiki session, load up the SMF session, set the old_url or logout_url value, update the sessions table, and redirect to the SMF page. This took a bit to figure out but it has been working great.

Quote from: Oldiesmann on May 11, 2008, 07:22:48 PM
I'm trying to find a solution that doesn't involve modifying SMF or hacking Mediawiki.

I would recommend trying my bridge out. It doesn't require modifying any SMF files. You just place the extension in the folder and add a few lines to LocalSettings.php.
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

Oldiesmann

I will definitely give this a try. Thanks!

Advertisement: