|
@@ 117-132 (lines=16) @@
|
| 114 |
|
* @param int $flags Bitfield (optional) |
| 115 |
|
* @return Revision|null |
| 116 |
|
*/ |
| 117 |
|
public static function newFromTitle( LinkTarget $linkTarget, $id = 0, $flags = 0 ) { |
| 118 |
|
$conds = [ |
| 119 |
|
'page_namespace' => $linkTarget->getNamespace(), |
| 120 |
|
'page_title' => $linkTarget->getDBkey() |
| 121 |
|
]; |
| 122 |
|
if ( $id ) { |
| 123 |
|
// Use the specified ID |
| 124 |
|
$conds['rev_id'] = $id; |
| 125 |
|
return self::newFromConds( $conds, $flags ); |
| 126 |
|
} else { |
| 127 |
|
// Use a join to get the latest revision |
| 128 |
|
$conds[] = 'rev_id=page_latest'; |
| 129 |
|
$db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_SLAVE ); |
| 130 |
|
return self::loadFromConds( $db, $conds, $flags ); |
| 131 |
|
} |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
/** |
| 135 |
|
* Load either the current, or a specified, revision |
|
@@ 148-159 (lines=12) @@
|
| 145 |
|
* @param int $flags Bitfield (optional) |
| 146 |
|
* @return Revision|null |
| 147 |
|
*/ |
| 148 |
|
public static function newFromPageId( $pageId, $revId = 0, $flags = 0 ) { |
| 149 |
|
$conds = [ 'page_id' => $pageId ]; |
| 150 |
|
if ( $revId ) { |
| 151 |
|
$conds['rev_id'] = $revId; |
| 152 |
|
return self::newFromConds( $conds, $flags ); |
| 153 |
|
} else { |
| 154 |
|
// Use a join to get the latest revision |
| 155 |
|
$conds[] = 'rev_id = page_latest'; |
| 156 |
|
$db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_SLAVE ); |
| 157 |
|
return self::loadFromConds( $db, $conds, $flags ); |
| 158 |
|
} |
| 159 |
|
} |
| 160 |
|
|
| 161 |
|
/** |
| 162 |
|
* Make a fake revision object from an archive table row. This is queried |