[MediaWiki-commits] [Gerrit] Add new recentchanges field rc_source to replace rc_type - change (mediawiki/core)
jenkins-bot has submitted this change and it was merged. Change subject: Add new recentchanges field rc_source to replace rc_type .. Add new recentchanges field rc_source to replace rc_type The existing field to differentiate between kinds of recentchanges rows is the rc_type field. We want to allow extensions to insert their own custom data into recentchanges, but we have learned via the NS_* series of constants that requiring extensions to register a specific number is very error prone. The solution, which this commit implements the first phase of, is to utilize a new 16 byte string field rc_source. Within that field change types will be prefixed strings such as 'mw.edit' and 'mw.new'. This commit adds the new field and begins populating it with data. At some point in the future the rc_type field will be dropped. While WMF wiki's will simply wait out the 30 day recentchanges history, other wiki's have the option of letting update.php populate rc_source, or manually applying the db change and utilizing the PopulateRecentChangeSource maintenance script. Change-Id: Iaddd6c446373a68d31586ed54346db7d04e13b2c --- M RELEASE-NOTES-1.22 M includes/RecentChange.php M includes/installer/MysqlUpdater.php M includes/installer/PostgresUpdater.php M includes/installer/SqliteUpdater.php A maintenance/archives/patch-rc_source.sql A maintenance/populateRecentChangesSource.php M maintenance/postgres/tables.sql M maintenance/rebuildrecentchanges.php M maintenance/tables.sql 10 files changed, 157 insertions(+), 0 deletions(-) Approvals: Aaron Schulz: Looks good to me, approved jenkins-bot: Verified diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 3112e26..dadedd2 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -366,6 +366,15 @@ * (bug 46751) Made Buryat (Russia) (буряад) (bxr) fallback to Russian. === Other changes in 1.22 === +* The rc_type field in the recentchanges table has been superseded by a new + rc_source field. The rc_source field is a string representation of the + change type where rc_type was a numeric constant. This field is not yet + queried but will be in a future point release of 1.22. +** Utilize update.php to create and populate this new field. On larger wiki's + which do not wish to update recentchanges table in one large update please + review the sql and comments in maintenance/archives/patch-rc_source.sql. +** The rc_type field of recentchanges will be deprecated in a future point + release. * BREAKING CHANGE: Implementation of MediaWiki's JS and JSON value encoding has changed: ** MediaWiki no longer supports PHP installations in which the native JSON diff --git a/includes/RecentChange.php b/includes/RecentChange.php index 980bd0a..282890f 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -30,6 +30,7 @@ * rc_namespacenamespace # * rc_titlenon-prefixed db key * rc_type is new entry, used to determine whether updating is necessary + * rc_source string representation of change source * rc_minoris minor * rc_cur_id page_id of associated page entry * rc_user user id who made the entry @@ -64,6 +65,14 @@ * @todo document functions and variables */ class RecentChange { + + // Constants for the rc_source field. Extensions may also have + // their own source constants. + const SRC_EDIT = 'mw.edit'; + const SRC_NEW = 'mw.new'; + const SRC_LOG = 'mw.log'; + const SRC_EXTERNAL = 'mw.external'; // obsolete + var $mAttribs = array(), $mExtra = array(); /** @@ -159,6 +168,7 @@ 'rc_this_oldid', 'rc_last_oldid', 'rc_type', + 'rc_source', 'rc_patrolled', 'rc_ip', 'rc_old_len', @@ -489,6 +499,7 @@ 'rc_namespace' = $title-getNamespace(), 'rc_title' = $title-getDBkey(), 'rc_type' = RC_EDIT, + 'rc_source' = self::SRC_EDIT, 'rc_minor' = $minor ? 1 : 0, 'rc_cur_id' = $title-getArticleID(), 'rc_user' = $user-getId(), @@ -548,6 +559,7 @@ 'rc_namespace' = $title-getNamespace(), 'rc_title' = $title-getDBkey(), 'rc_type' = RC_NEW, + 'rc_source' = self::SRC_NEW, 'rc_minor' = $minor ? 1 : 0, 'rc_cur_id' = $title-getArticleID(), 'rc_user' = $user-getId(), @@ -657,6 +669,7 @@ 'rc_namespace' = $target-getNamespace(), 'rc_title'
[MediaWiki-commits] [Gerrit] Add new recentchanges field rc_source to replace rc_type - change (mediawiki/core)
EBernhardson (WMF) has uploaded a new change for review. https://gerrit.wikimedia.org/r/85787 Change subject: Add new recentchanges field rc_source to replace rc_type .. Add new recentchanges field rc_source to replace rc_type The existing field to differentiate between kinds of recentchanges rows is the rc_type field. We want to allow extensions to insert their own custom data into recentchanges, but we have learned via the NS_* series of constants that requiring extensions to register a specific number is very error prone. The solution, which this commit implements the first phase of, is to utilize a new 16 byte string field rc_source. Within that field change types will be prefixed strings such as 'mw.edit' and 'mw.new'. This commit adds the new field and begins populating it with data. At some point in the future the rc_type field will be dropped. Change-Id: Iaddd6c446373a68d31586ed54346db7d04e13b2c --- M includes/Defines.php M includes/RecentChange.php M includes/installer/MysqlUpdater.php M includes/installer/PostgresUpdater.php A maintenance/archives/patch-rc_source.sql M maintenance/postgres/tables.sql M maintenance/rebuildrecentchanges.php M maintenance/tables.sql 8 files changed, 25 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/87/85787/1 diff --git a/includes/Defines.php b/includes/Defines.php index 86c5520..02fd333 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -179,6 +179,14 @@ /**@}*/ /**@{ + * RecentChange source identifiers + */ +define( 'RC_SRC_EDIT', 'mw.edit' ); +define( 'RC_SRC_NEW', 'mw.new' ); +define( 'RC_SRC_LOG', 'mw.log' ); +/**@}*/ + +/**@{ * Article edit flags */ define( 'EDIT_NEW', 1 ); diff --git a/includes/RecentChange.php b/includes/RecentChange.php index 980bd0a..055e6a8 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -30,6 +30,7 @@ * rc_namespacenamespace # * rc_titlenon-prefixed db key * rc_type is new entry, used to determine whether updating is necessary + * rc_source string representation of change source * rc_minoris minor * rc_cur_id page_id of associated page entry * rc_user user id who made the entry @@ -159,6 +160,7 @@ 'rc_this_oldid', 'rc_last_oldid', 'rc_type', + 'rc_source', 'rc_patrolled', 'rc_ip', 'rc_old_len', @@ -489,6 +491,7 @@ 'rc_namespace' = $title-getNamespace(), 'rc_title' = $title-getDBkey(), 'rc_type' = RC_EDIT, + 'rc_source' = RC_SRC_EDIT, 'rc_minor' = $minor ? 1 : 0, 'rc_cur_id' = $title-getArticleID(), 'rc_user' = $user-getId(), @@ -548,6 +551,7 @@ 'rc_namespace' = $title-getNamespace(), 'rc_title' = $title-getDBkey(), 'rc_type' = RC_NEW, + 'rc_source' = RC_SRC_NEW, 'rc_minor' = $minor ? 1 : 0, 'rc_cur_id' = $title-getArticleID(), 'rc_user' = $user-getId(), @@ -657,6 +661,7 @@ 'rc_namespace' = $target-getNamespace(), 'rc_title' = $target-getDBkey(), 'rc_type' = RC_LOG, + 'rc_source' = RC_SRC_LOG, 'rc_minor' = 0, 'rc_cur_id' = $target-getArticleID(), 'rc_user' = $user-getId(), @@ -716,6 +721,7 @@ 'rc_comment' = $row-rev_comment, 'rc_minor' = $row-rev_minor_edit ? 1 : 0, 'rc_type' = $row-page_is_new ? RC_NEW : RC_EDIT, + 'rc_source' = $row-page_is_new ? RC_SRC_NEW : RC_SRC_EDIT, 'rc_cur_id' = $row-page_id, 'rc_this_oldid' = $row-rev_id, 'rc_last_oldid' = isset( $row-rc_last_oldid ) ? $row-rc_last_oldid : 0, diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 02faf7c..9220005 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -231,6 +231,7 @@ // 1.22 array( 'doIwlinksIndexNonUnique' ), array( 'addIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-iwlinks-from-title-index.sql' ), + array( 'addField', 'recentchanges', 'rc_source', 'patch-rc_source.sql' ), );