Code Duplication    Length = 12-16 lines in 2 locations

includes/Revision.php 2 locations

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