RCFeed: Use named types instead of exposing internal MW constant
[lhc/web/wiklou.git] / includes / rcfeed / MachineReadableRCFeedFormatter.php
index 9321f52..d61b6c0 100644 (file)
@@ -38,7 +38,7 @@ abstract class MachineReadableRCFeedFormatter implements RCFeedFormatter {
         * @see RCFeedFormatter::getLine
         */
        public function getLine( array $feed, RecentChange $rc, $actionComment ) {
-               global $wgCanonicalServer, $wgScriptPath;
+               global $wgCanonicalServer, $wgServerName, $wgScriptPath;
                $attrib = $rc->getAttributes();
 
                $packet = array(
@@ -46,7 +46,7 @@ abstract class MachineReadableRCFeedFormatter implements RCFeedFormatter {
                        // but there is no real reason not to expose it in other cases,
                        // and I can see how this may be potentially useful for clients.
                        'id' => $attrib['rc_id'],
-                       'type' => $attrib['rc_type'],
+                       'type' => RecentChange::parseFromRCType( $attrib['rc_type'] ),
                        'namespace' => $rc->getTitle()->getNamespace(),
                        'title' => $rc->getTitle()->getPrefixedText(),
                        'comment' => $attrib['rc_comment'],
@@ -63,9 +63,9 @@ abstract class MachineReadableRCFeedFormatter implements RCFeedFormatter {
                if ( $type == RC_EDIT || $type == RC_NEW ) {
                        global $wgUseRCPatrol, $wgUseNPPatrol;
 
-                       $packet['minor'] = $attrib['rc_minor'];
+                       $packet['minor'] = (bool)$attrib['rc_minor'];
                        if ( $wgUseRCPatrol || ( $type == RC_NEW && $wgUseNPPatrol ) ) {
-                               $packet['patrolled'] = $attrib['rc_patrolled'];
+                               $packet['patrolled'] = (bool)$attrib['rc_patrolled'];
                        }
                }
 
@@ -120,6 +120,8 @@ abstract class MachineReadableRCFeedFormatter implements RCFeedFormatter {
                }
 
                $packet['server_url'] = $wgCanonicalServer;
+               $packet['server_name'] = $wgServerName;
+
                $packet['server_script_path'] = $wgScriptPath ?: '/';
                $packet['wiki'] = wfWikiID();