- /* static */ function listAllPages() {
- $dbr =& wfGetDB( DB_SLAVE );
- $archive = $dbr->tableName( 'archive' );
-
- $sql = "SELECT ar_namespace,ar_title, COUNT(*) AS count FROM $archive " .
- "GROUP BY ar_namespace,ar_title ORDER BY ar_namespace,ar_title";
-
- return $dbr->resultObject( $dbr->query( $sql, 'PageArchive::listAllPages' ) );
+ public static function listAllPages() {
+ $dbr = wfGetDB( DB_SLAVE );
+ return self::listPages( $dbr, '' );
+ }
+
+ /**
+ * List deleted pages recorded in the archive table matching the
+ * given title prefix.
+ * Returns result wrapper with (ar_namespace, ar_title, count) fields.
+ *
+ * @return ResultWrapper
+ */
+ public static function listPagesByPrefix( $prefix ) {
+ $dbr = wfGetDB( DB_SLAVE );
+
+ $title = Title::newFromText( $prefix );
+ if( $title ) {
+ $ns = $title->getNamespace();
+ $encPrefix = $dbr->escapeLike( $title->getDbKey() );
+ } else {
+ // Prolly won't work too good
+ // @todo handle bare namespace names cleanly?
+ $ns = 0;
+ $encPrefix = $dbr->escapeLike( $prefix );
+ }
+ $conds = array(
+ 'ar_namespace' => $ns,
+ "ar_title LIKE '$encPrefix%'",
+ );
+ return self::listPages( $dbr, $conds );