Index: includes/Export.php
===================================================================
--- includes/Export.php	(revision 20273)
+++ includes/Export.php	(working copy)
@@ -163,7 +163,9 @@
 		$page     = $this->db->tableName( 'page' );
 		$revision = $this->db->tableName( 'revision' );
 		$text     = $this->db->tableName( 'text' );
+		$page_restrictions = $this->db->tableName( 'page_restrictions' );
 
+		$group = 'GROUP BY page_id';
 		$order = 'ORDER BY page_id';
 		$limit = '';
 
@@ -212,18 +214,18 @@
 			$straight = '';
 		}
 		if( $this->text == WikiExporter::STUB ) {
-			$sql = "SELECT $straight * FROM
-					$page $pageindex,
+			$sql = "SELECT $straight *, COUNT(pr_page) AS pr_count FROM FROM
+					$page $pageindex LEFT OUTER JOIN $page_restrictions ON page_id=pr_page,
 					$revision $revindex
 					WHERE $where $join
-					$order $limit";
+					$group $order $limit";
 		} else {
-			$sql = "SELECT $straight * FROM
-					$page $pageindex,
+			$sql = "SELECT $straight *, COUNT(pr_page) AS pr_count FROM
+					$page $pageindex LEFT OUTER JOIN $page_restrictions ON page_id=pr_page,
 					$revision $revindex,
 					$text
 					WHERE $where $join AND rev_text_id=old_id
-					$order $limit";
+					$group $order $limit";
 		}
 		$result = $this->db->query( $sql, $fname );
 		$wrapper = $this->db->resultObject( $result );
@@ -378,12 +380,41 @@
 		$title = Title::makeTitle( $row->page_namespace, $row->page_title );
 		$out .= '    ' . wfElementClean( 'title', array(), $title->getPrefixedText() ) . "\n";
 		$out .= '    ' . wfElement( 'id', array(), strval( $row->page_id ) ) . "\n";
-		if( '' != $row->page_restrictions ) {
+		$restrictions = $this->expandRestrictions( $row->page_id,
+			$row->page_restrictions, $row->pr_count );
+		if( '' != $restrictions ) {
 			$out .= '    ' . wfElement( 'restrictions', array(),
-				strval( $row->page_restrictions ) ) . "\n";
+				strval( $restrictions ) ) . "\n";
 		}
 		return $out;
 	}
+	
+	/**
+	 * Use the classic (<1.9) page_restrictions field if available,
+	 * or emulate it with the new page_restrictions table.
+	 *
+	 * @fixme This will miss cascade info, per-user restrictions, etc.
+	 */
+	private function expandRestrictions( $id, $restrictions, $count ) {
+		if( $count == 0 ) {
+			return $restrictions;
+		} else {
+			// Flatten the restriction information from the new table
+			// into classic format.
+			// This is missing some new information such as cascades...
+			global $wgRestrictionTypes;
+			$title = Title::newFromId( $id );
+			if( $title ) {
+				$current = array();
+				foreach( $wgRestrictionTypes as $action )
+					$current[$action] = implode( '', $title->getRestrictions( $action ) );
+				return Article::flattenRestrictions( $current );
+			} else {
+				// Ideally this shouldn't happen.
+				return '';
+			}
+		}
+	}
 
 	/**
 	 * Closes a <page> section on the output stream.
