Index: branches/change-tagging/phase3/includes/ChangeTags.php |
— | — | @@ -32,10 +32,20 @@ |
33 | 33 | throw new MWException( "At least one of: RCID, revision ID, and log ID MUST be specified when adding a tag to a change!" ); |
34 | 34 | } |
35 | 35 | |
| 36 | + $dbr = wfGetDB( DB_SLAVE ); |
| 37 | + |
| 38 | + // Might as well look for rcids and so on. |
| 39 | + if (!$rc_id) { |
| 40 | + if ($log_id) { |
| 41 | + $rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_logid' => $log_id ), __METHOD__ ); |
| 42 | + } elseif ($rev_id) { |
| 43 | + $rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_this_oldid' => $rev_id ), __METHOD__ ); |
| 44 | + } |
| 45 | + } |
| 46 | + |
36 | 47 | $tsConds = array_filter( array( 'ts_rc_id' => $rc_id, 'ts_rev_id' => $rev_id, 'ts_log_id' => $log_id ) ); |
37 | 48 | |
38 | 49 | ## Update the summary row. |
39 | | - $dbr = wfGetDB( DB_SLAVE ); |
40 | 50 | $prevTags = $dbr->selectField( 'tag_summary', 'ts_tags', $tsConds, __METHOD__ ); |
41 | 51 | $prevTags = $prevTags ? $prevTags : ''; |
42 | 52 | $prevTags = array_filter( explode( ',', $prevTags ) ); |
— | — | @@ -50,7 +60,7 @@ |
51 | 61 | } |
52 | 62 | |
53 | 63 | $dbw = wfGetDB( DB_MASTER ); |
54 | | - $dbw->replace( 'tag_summary', array( 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ), array( array_merge( $tsConds, array( 'ts_tags' => implode( ',', $newTags ) ) ) ), __METHOD__ ); |
| 64 | + $dbw->replace( 'tag_summary', array( 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ), array_filter( array_merge( $tsConds, array( 'ts_tags' => implode( ',', $newTags ) ) ) ), __METHOD__ ); |
55 | 65 | |
56 | 66 | // Insert the tags rows. |
57 | 67 | $tagsRows = array(); |