Extension talk:CategorySubscriptions

Feel free to list bugs and issues you may fine. I will be monitoring this discussion page on a weekly basis. I can also be reached via email (myatzkan at gmail.com).

NameSpaces not showing up in links.
This appears to have a problem with namespaces. It does not include them in the link it sends. --Johnp125 20:27, 10 March 2010 (UTC)

On my mw 1.11.0, it appears that the table name category_subscriptions must be prefaced with $wgDBprefix

--The php mailer script does not run inside the mw engine, thus it cannot access the $wg variables. I am not a database and php expert, but my script runs just fine on both windows and unix machines. In the script the database host and name is defined then the link is created. This is all specific to mysql. If you are using a different database vendor then the script will need to be modified.

I did just update the code online. There was a small bug with how the email to and from fields are created. I had left a variable in that shouldn't have been there and that was causing a php error to occur. That would have caused you a mysql error as it was trying to find a column in a sql result set that didn't exist.

Try using the new code I just published. Maybe it will fix the error you are having.

It is not the mail script, it is CategorySubscriptions.php causing the exception in the SQL select invocation. Still happens with the new code unless one renames the table with the DBprefix which in my case is the installation default mw:

--Bob 02:40, 28 January 2008 (UTC)

Whenever you created the table in the database, did you modify the SQL code provided to include your database prefix? I just created another wiki installation using a dbprefix of 'mw' and changed the SQL code to "CREATE TABLE mwcategory_subscriptions" and all works fine for me (this is on MW 1.10). The PHP code should not need modified, because it is using the mediawiki database accessors and will automatically use whatever prefix is defined. Please make sure that the actual table created has your prefix in the table name. Because the table is manually created the prefix needs to be manually inserted.

This does, however, expose a design flaw in the mailer script that I will need fix - the mailer script does not provide any method to tell it the wiki database prefix. I will edit the code so that there is a variable at the top of the script that allows one to define the db prefix, which will then be concatinated to all db table calls throughout the script. I should have that done today (hopefully).

I hope this helps and that I am understanding the issue correctly. If you could, please double check the database name in the mean time and let me know if that solves your problem. I will try to have an updated mailer script posted today. I need to figure out how to get files uploaded to cvs on here, if anyone reading can point me in the right direction that would be helpful :) Thanks. --Mike 8 February 2008

Bug Fixes
Fixed a bug in how the mailer script gets the user's email address and sets them to the $to and $from variables. A variable was left in place which was trying to access a column in a sql result set that didn't exist, which throws an error.

8 February 2008 Update

Several design issues have been addressed:
 * Added ability to set a database prefix. A new variable $DATABASE_PREFIX is defined near the top of the script - this is where the prefix is defined, if one exists for your wiki.
 * Added ability to set the wiki url. I accidentally left my hardcoded url address.  Please disregard that and update to the new code.  The variable $WIKI_URL is where you can now define your url to your wiki.  This will make the links in the emails point to your wiki.

headers already sent error
Several instances of are thrown onto each page using code from Jan 27 --Bob 03:08, 28 January 2008 (UTC)

Just want to make sure, do you have any extra spaces or lines before the first '<?' and after the last '?>'? Extra lines and spaces can cause errors when MW parses the script. Other than that I am a bit stumped. I am a little stumped on this, but will keep looking for a cause. Thanks. --Mike 2.8.2008

enhancement: directmailer.php
After installing this extension I realised that a cron job is necessary to run the emailing periodically. This is not what I wanted. I just wanted to see the immediate result. Therefore I added an enhancement to this extension that sends out the email right away. It's not perfect, but it works. In order to use it you need to install the extension and the directmailer.php, too:


 * Distributed under GNU General Public License 2.0 or later (http://www.gnu.org/copyleft/gpl.html)
 * Distributed under GNU General Public License 2.0 or later (http://www.gnu.org/copyleft/gpl.html)

if (!defined('MEDIAWIKI')) die;

$WIKI_URL = "http://www.yourdomain.com/wiki/index.php?title=";
 * 1) URL For your wiki
 * 2) Enter the url for your wiki, maybe it is not necessary, then leave it empty ("").
 * 3) If you do not use short-urls, you must enter the url like this:
 * 4) "http://www.yourdomain.com/wiki/index.php?title="
 * 5) If short-urls are used, you must append a trailing slash to the end of the url, like such:
 * 6) "http://www.yourdomain.com/wiki/"
 * 1) If short-urls are used, you must append a trailing slash to the end of the url, like such:
 * 2) "http://www.yourdomain.com/wiki/"

