MediaWiki r99867 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r99866‎ | r99867 (on ViewVC)‎ | r99868 >
Date:09:49, 15 October 2011
Author:flohack
Status:deferred (Comments)
Tags:
Comment:
Modified paths:

Diff [purge]

Index: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_remove_primary_keys.sql
@@ -0,0 +1,8 @@
 2+-- Remove unnecessary primary key columns
 3+
 4+ALTER TABLE /*$wgDBprefix*/collabwatchlistcategory
 5+ DROP COLUMN rlc_id;
 6+ALTER TABLE /*$wgDBprefix*/collabwatchlistrevisiontag
 7+ DROP COLUMN rrt_id;
 8+ALTER TABLE /*$wgDBprefix*/collabwatchlisttag
 9+ DROP COLUMN rt_id;
Property changes on: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_remove_primary_keys.sql
___________________________________________________________________
Added: svn:eol-style
110 + native
Index: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_rename_fields.sql
@@ -0,0 +1,20 @@
 2+-- Rename misnamed fields
 3+
 4+ALTER TABLE /*$wgDBprefix*/collabwatchlist
 5+ CHANGE rl_id cw_id integer unsigned NOT NULL AUTO_INCREMENT;
 6+ALTER TABLE /*$wgDBprefix*/collabwatchlist
 7+ CHANGE rl_name cw_name varbinary(255) NOT NULL;
 8+ALTER TABLE /*$wgDBprefix*/collabwatchlist
 9+ CHANGE rl_start cw_start binary(14) NOT NULL default '';
 10+
 11+ALTER TABLE /*$wgDBprefix*/collabwatchlistrevisiontag
 12+ CHANGE rl_id cw_id integer unsigned NOT NULL;
 13+
 14+ALTER TABLE /*$wgDBprefix*/collabwatchlisttag
 15+ CHANGE rl_id cw_id integer unsigned NOT NULL;
 16+
 17+ALTER TABLE /*$wgDBprefix*/collabwatchlistuser
 18+ CHANGE rl_id cw_id integer unsigned NOT NULL;
 19+
 20+ALTER TABLE /*$wgDBprefix*/collabwatchlistcategory
 21+ CHANGE rl_id cw_id integer unsigned NOT NULL;
Property changes on: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_rename_fields.sql
___________________________________________________________________
Added: svn:eol-style
122 + native
Index: trunk/extensions/CollabWatchlist/sql/collabwatchlistrevisiontag.sql
@@ -3,21 +3,21 @@
44 -- Replace /*$wgDBprefix*/ with the proper prefix
55 -- Replace /*$wgDBTableOptions*/ with the correct options
66
 7+-- Associates a specific tag (ct_tag) with a recent changes entry (ct_rc_id)
 8+-- and a specific collabwatchlist (cw_id)
79 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/collabwatchlistrevisiontag (
8 - -- The id of this entry
9 - rrt_id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
1010 -- See change_tag.ct_tag
1111 ct_tag varbinary(255) NOT NULL,
1212 -- See change_tag.ct_rc_id
1313 ct_rc_id int NOT NULL default 0,
14 - -- Foreign key to collabwatchlist.rl_id
15 - rl_id integer unsigned NOT NULL,
 14+ -- Foreign key to collabwatchlist.cw_id
 15+ cw_id integer unsigned NOT NULL,
1616 -- Foreign key to user.user_id
1717 user_id int(10) unsigned NOT NULL,
1818
1919 -- Comment for the tag
20 - rrt_comment varchar(255),
 20+ rrt_comment varchar(255)
2121
22 - UNIQUE KEY (ct_tag, ct_rc_id, rl_id)
2322 ) /*$wgDBTableOptions*/;
 23+
 24+CREATE UNIQUE INDEX ct_tag on /*$wgDBprefix*/collabwatchlistrevisiontag (ct_tag, ct_rc_id, cw_id);
\ No newline at end of file
Index: trunk/extensions/CollabWatchlist/sql/collabwatchlisttag.sql
@@ -3,16 +3,15 @@
44 -- Replace /*$wgDBprefix*/ with the proper prefix
55 -- Replace /*$wgDBTableOptions*/ with the correct options
66
 7+-- Add table defining the tags which are allowed on a collab watchlist
78 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/collabwatchlisttag (
8 - -- The id of this entry
9 - rt_id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
10 - -- Foreign key to collabwatchlist.rl_id
11 - rl_id integer unsigned NOT NULL,
 9+ -- Foreign key to collabwatchlist.cw_id
 10+ cw_id integer unsigned NOT NULL,
1211 -- The name of the collabwatchlist tag (unique)
1312 rt_name varbinary(255) NOT NULL,
1413 -- Description of the tag
15 - rt_description tinyblob NOT NULL default '',
 14+ rt_description tinyblob NOT NULL default ''
1615
17 - UNIQUE KEY (rl_id, rt_name)
18 -) /*$wgDBTableOptions*/;
\ No newline at end of file
 16+) /*$wgDBTableOptions*/;
 17+
 18+CREATE UNIQUE INDEX cw_id ON /*$wgDBprefix*/collabwatchlisttag (cw_id, rt_name);
\ No newline at end of file
Index: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_noctid.sql
@@ -1,6 +1,4 @@
22 -- Remove the ct_id column which was introduced in a previous revision
33
44 ALTER TABLE /*$wgDBprefix*/collabwatchlistrevisiontag
55 ADD ct_tag varbinary(255) NOT NULL;
Index: trunk/extensions/CollabWatchlist/sql/collabwatchlistcategory.sql
@@ -5,10 +5,8 @@
66
77 -- Add table defining the categories for collaborative watchlists
88 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/collabwatchlistcategory (
9 - -- The id of this entry
10 - rlc_id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
11 - -- Foreign key to collabwatchlist.rl_id
12 - rl_id integer unsigned NOT NULL,
 9+ -- Foreign key to collabwatchlist.cw_id
 10+ cw_id integer unsigned NOT NULL,
1311 -- Foreign key to page.page_id
1412 cat_page_id integer unsigned NOT NULL,
1513 -- Whether the category is subtracted from or added to the collaborative watchlist
Index: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_remove_enum.sql
@@ -0,0 +1,15 @@
 2+-- Remove enums
 3+
 4+ALTER TABLE /*$wgDBprefix*/collabwatchlistuser
 5+ ADD COLUMN rlu_type_new integer NOT NULL DEFAULT 1;
 6+UPDATE /*$wgDBprefix*/collabwatchlistuser
 7+ SET rlu_type_new = 1 WHERE rlu_type = 'OWNER' OR rlu_type = 1;
 8+UPDATE /*$wgDBprefix*/collabwatchlistuser
 9+ SET rlu_type_new = 2 WHERE rlu_type = 'USER' OR rlu_type = 2;
 10+UPDATE /*$wgDBprefix*/collabwatchlistuser
 11+ SET rlu_type_new = 3 WHERE rlu_type = 'TRUSTED_EDITOR' OR rlu_type = 3;
 12+ALTER TABLE /*$wgDBprefix*/collabwatchlistuser
 13+ DROP COLUMN rlu_type;
 14+ALTER TABLE /*$wgDBprefix*/collabwatchlistuser
 15+ CHANGE rlu_type_new rlu_type integer NOT NULL DEFAULT 1;
 16+
Property changes on: trunk/extensions/CollabWatchlist/sql/patch-collabwatchlist_remove_enum.sql
___________________________________________________________________
Added: svn:eol-style
117 + native
Index: trunk/extensions/CollabWatchlist/sql/collabwatchlistuser.sql
@@ -7,11 +7,12 @@
88 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/collabwatchlistuser (
99 -- The id of this entry
1010 rlu_id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
11 - -- Foreign key to collabwatchlist.rl_id
12 - rl_id integer unsigned NOT NULL,
 11+ -- Foreign key to collabwatchlist.cw_id
 12+ cw_id integer unsigned NOT NULL,
1313 -- Foreign key to user.user_id
1414 user_id int(10) unsigned NOT NULL,
15 -
1615 -- Type of user
17 - rlu_type ENUM("OWNER", "USER", "TRUSTED_EDITOR") DEFAULT "OWNER"
18 -) /*$wgDBTableOptions*/;
\ No newline at end of file
 16+ rlu_type integer NOT NULL DEFAULT 1
 17+) /*$wgDBTableOptions*/;
 18+
 19+CREATE UNIQUE INDEX rl_id ON /*$wgDBprefix*/collabwatchlistuser (rl_id, user_id);
