protected function addFieldsIf( $value, $condition ) {
if ( $condition ) {
$this->addFields( $value );
+
return true;
}
+
return false;
}
protected function addWhereIf( $value, $condition ) {
if ( $condition ) {
$this->addWhere( $value );
+
return true;
}
+
return false;
}
if ( $sort ) {
$order = $field . ( $isDirNewer ? '' : ' DESC' );
// Append ORDER BY
- $optionOrderBy = isset( $this->options['ORDER BY'] ) ? (array)$this->options['ORDER BY'] : array();
+ $optionOrderBy = isset( $this->options['ORDER BY'] )
+ ? (array)$this->options['ORDER BY']
+ : array();
$optionOrderBy[] = $order;
$this->addOption( 'ORDER BY', $optionOrderBy );
}
* @param string $method Function the query should be attributed to.
* You should usually use __METHOD__ here
* @param array $extraQuery Query data to add but not store in the object
- * Format is array( 'tables' => ..., 'fields' => ..., 'where' => ..., 'options' => ..., 'join_conds' => ... )
+ * Format is array(
+ * 'tables' => ...,
+ * 'fields' => ...,
+ * 'where' => ...,
+ * 'options' => ...,
+ * 'join_conds' => ...
+ * )
* @return ResultWrapper
*/
protected function select( $method, $extraQuery = array() ) {
- $tables = array_merge( $this->tables, isset( $extraQuery['tables'] ) ? (array)$extraQuery['tables'] : array() );
- $fields = array_merge( $this->fields, isset( $extraQuery['fields'] ) ? (array)$extraQuery['fields'] : array() );
- $where = array_merge( $this->where, isset( $extraQuery['where'] ) ? (array)$extraQuery['where'] : array() );
- $options = array_merge( $this->options, isset( $extraQuery['options'] ) ? (array)$extraQuery['options'] : array() );
- $join_conds = array_merge( $this->join_conds, isset( $extraQuery['join_conds'] ) ? (array)$extraQuery['join_conds'] : array() );
+ $tables = array_merge(
+ $this->tables,
+ isset( $extraQuery['tables'] ) ? (array)$extraQuery['tables'] : array()
+ );
+ $fields = array_merge(
+ $this->fields,
+ isset( $extraQuery['fields'] ) ? (array)$extraQuery['fields'] : array()
+ );
+ $where = array_merge(
+ $this->where,
+ isset( $extraQuery['where'] ) ? (array)$extraQuery['where'] : array()
+ );
+ $options = array_merge(
+ $this->options,
+ isset( $extraQuery['options'] ) ? (array)$extraQuery['options'] : array()
+ );
+ $join_conds = array_merge(
+ $this->join_conds,
+ isset( $extraQuery['join_conds'] ) ? (array)$extraQuery['join_conds'] : array()
+ );
// getDB has its own profileDBIn/Out calls
$db = $this->getDB();
protected function checkRowCount() {
$db = $this->getDB();
$this->profileDBIn();
- $rowcount = $db->estimateRowCount( $this->tables, $this->fields, $this->where, __METHOD__, $this->options );
+ $rowcount = $db->estimateRowCount(
+ $this->tables,
+ $this->fields,
+ $this->where,
+ __METHOD__,
+ $this->options
+ );
$this->profileDBOut();
global $wgAPIMaxDBRows;
if ( $rowcount > $wgAPIMaxDBRows ) {
return false;
}
+
return true;
}
protected function addPageSubItems( $pageId, $data ) {
$result = $this->getResult();
$result->setIndexedTagName( $data, $this->getModulePrefix() );
+
return $result->addValue( array( 'query', 'pages', intval( $pageId ) ),
$this->getModuleName(),
$data );
return false;
}
$result->setIndexedTagName_internal( array( 'query', 'pages', $pageId,
- $this->getModuleName() ), $elemname );
+ $this->getModuleName() ), $elemname );
+
return true;
}
if ( is_null( $this->mDb ) ) {
$this->mDb = $this->getQuery()->getDB();
}
+
return $this->mDb;
}
if ( !$t ) {
$this->dieUsageMsg( array( 'invalidtitle', $title ) );
}
+
return $t->getPrefixedDBkey();
}
if ( !$t ) {
$this->dieUsageMsg( array( 'invalidtitle', $key ) );
}
+
return $t->getPrefixedText();
}
* @return string Title part with underscores
*/
public function titlePartToKey( $titlePart ) {
- return substr( $this->titleToKey( $titlePart . 'x' ), 0, - 1 );
+ return substr( $this->titleToKey( $titlePart . 'x' ), 0, -1 );
}
/**
* @return string Key part with underscores
*/
public function keyPartToTitle( $keyPart ) {
- return substr( $this->keyToTitle( $keyPart . 'x' ), 0, - 1 );
+ return substr( $this->keyToTitle( $keyPart . 'x' ), 0, -1 );
}
/**
*/
public function getDirectionDescription( $p = '', $extraDirText = '' ) {
return array(
- "In which direction to enumerate{$extraDirText}",
- " newer - List oldest first. Note: {$p}start has to be before {$p}end.",
- " older - List newest first (default). Note: {$p}start has to be later than {$p}end.",
- );
+ "In which direction to enumerate{$extraDirText}",
+ " newer - List oldest first. Note: {$p}start has to be before {$p}end.",
+ " older - List newest first (default). Note: {$p}start has to be later than {$p}end.",
+ );
}
/**
* @param $protocol String
* @return null|string
*/
- public function prepareUrlQuerySearchString( $query = null, $protocol = null) {
+ public function prepareUrlQuerySearchString( $query = null, $protocol = null ) {
$db = $this->getDb();
if ( !is_null( $query ) || $query != '' ) {
if ( is_null( $protocol ) ) {
}
$likeQuery = LinkFilter::keepOneWildcard( $likeQuery );
+
return 'el_index ' . $db->buildLike( $likeQuery );
} elseif ( !is_null( $protocol ) ) {
return 'el_index ' . $db->buildLike( "$protocol", $db->anyString() );
* @return void
*/
public function showHiddenUsersAddBlockInfo( $showBlockInfo ) {
- $userCanViewHiddenUsers = $this->getUser()->isAllowed( 'hideuser' );
-
- if ( $showBlockInfo || !$userCanViewHiddenUsers ) {
- $this->addTables( 'ipblocks' );
- $this->addJoinConds( array(
- 'ipblocks' => array( 'LEFT JOIN', 'ipb_user=user_id' ),
- ) );
+ $this->addTables( 'ipblocks' );
+ $this->addJoinConds( array(
+ 'ipblocks' => array( 'LEFT JOIN', 'ipb_user=user_id' ),
+ ) );
- $this->addFields( 'ipb_deleted' );
+ $this->addFields( 'ipb_deleted' );
- if ( $showBlockInfo ) {
- $this->addFields( array( 'ipb_id', 'ipb_by', 'ipb_by_text', 'ipb_reason', 'ipb_expiry' ) );
- }
+ if ( $showBlockInfo ) {
+ $this->addFields( array( 'ipb_id', 'ipb_by', 'ipb_by_text', 'ipb_reason', 'ipb_expiry' ) );
+ }
- // Don't show hidden names
- if ( !$userCanViewHiddenUsers ) {
- $this->addWhere( 'ipb_deleted = 0 OR ipb_deleted IS NULL' );
- }
+ // Don't show hidden names
+ if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
+ $this->addWhere( 'ipb_deleted = 0 OR ipb_deleted IS NULL' );
}
}
array( 'invalidtitle', 'title' ),
array( 'invalidtitle', 'key' ),
) );
+
return $errors;
}
}
if ( $this->mGeneratorPageSet !== null ) {
return $this->mGeneratorPageSet;
}
+
return parent::getPageSet();
}