$EMAIL_FROM = '';
 * 1) By default, email is sent from the email address of the loggin-user
 * 2) Enter here the user-id for emails for anon users

$EMAIL_SUBJECT = "Your category subscriptions";
 * 1) change subject if desired

/* future enhancement: $wgHooks['ArticleDeleteComplete'][] = 'CategorySubscriptionsDelete'; $wgHooks['ArticleSaveComplete'][] = 'CategorySubscriptionsChange';

function CategorySubscriptionsChange(&$article, &$user, &$text, &$summary, &$minoredit, &$watchthis, &$sectionanchor, &$flags, $revision) { global $WIKI_URL, $EMAIL_FROM, $EMAIL_SUBJECT; global $wgOut, $wgUser, $wgDBprefix;

$myID=$article->getID; #slave database handle $dbr =& wfGetDB( DB_SLAVE );

#get new pages $result = $dbr->select(array('category_subscriptions', 'categorylinks', 'user', 'page'),                               array('cl_to', 'user_email', 'user_email', 'page_title', 'page_is_new', 'page_namespace'),                               array($wgDBprefix."category_subscriptions.category = ".$wgDBprefix."categorylinks.cl_to", $wgDBprefix."category_subscriptions.user_id = ".$wgDBprefix."user.user_id", "cl_from = page_id", "cl_from = ".$article->getID )); while($row = $result->fetchRow ) {       #new pages if ( $row["page_is_new"] == '0' ) { $email_body = "A page of the subscribed category ".$row["cl_to"]." was changed:\n"; } else { $email_body = "A new page has been added to the subscribed category ".$row["cl_to"].":\n"; }       $url = $article->mTitle->getFullURL( 'redirect=no' ); $email_body .=$WIKI_URL.$url."\n";

#Send the email $to = new MailAddress( $row["user_email"] ); if( $wgUser->isLoggedIn ) { if( User::isValidEmailAddr( $wgUser->getEmail ) ) { $from = new MailAddress( $wgUser->getEmail ); } else { $wgOut->addWikiMsg( 'confirmemail_noemail' ); }	}       else { $from = new MailAddress( $EMAIL_FROM ); }	$subject = $EMAIL_SUBJECT; $replyTo = null; if ( wfRunHooks( 'EmailUser', array( &$to, &$from, &$subject, &$email_body ) ) ) { $mailResult = UserMailer::send( $to, $from, $subject, $email_body, $replyTo ); if( WikiError::isError( $mailResult ) ) { $wgOut->addHTML( wfMsg( "usermailererror" ) .				' ' . htmlspecialchars( $mailResult->getMessage ) ); }       }

}

return true; }

?>

Installation: require_once("extensions/DirectMailer.php");
 * copy the source statements above to a source file in your extension library (e.g. directmailer.php)
 * add following statements to your LocalSettings.php:
 * fin.

K.W. 84.149.248.31 19:58, 15 March 2009 (UTC) update March 12th,2010: URL with Namespace; DB-Select with DB prefix

Google Code Shutting Down
Hello, As you are likely aware, Google is shutting down their Google Code service in January of 2016. This extension appears to house its code with Google Code and is at risk to creating broken links and confusion of users in the near future.

I’m helping to let folks know about this coming update and provide some helpful links to make this migration easy. I hope you’ll take a moment and migrate your extension to a new hosting solution.

For extensions that have a compatible license, you can request developer access to the MediaWiki source repositories for extensions and get a new repository created for you. Alternatively, you may also export your code to other popular repositories such as Github and Bitbucket. Google has provided tools to help with this migration.

Ckoerner (talk) 17:15, 7 July 2015 (UTC)