\ No newline at end of file
Index: trunk/extensions/CollabWatchlist/sql/collabwatchlist.sql
@@ -7,11 +7,11 @@
88 -- Add table defining a collaborative watchlist
99 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/collabwatchlist (
1010 -- The id of the collaborative watchlist
11 - rl_id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
 11+ cw_id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
1212 -- The name of the collaborative watchlist (unique)
13 - rl_name varbinary(255) NOT NULL,
 13+ cw_name varbinary(255) NOT NULL,
1414 -- Starting date in standard YMDHMS form.
15 - rl_start binary(14) NOT NULL default '',
 15+ cw_start binary(14) NOT NULL default ''
 16+) /*$wgDBTableOptions*/;
1617
17 - UNIQUE KEY (rl_name)
18 -) /*$wgDBTableOptions*/;
\ No newline at end of file
 18+CREATE UNIQUE INDEX cw_name ON /*$wgDBprefix*/collabwatchlist (cw_name);
Index: trunk/extensions/CollabWatchlist/tests/CollabWatchlistTest.php
@@ -1,6 +1,9 @@
22 <?php
33
44 class CollabWatchlistTest extends PHPUnit_Framework_TestCase {
 5+ protected function setUp() {
 6+ $this->markTestSkipped('Manually only');
 7+ }
58 public function testCategoryTree() {
69 /* Workaround for eclipse xdebug
710 $path = '/usr/share/php';
Index: trunk/extensions/CollabWatchlist/CollabWatchlist.php
@@ -8,6 +8,26 @@
99 exit( 1 );
1010 }
1111
 12+/**
 13+ * Toggles the recursive category scan. If you disable that, users
 14+ * will not be able to watch edits on pages belonging to subcategories
 15+ * of categories on their collaborative watchlist.
 16+ * You might want to disable that, as it causes quite a bit of database
 17+ * and (if enabled) cache load and size.
 18+ */
 19+$wgCollabWatchlistRecursiveCatScan = true;
 20+/**
 21+ * The depth of the category tree we are building.
 22+ * This is only relevant if $wgCollabWatchlistRecursiveCatScan is enabled
 23+ * -1 means infinite
 24+ * 0 fetches no child categories at all
 25+ */
 26+$wgCollabWatchlistRecursiveCatMaxDepth = -1;
 27+/**
 28+ * The name of the page to show to users who don't have the necessary
 29+ * privileges to show a page belonging to this extension.
 30+ */
 31+$wgCollabWatchlistPermissionDeniedPage = 'CollabWatchlistPermissionDenied';
1232
1333 $wgExtensionCredits['specialpage'][] = array(
1434 'path' => __FILE__,
@@ -24,6 +44,8 @@
2545 $wgExtensionMessagesFiles['CollabWatchlist'] = $wgDir . 'CollabWatchlist.i18n.php';
2646 $wgExtensionAliasesFiles['CollabWatchlist'] = $wgDir . 'CollabWatchlist.alias.php';
2747
 48+$wgAutoloadClasses['CollabWatchlistHooks'] = "$wgDir/CollabWatchlist.hooks.php";
 49+$wgAutoloadClasses['CollabWatchlist'] = "$wgDir/CollabWatchlist.class.php";
2850 $wgAutoloadClasses['SpecialCollabWatchlist'] = $wgCollabWatchlistIncludes . 'SpecialCollabWatchlist.php';
2951 $wgAutoloadClasses['CollabWatchlistChangesList'] = $wgCollabWatchlistIncludes . 'CollabWatchlistChangesList.php';
3052 $wgAutoloadClasses['CategoryTreeManip'] = $wgCollabWatchlistIncludes . 'CategoryTreeManip.php';
@@ -42,79 +64,6 @@
4365 $wgSpecialPages['Collabwatchlist'] = 'SpecialCollabWatchlist'; # Let MediaWiki know about your new special page.
4466 $wgSpecialPageGroups['Collabwatchlist'] = 'other';
4567
46 -$wgHooks['LoadExtensionSchemaUpdates'][] = 'fnCollabWatchlistDbSchema';
47 -$wgHooks['GetPreferences'][] = 'fnCollabWatchlistPreferences';
48 -
49 -function fnCollabWatchlistDbSchema( $updater = null ) {
50 - $sqlDir = dirname(__FILE__) . '/sql/';
51 - if ( $updater === null ) { // <= 1.16 support
52 - global $wgExtNewTables, $wgExtNewFields;
53 - $wgExtNewTables[] = array('collabwatchlist', $sqlDir . 'collabwatchlist.sql');
54 - $wgExtNewTables[] = array('collabwatchlistuser', $sqlDir . 'collabwatchlistuser.sql');
55 - $wgExtNewTables[] = array('collabwatchlistcategory', $sqlDir . 'collabwatchlistcategory.sql');
56 - $wgExtNewTables[] = array('collabwatchlistrevisiontag', $sqlDir . 'collabwatchlistrevisiontag.sql');
57 - $wgExtNewTables[] = array('collabwatchlisttag', $sqlDir . 'collabwatchlisttag.sql');
58 - $wgExtNewFields[] = array('collabwatchlistrevisiontag', 'ct_rc_id', $sqlDir . 'patch-collabwatchlist_noctid.sql');
59 - } else { // >= 1.17 support
60 - $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlist',
61 - $sqlDir . 'collabwatchlist.sql', true ) );
62 - $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistuser',
63 - $sqlDir . 'collabwatchlistuser.sql', true ) );
64 - $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistcategory',
65 - $sqlDir . 'collabwatchlistcategory.sql', true ) );
66 - $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistrevisiontag',
67 - $sqlDir . 'collabwatchlistrevisiontag.sql', true ) );
68 - $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlisttag',
69 - $sqlDir . 'collabwatchlisttag.sql', true ) );
70 - $updater->addExtensionUpdate( array( 'addField', 'collabwatchlistrevisiontag', 'ct_rc_id',
71 - $sqlDir . 'patch-collabwatchlist_noctid.sql', true ) );
72 - }
73 - return true;
74 -}
75 -
76 -function fnCollabWatchlistPreferences( $user, &$preferences ) {
77 - $preferences['collabwatchlisthidelistuser'] = array(
78 - 'type' => 'toggle',
79 - 'label-message' => 'tog-collabwatchlisthidelistusers',
80 - 'section' => 'watchlist/advancedwatchlist',
81 - );
82 - return true;
83 -}
84 -
85 -// You might want to disable that, as it causes quite a bit of database
86 -// and (if enabled) cache load and size
87 -$wgCollabWatchlistRecursiveCatScan = true;
88 -// The depth of the category tree we are building. -1 means infinite
89 -// 0 fetches no child categories at all
90 -$wgCollabWatchlistRecursiveCatMaxDepth = -1;
91 -$wgCollabWatchlistNSPrefix = 'CollabWatchlist';
92 -$wgCollabWatchlistPermissionDeniedPage = 'CollabWatchlistPermissionDenied';
93 -
94 -# Unit tests
95 -$wgHooks['UnitTestsList'][] = 'efCollabWatchlistUnitTests';
96 -
97 -function efCollabWatchlistUnitTests( &$files ) {
98 - $files[] = dirname( __FILE__ ) . '/tests/CollabWatchlistTest.php';
99 - return true;
100 -}
101 -
102 -/**#@+
103 - * Collaborative watchlist user types
104 - * This defines constants for the collabwatchlistuser.rlu_type
105 - */
106 -define( 'COLLABWATCHLISTUSER_OWNER', 'OWNER' ); // owners are allowed to edit the list
107 -define( 'COLLABWATCHLISTUSER_OWNER_TEXT', 'Owner' ); // owners are allowed to edit the list
108 -define( 'COLLABWATCHLISTUSER_USER', 'USER' ); // users are allowed to view the list and tag edits
109 -define( 'COLLABWATCHLISTUSER_USER_TEXT', 'User' ); // users are allowed to view the list and tag edits
110 -define( 'COLLABWATCHLISTUSER_TRUSTED_EDITOR', 'TRUSTED_EDITOR' ); // trusted editors are used to filter edits which don't require a review
111 -define( 'COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT', 'TrustedEditor' ); // trusted editors are used to filter edits which don't require a review
112 -
113 -function fnCollabWatchlistUserTypeToText( $userType ) {
114 - if ( $userType === COLLABWATCHLISTUSER_OWNER )
115 - return COLLABWATCHLISTUSER_OWNER_TEXT;
116 - if ( $userType === COLLABWATCHLISTUSER_USER )
117 - return COLLABWATCHLISTUSER_USER_TEXT;
118 - if ( $userType === COLLABWATCHLISTUSER_TRUSTED_EDITOR )
119 - return COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT;
120 -}
121 -/**#@-*/
 68+$wgHooks['LoadExtensionSchemaUpdates'][] = 'CollabWatchlistHooks::onLoadExtensionSchemaUpdates';
 69+$wgHooks['GetPreferences'][] = 'CollabWatchlistHooks::onGetPreferences';
 70+$wgHooks['UnitTestsList'][] = 'CollabWatchlistHooks::onUnitTestsList';
Index: trunk/extensions/CollabWatchlist/includes/SpecialCollabWatchlist.php
@@ -168,7 +168,7 @@
169169 $recentchanges = $dbr->tableName( 'recentchanges' );
170170
171171 $nitems = $dbr->selectField( 'collabwatchlistcategory', 'COUNT(*)',
172 - $collabWatchlist == 0 ? array() : array( 'rl_id' => $collabWatchlist
 172+ $collabWatchlist == 0 ? array() : array( 'cw_id' => $collabWatchlist
173173 ), __METHOD__ );
174174 if ( $nitems == 0 ) {
175175 $wgOut->addWikiMsg( 'nowatchlist' );
@@ -459,28 +459,28 @@
460460
461461 /** Returns an array of maps representing collab watchlist tags. The following fields are present
462462 * in each map:
463 - * - rl_id Id of the collaborative watchlist
 463+ * - cw_id Id of the collaborative watchlist
464464 * - ct_tag Name of the tag
465465 * - collabwatchlistrevisiontag.user_id User which set the tag
466466 * - user_name Username of the user which set the tag
467467 * - rrt_comment Collabwatchlist tag comment
468468 * @param $rev_id
469 - * @param $rl_ids
 469+ * @param $cw_ids
470470 * @return unknown_type
471471 */
472 - function wlTagsForRevision( $rev_id, $rl_ids = array(), $filterTags = array() ) {
 472+ function wlTagsForRevision( $rev_id, $cw_ids = array(), $filterTags = array() ) {
473473 // Some DB stuff
474474 $dbr = wfGetDB( DB_SLAVE );
475475 $cond = array();
476 - if ( isset( $rl_ids ) && !( count( $rl_ids ) == 1 && $rl_ids[0] == 0 ) ) {
477 - $cond = array( "rl_id" => $rl_ids );
 476+ if ( isset( $cw_ids ) && !( count( $cw_ids ) == 1 && $cw_ids[0] == 0 ) ) {
 477+ $cond = array( "cw_id" => $cw_ids );
478478 }
479479 if ( isset( $filterTags ) && count( $filterTags ) > 0 ) {
480480 $cond[] = "ct_tag not in (" . $dbr->makeList( $filterTags ) . ")";
481481 }
482482 // $table, $vars, $conds='', $fname = 'Database::select', $options = array(), $join_conds = array()
483483 $res = $dbr->select( array( 'change_tag', 'collabwatchlistrevisiontag', 'user' ), # Tables
484 - array( 'rl_id', 'collabwatchlistrevisiontag.ct_tag', 'collabwatchlistrevisiontag.user_id', 'user_name', 'rrt_comment' ), # Fields
 484+ array( 'cw_id', 'collabwatchlistrevisiontag.ct_tag', 'collabwatchlistrevisiontag.user_id', 'user_name', 'rrt_comment' ), # Fields
485485 array( 'change_tag.ct_rev_id' => $rev_id ) + $cond, # Conditions
486486 __METHOD__, array(),
487487 # Join conditions
@@ -500,12 +500,12 @@
501501 * It filters entries which are not relevant for the given watchlists. I.e.
502502 * entries which don't belong to a category and are not listed explicitly as a
503503 * page for one of the given watchlists.
504 - * @param $rl_ids Array: A list of collaborative watchlist ids
 504+ * @param $cw_ids Array: A list of collaborative watchlist ids
505505 * @param $catNameCol String: The name of the column containing category names
506506 * @param $pageIdCol String: The name of the column containing page ids
507507 * @return String: An SQL clause usable in the conditions parameter of $db->select()
508508 */
509 - function wlGetFilterClauseForCollabWatchlistIds( $rl_ids, $catNameCol, $pageIdCol ) {
 509+ function wlGetFilterClauseForCollabWatchlistIds( $cw_ids, $catNameCol, $pageIdCol ) {
510510 global $wgCollabWatchlistRecursiveCatScan;
511511 $excludedCatPageIds = array();
512512 $includedCatPageIds = array();
@@ -513,10 +513,10 @@
514514 $dbr = wfGetDB( DB_SLAVE );
515515 $res = $dbr->select( array( 'collabwatchlist', 'collabwatchlistcategory', 'page' ), # Tables
516516 array( 'cat_page_id', 'page_title', 'page_namespace', 'subtract' ), # Fields
517 - $rl_ids != 0 ? array( 'collabwatchlist.rl_id' => $rl_ids ) : array(), # Conditions
 517+ $cw_ids != 0 ? array( 'collabwatchlist.cw_id' => $cw_ids ) : array(), # Conditions
518518 __METHOD__, array(),
519519 # Join conditions
520 - array( 'collabwatchlistcategory' => array( 'JOIN', 'collabwatchlist.rl_id = collabwatchlistcategory.rl_id' ),
 520+ array( 'collabwatchlistcategory' => array( 'JOIN', 'collabwatchlist.cw_id = collabwatchlistcategory.cw_id' ),
521521 'page' => array( 'JOIN', 'page.page_id = collabwatchlistcategory.cat_page_id' ) )
522522 );
523523 foreach ( $res as $row ) {
@@ -553,15 +553,15 @@
554554 /**
555555 * Constructs the user filter SQL clause for the given collaborative watchlist ids.
556556 * It filters entries from the users of the given watchlists.
557 - * @param $rl_ids Array: A list of collaborative watchlist ids
 557+ * @param $cw_ids Array: A list of collaborative watchlist ids
558558 * @return String: An SQL clause usable in the conditions parameter of $db->select()
559559 */
560 - function wlGetFilterClauseListUser( $rl_id ) {
 560+ function wlGetFilterClauseListUser( $cw_id ) {
561561 $excludedUserIds = array();
562562 $dbr = wfGetDB( DB_SLAVE );
563563 $res = $dbr->select( 'collabwatchlistuser', # Tables
564564 'user_id', # Fields
565 - array( 'collabwatchlistuser.rl_id' => $rl_id ) # Conditions
 565+ array( 'collabwatchlistuser.cw_id' => $cw_id ) # Conditions
566566 );
567567 $clause = '';
568568 foreach ( $res as $row ) {
Index: trunk/extensions/CollabWatchlist/includes/CollabWatchlistChangesList.php
@@ -180,7 +180,7 @@
181181
182182 /** Insert links to user page, user talk page and eventually a blocking link */
183183 $userLink = $this->skin->userLink( $tagRow['user_id'], $tagRow['user_name'] );
184 - $delTagTarget = CollabWatchlistEditor::getUnsetTagUrl( $wgRequest->getFullRequestURL(), $attr['rc_title'], $tagRow['rl_id'], $tag, $attr['rc_id'] );
 184+ $delTagTarget = CollabWatchlistEditor::getUnsetTagUrl( $wgRequest->getFullRequestURL(), $attr['rc_title'], $tagRow['cw_id'], $tag, $attr['rc_id'] );
185185 $delTagLink = Xml::element( 'a', array( 'href' => $delTagTarget, 'class' => 'mw-collabwatchlist-unsettag-' . $tag ), wfMsg( 'collabwatchlist-unset-tag' ) );
186186 $displayTags[] = $collabwatchlistTag . ' ' . $delTagLink . ' ' . $userLink;
187187 }
@@ -286,7 +286,7 @@
287287 $options = array();
288288 foreach ( $tagsAndInfo as $tagName => $info ) {
289289 $optionsAll[] = Xml::option( $tagName . ' ' . $info['rt_description'], $tagName );
290 - foreach ( $info['rl_ids'] as $rlId ) {
 290+ foreach ( $info['cw_ids'] as $rlId ) {
291291 $options[$rlId][] = Xml::option( $tagName, $tagName );
292292 }
293293 }
@@ -322,7 +322,7 @@
323323 *
324324 * The info is an array with the following keys:
325325 * 'rt_description' The description of the tag
326 - * 'rl_ids' An array of collab watchlist ids the tag belongs to
 326+ * 'cw_ids' An array of collab watchlist ids the tag belongs to
327327 * @param array $rlIds A list of collab watchlist ids
328328 * @return array Mapping from tag name to info
329329 */
@@ -332,16 +332,16 @@
333333 }
334334 $dbr = wfGetDB( DB_SLAVE );
335335 $res = $dbr->select( array( 'collabwatchlisttag' ), # Tables
336 - array( 'rt_name', 'rt_description', 'rl_id' ), # Fields
337 - array( 'rl_id' => $rlIds ), # Conditions
 336+ array( 'rt_name', 'rt_description', 'cw_id' ), # Fields
 337+ array( 'cw_id' => $rlIds ), # Conditions
338338 __METHOD__
339339 );
340340 $list = array();
341341 foreach ( $res as $row ) {
342342 if ( array_key_exists( $row->rt_name, $list ) ) {
343 - $list[$row->rt_name]['rl_ids'][] = $row->rl_id;
 343+ $list[$row->rt_name]['cw_ids'][] = $row->cw_id;
344344 } else {
345 - $list[$row->rt_name] = array( 'rt_description' => $row->rt_description, 'rl_ids' => array( $row->rl_id ) );
 345+ $list[$row->rt_name] = array( 'rt_description' => $row->rt_description, 'cw_ids' => array( $row->cw_id ) );
346346 }
347347 }
348348 return $list;
@@ -354,20 +354,22 @@
355355 * @param array $member_types A list of allowed membership types
356356 * @return array Mapping from collab watchlist id to its name
357357 */
358 - public static function getCollabWatchlistIdAndName( $user_id, $member_types = array( COLLABWATCHLISTUSER_OWNER, COLLABWATCHLISTUSER_USER ) ) {
 358+ public static function getCollabWatchlistIdAndName( $user_id, $member_types = NULL ) {
359359 global $wgDBprefix;
 360+ if ( is_null($member_types) )
 361+ $member_types = array( CollabWatchlist::$USER_OWNER, CollabWatchlist::$USER_USER );
360362 $dbr = wfGetDB( DB_SLAVE );
361363 $list = array();
362364 // $table, $vars, $conds='', $fname = 'Database::select', $options = array(), $join_conds = array()
363365 $res = $dbr->select( array( 'collabwatchlist', 'collabwatchlistuser' ), # Tables
364 - array( $wgDBprefix . 'collabwatchlist.rl_id', 'rl_name' ), # Fields
 366+ array( $wgDBprefix . 'collabwatchlist.cw_id', 'cw_name' ), # Fields
365367 array( 'rlu_type' => $member_types, $wgDBprefix . 'collabwatchlistuser.user_id' => $user_id ), # Conditions
366368 __METHOD__, array(),
367369 # Join conditions
368 - array( 'collabwatchlistuser' => array( 'JOIN', $wgDBprefix . 'collabwatchlist.rl_id = ' . $wgDBprefix . 'collabwatchlistuser.rl_id' ) )
 370+ array( 'collabwatchlistuser' => array( 'JOIN', $wgDBprefix . 'collabwatchlist.cw_id = ' . $wgDBprefix . 'collabwatchlistuser.cw_id' ) )
369371 );
370372 foreach ( $res as $row ) {
371 - $list[$row->rl_id] = $row->rl_name;
 373+ $list[$row->cw_id] = $row->cw_name;
372374 }
373375 return $list;
374376 }
Index: trunk/extensions/CollabWatchlist/includes/CollabWatchlistEditor.php
@@ -94,7 +94,7 @@
9595 }
9696 $wanted = $this->extractCollabWatchlistUsers( $request->getText( 'titles' ) );
9797 $current = $this->getCollabWatchlistUsers( $rlId );
98 - $isOwnerCb = create_function( '$a', 'return stripos($a, "' . COLLABWATCHLISTUSER_OWNER_TEXT . ' ' . '") === 0;' );
 98+ $isOwnerCb = create_function( '$a', 'return stripos($a, "' . CollabWatchlist::$USER_OWNER_TEXT . ' ' . '") === 0;' );
9999 $wantedOwners = array_filter( $wanted, $isOwnerCb );
100100 if ( count( $wantedOwners ) < 1 ) {
101101 // Make sure there is at least one owner left
@@ -179,7 +179,7 @@
180180 $redirTarget = SpecialPage::getTitleFor( 'CollabWatchlist' )->getLocalUrl();
181181 if ( $request->wasPosted() ) {
182182 $rlId = $request->getInt( 'collabwatchlist', -1 );
183 - if ( ! $this->checkPermissions( $wgUser, $rlId, array( COLLABWATCHLISTUSER_USER, COLLABWATCHLISTUSER_OWNER ) ) ) {
 183+ if ( ! $this->checkPermissions( $wgUser, $rlId, array( CollabWatchlist::$USER_USER, CollabWatchlist::$USER_OWNER ) ) ) {
184184 $output->redirect( $permissionDeniedTarget );
185185 break;
186186 }
@@ -206,7 +206,7 @@
207207 break;
208208 case self::UNSET_TAGS:
209209 $rlId = $request->getInt( 'collabwatchlist', -1 );
210 - if ( ! $this->checkPermissions( $wgUser, $rlId, array( COLLABWATCHLISTUSER_USER, COLLABWATCHLISTUSER_OWNER ) ) ) {
 210+ if ( ! $this->checkPermissions( $wgUser, $rlId, array( CollabWatchlist::$USER_USER, CollabWatchlist::$USER_OWNER ) ) ) {
211211 $output->redirect( $permissionDeniedTarget );
212212 break;
213213 }
@@ -261,19 +261,25 @@
262262 * @param $memberTypes Which types of members are allowed
263263 * @return bool
264264 */
265 - private function checkToken( $request, $user, $rlId, $memberTypes = array( COLLABWATCHLISTUSER_OWNER ) ) {
 265+ private function checkToken( $request, $user, $rlId, $memberTypes = NULL ) {
 266+ if ( is_null($member_types) )
 267+ $member_types = array( CollabWatchlist::$USER_OWNER );
 268+
266269 $tokenOk = $user->matchEditToken( $request->getVal( 'token' ), 'watchlistedit' ) && $request->getVal( 'collabwatchlist' ) !== 0;
267270 if ( $tokenOk === false )
268271 return $tokenOk;
269272 return $this->checkPermissions( $user, $rlId, $memberTypes );
270273 }
271274
272 - private function checkPermissions( $user, $rlId, $memberTypes = array( COLLABWATCHLISTUSER_OWNER ) ) {
 275+ private function checkPermissions( $user, $rlId, $memberTypes = NULL ) {
 276+ if ( is_null($member_types) )
 277+ $member_types = array( CollabWatchlist::$USER_OWNER );
 278+
273279 // Check permissions
274280 $dbr = wfGetDB( DB_MASTER );
275281 $res = $dbr->select( 'collabwatchlistuser',
276282 'COUNT(*) AS count',
277 - array( 'rl_id' => $rlId, 'user_id' => $user->getId(), 'rlu_type' => $memberTypes ),
 283+ array( 'cw_id' => $rlId, 'user_id' => $user->getId(), 'rlu_type' => $memberTypes ),
278284 __METHOD__
279285 );
280286 $row = $dbr->fetchObject( $res );
@@ -313,22 +319,22 @@
314320 }
315321
316322 private function extractTypeTypeTextAndUsername( $typeAndUsernameStr ) {
317 - $type = COLLABWATCHLISTUSER_USER;
318 - $typeText = COLLABWATCHLISTUSER_USER_TEXT;
 323+ $type = CollabWatchlist::$USER_USER;
 324+ $typeText = CollabWatchlist::$USER_USER_TEXT;
319325 $text = trim( $typeAndUsernameStr );
320326 $titleText = $text;
321 - if ( stripos( $text, COLLABWATCHLISTUSER_OWNER_TEXT . ' ' ) === 0 ) {
322 - $type = COLLABWATCHLISTUSER_OWNER;
323 - $typeText = COLLABWATCHLISTUSER_OWNER_TEXT;
324 - $titleText = trim( substr( $text, strlen( COLLABWATCHLISTUSER_OWNER_TEXT . ' ' ) ) );
325 - } else if ( stripos( $text, COLLABWATCHLISTUSER_USER_TEXT . ' ' ) === 0 ) {
326 - $type = COLLABWATCHLISTUSER_USER;
327 - $typeText = COLLABWATCHLISTUSER_USER_TEXT;
328 - $titleText = trim( substr( $text, strlen( COLLABWATCHLISTUSER_USER_TEXT . ' ' ) ) );
329 - } else if ( stripos( $text, COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT . ' ' ) === 0 ) {
330 - $type = COLLABWATCHLISTUSER_TRUSTED_EDITOR;
331 - $typeText = COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT;
332 - $titleText = trim( substr( $text, strlen( COLLABWATCHLISTUSER_TRUSTED_EDITOR_TEXT . ' ' ) ) );
 327+ if ( stripos( $text, CollabWatchlist::$USER_OWNER_TEXT . ' ' ) === 0 ) {
 328+ $type = CollabWatchlist::$USER_OWNER;
 329+ $typeText = CollabWatchlist::$USER_OWNER_TEXT;
 330+ $titleText = trim( substr( $text, strlen( CollabWatchlist::$USER_OWNER_TEXT . ' ' ) ) );
 331+ } else if ( stripos( $text, CollabWatchlist::$USER_USER_TEXT . ' ' ) === 0 ) {
 332+ $type = CollabWatchlist::$USER_USER;
 333+ $typeText = CollabWatchlist::$USER_USER_TEXT;
 334+ $titleText = trim( substr( $text, strlen( CollabWatchlist::$USER_USER_TEXT . ' ' ) ) );
 335+ } else if ( stripos( $text, CollabWatchlist::$USER_TRUSTED_EDITOR_TEXT . ' ' ) === 0 ) {
 336+ $type = CollabWatchlist::$USER_TRUSTED_EDITOR;
 337+ $typeText = CollabWatchlist::$USER_TRUSTED_EDITOR_TEXT;
 338+ $titleText = trim( substr( $text, strlen( CollabWatchlist::$USER_TRUSTED_EDITOR_TEXT . ' ' ) ) );
333339 }
334340 return array( $type, $typeText, $titleText );
335341 }
@@ -454,7 +460,7 @@
455461 */
456462 private function countCollabWatchlistCategories( $rlId ) {
457463 $dbr = wfGetDB( DB_MASTER );
458 - $res = $dbr->select( 'collabwatchlistcategory', 'COUNT(*) AS count', array( 'rl_id' => $rlId ), __METHOD__ );
 464+ $res = $dbr->select( 'collabwatchlistcategory', 'COUNT(*) AS count', array( 'cw_id' => $rlId ), __METHOD__ );
459465 $row = $dbr->fetchObject( $res );
460466 return $row->count;
461467 }
@@ -467,7 +473,7 @@
468474 */
469475 private function countCollabWatchlistUsers( $rlId ) {
470476 $dbr = wfGetDB( DB_MASTER );
471 - $res = $dbr->select( 'collabwatchlistuser', 'COUNT(*) AS count', array( 'rl_id' => $rlId ), __METHOD__ );
 477+ $res = $dbr->select( 'collabwatchlistuser', 'COUNT(*) AS count', array( 'cw_id' => $rlId ), __METHOD__ );
472478 $row = $dbr->fetchObject( $res );
473479 return $row->count;
474480 }
@@ -480,7 +486,7 @@
481487 */
482488 private function countCollabWatchlistTags( $rlId ) {
483489 $dbr = wfGetDB( DB_MASTER );
484 - $res = $dbr->select( 'collabwatchlisttag', 'COUNT(*) AS count', array( 'rl_id' => $rlId ), __METHOD__ );
 490+ $res = $dbr->select( 'collabwatchlisttag', 'COUNT(*) AS count', array( 'cw_id' => $rlId ), __METHOD__ );
485491 $row = $dbr->fetchObject( $res );
486492 return $row->count;
487493 }
@@ -493,7 +499,7 @@
494500 */
495501 private function countCollabWatchlistSetTags( $rlId ) {
496502 $dbr = wfGetDB( DB_MASTER );
497 - $res = $dbr->select( 'collabwatchlistrevisiontag', 'COUNT(*) AS count', array( 'rl_id' => $rlId ), __METHOD__ );
 503+ $res = $dbr->select( 'collabwatchlistrevisiontag', 'COUNT(*) AS count', array( 'cw_id' => $rlId ), __METHOD__ );
498504 $row = $dbr->fetchObject( $res );
499505 return $row->count;
500506 }
@@ -512,7 +518,7 @@
513519 array( 'collabwatchlistcategory', 'page' ),
514520 array( 'page_title', 'page_namespace', 'subtract' ),
515521 array(
516 - 'rl_id' => $rlId,
 522+ 'cw_id' => $rlId,
517523 ),
518524 __METHOD__, array(),
519525 # Join conditions
@@ -542,7 +548,7 @@
543549 array( 'collabwatchlistuser', 'user' ),
544550 array( 'user_name', 'rlu_type' ),
545551 array(
546 - 'rl_id' => $rlId,
 552+ 'cw_id' => $rlId,
547553 ),
548554 __METHOD__, array(),
549555 # Join conditions
@@ -550,7 +556,7 @@
551557 );
552558 if ( $res->numRows() > 0 ) {
553559 foreach ( $res as $row ) {
554 - $typeText = fnCollabWatchlistUserTypeToText( $row->rlu_type );
 560+ $typeText = Collabwatchlist::userTypeToText( $row->rlu_type );
555561 $list[] = $typeText . ' ' . $row->user_name;
556562 }
557563 }
@@ -571,7 +577,7 @@
572578 array( 'collabwatchlisttag' ),
573579 array( 'rt_name', 'rt_description' ),
574580 array(
575 - 'rl_id' => $rlId,
 581+ 'cw_id' => $rlId,
576582 ), __METHOD__
577583 );
578584 if ( $res->numRows() > 0 ) {
@@ -598,7 +604,7 @@
599605 array( 'collabwatchlistcategory', 'page' ),
600606 array( 'page_title', 'page_namespace', 'page_id', 'page_len', 'page_is_redirect', 'subtract' ),
601607 array(
602 - 'rl_id' => $rlId,
 608+ 'cw_id' => $rlId,
603609 ),
604610 __METHOD__, array(),
605611 # Join conditions
@@ -704,7 +710,7 @@
705711 */
706712 private function clearCollabWatchlist( $rlId ) {
707713 $dbw = wfGetDB( DB_MASTER );
708 - $dbw->delete( 'collabwatchlistcategory', array( 'rl_id' => $rlId ), __METHOD__ );
 714+ $dbw->delete( 'collabwatchlistcategory', array( 'cw_id' => $rlId ), __METHOD__ );
709715 }
710716
711717 /**
@@ -731,7 +737,7 @@
732738 $titleObj = Title::newFromText( $titleText );
733739 if ( $titleObj instanceof Title && $titleObj->exists() ) {
734740 $rows[] = array(
735 - 'rl_id' => $rlId,
 741+ 'cw_id' => $rlId,
736742 'cat_page_id' => $titleObj->getArticleID(),
737743 'subtract' => $subtract,
738744 );
@@ -759,7 +765,7 @@
760766 $user = User::newFromName( $titleText );
761767 if ( $user instanceof User && $user->getId() !== 0 ) {
762768 $rows[] = array(
763 - 'rl_id' => $rlId,
 769+ 'cw_id' => $rlId,
764770 'user_id' => $user->getId(),
765771 'rlu_type' => $type,
766772 );
@@ -789,7 +795,7 @@
790796 }
791797 }
792798 // Add the tagged revisions to the collaborative watchlist
793 - $sql = 'INSERT IGNORE INTO collabwatchlistrevisiontag (ct_rc_id, ct_tag, rl_id, user_id, rrt_comment)
 799+ $sql = 'INSERT IGNORE INTO collabwatchlistrevisiontag (ct_rc_id, ct_tag, cw_id, user_id, rrt_comment)
794800 SELECT ct_rc_id, ct_tag, ' . $dbw->strencode( $rlId ) . ',' .
795801 $dbw->strencode( $userId ) . ',' .
796802 $dbw->addQuotes( $comment ) . ' FROM change_tag WHERE ct_tag = ? AND ct_rc_id ';
@@ -844,7 +850,7 @@
845851 $rows = array();
846852 foreach ( $titles as $title => $description ) {
847853 $rows[] = array(
848 - 'rl_id' => $rlId,
 854+ 'cw_id' => $rlId,
849855 'rt_name' => $title,
850856 'rt_description' => $description,
851857 );
@@ -876,7 +882,7 @@
877883 $dbw->delete(
878884 'collabwatchlistcategory',
879885 array(
880 - 'rl_id' => $rlId,
 886+ 'cw_id' => $rlId,
881887 'cat_page_id' => $title->getArticleID(),
882888 'subtract' => $subtract,
883889 ),
@@ -906,7 +912,7 @@
907913 $dbw->delete(
908914 'collabwatchlistuser',
909915 array(
910 - 'rl_id' => $rlId,
 916+ 'cw_id' => $rlId,
911917 'user_id' => $user->getId(),
912918 'rlu_type' => $type,
913919 ),
@@ -932,7 +938,7 @@
933939 $dbw->delete(
934940 'collabwatchlisttag',
935941 array(
936 - 'rl_id' => $rlId,
 942+ 'cw_id' => $rlId,
937943 'rt_name' => $title,
938944 ),
939945 __METHOD__
@@ -1003,11 +1009,11 @@
10041010 $dbw = wfGetDB( DB_MASTER );
10051011 $dbw->begin();
10061012 try {
1007 - $rl_id = $dbw->nextSequenceValue( 'collabwatchlist_rl_id_seq' );
 1013+ $cw_id = $dbw->nextSequenceValue( 'collabwatchlist_cw_id_seq' );
10081014 $dbw->insert( 'collabwatchlist', array(
1009 - 'rl_id' => $rl_id,
1010 - 'rl_name' => $name,
1011 - 'rl_start' => wfTimestamp( TS_ISO_8601 ),
 1015+ 'cw_id' => $cw_id,
 1016+ 'cw_name' => $name,
 1017+ 'cw_start' => wfTimestamp( TS_ISO_8601 ),
10121018 ), __METHOD__, 'IGNORE' );
10131019
10141020 $affected = $dbw->affectedRows();
@@ -1019,9 +1025,9 @@
10201026 $rlu_id = $dbw->nextSequenceValue( 'collabwatchlistuser_rlu_id_seq' );
10211027 $dbw->insert( 'collabwatchlistuser', array(
10221028 'rlu_id' => $rlu_id,
1023 - 'rl_id' => $newid,
 1029+ 'cw_id' => $newid,
10241030 'user_id' => $wgUser->getId(),
1025 - 'rlu_type' => COLLABWATCHLISTUSER_OWNER,
 1031+ 'rlu_type' => CollabWatchlist::$USER_OWNER,
10261032 ), __METHOD__, 'IGNORE' );
10271033 $affected = $dbw->affectedRows();
10281034 if ( ! $affected ) {
@@ -1042,19 +1048,19 @@
10431049 $dbw->begin();
10441050 try {
10451051 $dbw->delete( 'collabwatchlistrevisiontag', array(
1046 - 'rl_id' => $rlId,
 1052+ 'cw_id' => $rlId,
10471053 ), __METHOD__ );
10481054 $dbw->delete( 'collabwatchlisttag', array(
1049 - 'rl_id' => $rlId,
 1055+ 'cw_id' => $rlId,
10501056 ), __METHOD__ );
10511057 $dbw->delete( 'collabwatchlistcategory', array(
1052 - 'rl_id' => $rlId,
 1058+ 'cw_id' => $rlId,
10531059 ), __METHOD__ );
10541060 $dbw->delete( 'collabwatchlistuser', array(
1055 - 'rl_id' => $rlId,
 1061+ 'cw_id' => $rlId,
10561062 ), __METHOD__ );
10571063 $dbw->delete( 'collabwatchlist', array(
1058 - 'rl_id' => $rlId,
 1064+ 'cw_id' => $rlId,
10591065 ), __METHOD__ );
10601066 $affected = $dbw->affectedRows();
10611067 if ( ! $affected ) {
Index: trunk/extensions/CollabWatchlist/CollabWatchlist.hooks.php
@@ -0,0 +1,47 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) ) {
 4+ die();
 5+}
 6+
 7+/** Provides hooks for the CollabWatchlist extension
 8+ * @author fhackenberger
 9+ */
 10+class CollabWatchlistHooks {
 11+ /** Provide info for the DB schem upgrade framework */
 12+ public static function onLoadExtensionSchemaUpdates( $updater ) {
 13+ $sqlDir = dirname(__FILE__) . '/sql/';
 14+ $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlist',
 15+ $sqlDir . 'collabwatchlist.sql', true ) );
 16+ $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistuser',
 17+ $sqlDir . 'collabwatchlistuser.sql', true ) );
 18+ $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistcategory',
 19+ $sqlDir . 'collabwatchlistcategory.sql', true ) );
 20+ $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlistrevisiontag',
 21+ $sqlDir . 'collabwatchlistrevisiontag.sql', true ) );
 22+ $updater->addExtensionUpdate( array ( 'addTable', 'collabwatchlisttag',
 23+ $sqlDir . 'collabwatchlisttag.sql', true ) );
 24+ $updater->addExtensionUpdate( array( 'addField', 'collabwatchlistrevisiontag', 'ct_rc_id',
 25+ $sqlDir . 'patch-collabwatchlist_noctid.sql', true ) );
 26+ $updater->addExtensionUpdate( array( 'addField', 'collabwatchlist', 'cw_id',
 27+ $sqlDir . 'patch-collabwatchlist_rename_fields.sql', true ) );
 28+ $updater->addExtensionUpdate( array( 'addField', 'collabwatchlistuser', 'rlu_type',
 29+ $sqlDir . 'patch-collabwatchlist_remove_enum.sql', true ) );
 30+ $updater->addExtensionUpdate( array( 'modifyField', 'collabwatchlisttag', 'rt_id',
 31+ $sqlDir . 'patch-collabwatchlist_remove_primary_keys.sql', true ) );
 32+ return true;
 33+ }
 34+
 35+ public static function onGetPreferences( $user, &$preferences ) {
 36+ $preferences['collabwatchlisthidelistuser'] = array(
 37+ 'type' => 'toggle',
 38+ 'label-message' => 'tog-collabwatchlisthidelistusers',
 39+ 'section' => 'watchlist/advancedwatchlist',
 40+ );
 41+ return true;
 42+ }
 43+
 44+ public static function onUnitTestsList( &$files ) {
 45+ $files[] = dirname( __FILE__ ) . '/tests/CollabWatchlistTest.php';
 46+ return true;
 47+ }
 48+}
Property changes on: trunk/extensions/CollabWatchlist/CollabWatchlist.hooks.php
___________________________________________________________________
Added: svn:eol-style
149 + native
Index: trunk/extensions/CollabWatchlist/CollabWatchlist.class.php
@@ -0,0 +1,35 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) ) {
 4+ die();
 5+}
 6+
 7+/** Provides hooks for the CollabWatchlist extension
 8+ * @author fhackenberger
 9+ */
 10+class CollabWatchlist {
 11+ /**
 12+ * Collaborative watchlist user types
 13+ * Defines constants for the collabwatchlistuser.rlu_type
 14+ */
 15+ /** owners are allowed to edit the list */
 16+ public static $USER_OWNER = 1;
 17+ /** owners are allowed to edit the list */
 18+ public static $USER_OWNER_TEXT = 'Owner';
 19+ /** users are allowed to view the list and tag edits */
 20+ public static $USER_USER = 2;
 21+ /** users are allowed to view the list and tag edits */
 22+ public static $USER_USER_TEXT = 'User';
 23+ /** trusted editors are used to filter edits which don't require a review */
 24+ public static $USER_TRUSTED_EDITOR = 3;
 25+ /** trusted editors are used to filter edits which don't require a review */
 26+ public static $USER_TRUSTED_EDITOR_TEXT = 'TrustedEditor';
 27+
 28+ public static function userTypeToText( $userType ) {
 29+ if ( $userType === CollabWatchlist::$USER_OWNER )
 30+ return CollabWatchlist::$USER_OWNER_TEXT;
 31+ if ( $userType === CollabWatchlist::$USER_USER )
 32+ return CollabWatchlist::$USER_USER_TEXT;
 33+ if ( $userType === CollabWatchlist::$USER_TRUSTED_EDITOR )
 34+ return CollabWatchlist::$USER_TRUSTED_EDITOR_TEXT;
 35+ }
 36+}
Property changes on: trunk/extensions/CollabWatchlist/CollabWatchlist.class.php
___________________________________________________________________
Added: svn:eol-style
137 + native
Index: trunk/extensions/CollabWatchlist/mediawiki_core.patch.99863
@@ -0,0 +1,124 @@
 2+Index: includes/ChangesList.php
 3+===================================================================
 4+--- includes/ChangesList.php (revision 99863)
 5+@@ -763,6 +763,44 @@
 6+ return $ret;
 7+ }
 8+
 9++ protected function insertDiffAndHistLinks( &$s, &$rc ) {
 10++ $s .= ' ('. $rc->difflink;
 11++ $this->insertHistLink($s, $rc, $rc->getTitle());
 12++ $s .= ')';
 13++ }
 14++
 15++ protected function insertHistLink( &$s, &$rc, $title, $params = array(), $sep = NULL ) {
 16++ $params['action'] = 'history';
 17++ $s .= isset($sep) ? $sep : $this->message['pipe-separator'] .
 18++ Linker::linkKnown(
 19++ $title,
 20++ $this->message['hist'],
 21++ array(),
 22++ $params
 23++ );
 24++ }
 25++
 26++ protected function insertBeforeRCFlags( &$r, &$rcObj ) {
 27++
 28++ }
 29++
 30++ protected function insertBeforeRCFlagsBlock( &$r, &$block ) {
 31++
 32++ }
 33++
 34++ protected function insertCurrAndLastLinks( &$s, &$rc ) {
 35++ $s .= ' (';
 36++ $s .= $rc->curlink;
 37++ $s .= $this->message['pipe-separator'];
 38++ $s .= $rc->lastlink;
 39++ $s .= ')';
 40++ }
 41++
 42++ protected function insertUserAndTalkLinks( &$s, &$rc ) {
 43++ $s .= $rc->userlink;
 44++ $s .= $rc->usertalklink;
 45++ }
 46++
 47+ /**
 48+ * Enhanced RC group
 49+ */
 50+@@ -850,7 +888,7 @@
 51+ . "<a href='#' title='$closeTitle'>{$this->downArrow()}</a>"
 52+ . "</span></span>";
 53+ $r .= "<td>$tl</td>";
 54+-
 55++ $this->insertBeforeRCFlagsBlock($r, $block);
 56+ # Main line
 57+ $r .= '<td class="mw-enhanced-rc">' . $this->recentChangesFlags( array(
 58+ 'newpage' => $isnew,
 59+@@ -910,15 +948,8 @@
 60+ $r .= $this->message['pipe-separator'] . $this->message['hist'] . ')';
 61+ } else {
 62+ $params = $queryParams;
 63+- $params['action'] = 'history';
 64+-
 65+- $r .= $this->message['pipe-separator'] .
 66+- Linker::linkKnown(
 67+- $block[0]->getTitle(),
 68+- $this->message['hist'],
 69+- array(),
 70+- $params
 71+- ) . ')';
 72++ $this->insertHistLink($r, $rcObj, $block[0]->getTitle(), $params);
 73++ $r .= ')';
 74+ }
 75+ $r .= ' . . ';
 76+
 77+@@ -955,6 +986,7 @@
 78+
 79+ #$r .= '<tr><td valign="top">'.$this->spacerArrow();
 80+ $r .= '<tr><td></td><td class="mw-enhanced-rc">';
 81++ $this->insertBeforeRCFlags( $r, $rcObj );
 82+ $r .= $this->recentChangesFlags( array(
 83+ 'newpage' => $rcObj->mAttribs['rc_new'],
 84+ 'minor' => $rcObj->mAttribs['rc_minor'],
 85+@@ -992,11 +1024,7 @@
 86+ $r .= $link . '</span>';
 87+
 88+ if ( !$type == RC_LOG || $type == RC_NEW ) {
 89+- $r .= ' (';
 90+- $r .= $rcObj->curlink;
 91+- $r .= $this->message['pipe-separator'];
 92+- $r .= $rcObj->lastlink;
 93+- $r .= ')';
 94++ $this->insertCurrAndLastLinks( $r, $rcObj );
 95+ }
 96+ $r .= ' . . ';
 97+
 98+@@ -1009,8 +1037,7 @@
 99+ $r .= $this->insertLogEntry( $rcObj );
 100+ } else {
 101+ # User links
 102+- $r .= $rcObj->userlink;
 103+- $r .= $rcObj->usertalklink;
 104++ $this->insertUserAndTalkLinks( $r, $rcObj );
 105+ $r .= $this->insertComment( $rcObj );
 106+ }
 107+
 108+@@ -1097,6 +1124,7 @@
 109+ Html::openElement( 'tr' );
 110+
 111+ $r .= '<td class="mw-enhanced-rc">' . $this->spacerArrow();
 112++ $this->insertBeforeRCFlags( $r, $rcObj );
 113+ # Flag and Timestamp
 114+ if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
 115+ $r .= '&#160;&#160;&#160;&#160;'; // 4 flags -> 4 spaces
 116+@@ -1137,7 +1165,7 @@
 117+ if ( $type == RC_LOG ) {
 118+ $r .= $this->insertLogEntry( $rcObj );
 119+ } else {
 120+- $r .= ' '.$rcObj->userlink . $rcObj->usertalklink;
 121++ $this->insertUserAndTalkLinks($r, $rcObj);
 122+ $r .= $this->insertComment( $rcObj );
 123+ $r .= $this->insertRollback( $r, $rcObj );
 124+ }

Comments

#Comment by MarkAHershberger (talk | contribs)   03:33, 7 November 2011

Umm, first you remove the rl_id field from collabwatchlistuser: - rl_id integer unsigned NOT NULL,

and then you create an index based on it?

+CREATE UNIQUE INDEX rl_id ON /*$wgDBprefix*/collabwatchlistuser (rl_id, user_id);

#Comment by MarkAHershberger (talk | contribs)   04:04, 7 November 2011

I really recommend you run with E_STRICT when developing. Not doing so probably meant the following references to an undefined $member_types slipped through:

+ private function checkToken( $request, $user, $rlId, $memberTypes = NULL ) { + if ( is_null($member_types) ) + $member_types = array( CollabWatchlist::$USER_OWNER );

+ private function checkPermissions( $user, $rlId, $memberTypes = NULL ) { + if ( is_null($member_types) ) + $member_types = array( CollabWatchlist::$USER_OWNER );


Of course, the name probably slipped in there because you used the (non-MediaWiki-conforming) name here:

	 * @param array $member_types A list of allowed membership types
	 * @return array Mapping from collab watchlist id to its name
	 */

- public static function getCollabWatchlistIdAndName( $user_id, $member_types = array( COLLABWATCHLISTUSER_OWNER, COLLABWATCHLISTUSER_USER ) ) { + public static function getCollabWatchlistIdAndName( $user_id, $member_types = NULL ) {

Status & tagging log

  • 21:05, 21 October 2011 Reedy (talk | contribs) changed the status of r99867 [removed: new added: deferred]