Last modified: 2013-02-06 14:57:14 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 44610 - DplForum: Fixup raw SQL building
DplForum: Fixup raw SQL building
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
Other (Other open bugs)
unspecified
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: code_quality 14087
  Show dependency treegraph
 
Reported: 2013-02-03 01:06 UTC by Sam Reed (reedy)
Modified: 2013-02-06 14:57 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Sam Reed (reedy) 2013-02-03 01:06:05 UTC
The SQL query building is very scary

		// build the SQL query
		$dbr = wfGetDB( DB_SLAVE );
		$sPageTable = $dbr->tableName( 'page' );
		$sRevTable = $dbr->tableName( 'revision' );
		$categorylinks = $dbr->tableName( 'categorylinks' );
		$sSqlSelectFrom = "SELECT page_namespace, page_title,"
			. " r.rev_user_text, r.rev_timestamp";
		$arg = " FROM $sPageTable INNER JOIN $sRevTable"
			. " AS r ON page_latest = r.rev_id";

		if ( $bCountMode ) {
			$sSqlSelectFrom = "SELECT COUNT(*) AS num_rows FROM $sPageTable";
		} elseif ( ( $this->bAddAuthor || $this->bAddCreationDate ||
		( $sOrder == 'first_time' ) ) && ( ( !$this->restrictNamespace ) ||
		( $iNamespace >= 0 && !in_array( $iNamespace, $this->restrictNamespace ) ) ) ) {
			$sSqlSelectFrom .= ", o.rev_user_text AS first_user, o.rev_timestamp AS"
			. " first_time" . $arg . " INNER JOIN $sRevTable AS o"
			. " ON o.rev_id =( SELECT MIN(q.rev_id) FROM $sRevTable"
			. " AS q WHERE q.rev_page = page_id )";
		} else {
			if ( $sOrder == 'first_time' ) {
				$sOrder = 'page_id';
			}
			$sSqlSelectFrom .= $arg;
		}

		$sSqlWhere = ' WHERE 1=1';
		if ( $iNamespace >= 0 ) {
			$sSqlWhere = ' WHERE page_namespace=' . $iNamespace;
		}

		if ( $sPrefix !== '' ) {
			// Escape SQL special characters
			$sPrefix = strtr( $sPrefix, array( '\\' => '\\\\\\\\',
			' ' => '\\_', '_' => '\\_', '%' => '\\%', '\'' => '\\\'' ) );
			$sSqlWhere .= " AND page_title LIKE BINARY '" . $sPrefix . "%'";
		}

		switch( $this->get( 'redirects' ) ) {
			case 'only':
				$sSqlWhere .= ' AND page_is_redirect = 1';
			case 'include':
				break;
			case 'exclude':
			default:
				$sSqlWhere .= ' AND page_is_redirect = 0';
			break;
		}

		$n = 1;
		for ( $i = 0; $i < $cats; $i++ ) {
			$sSqlSelectFrom .= " INNER JOIN $categorylinks AS" .
			" c{$n} ON page_id = c{$n}.cl_from AND c{$n}.cl_to=" .
			$dbr->addQuotes( $aCategories[$i]->getDBkey() );
			$n++;
		}
		for ( $i = 0; $i < $nocats; $i++ ) {
			$sSqlSelectFrom .= " LEFT OUTER JOIN $categorylinks AS" .
			" c{$n} ON page_id = c{$n}.cl_from AND c{$n}.cl_to=" .
			$dbr->addQuotes( $aExcludeCategories[$i]->getDBkey() );
			$sSqlWhere .= " AND c{$n}.cl_to IS NULL";
			$n++;
		}

		if ( !$bCountMode ) {
			$sSqlWhere .= " ORDER BY $sOrder ";

			if ( $this->get( 'order' ) == 'ascending' ) {
				$sSqlWhere .= 'ASC';
			} else {
				$sSqlWhere .= 'DESC';
			}
		}
		$sSqlWhere .= " LIMIT $start, $count";
Comment 1 Timeshifter 2013-02-03 14:09:22 UTC
Wikia has a newer set of central forums that are also based on individual threads that can be watchlisted. I don't know if it is based on a fork of DplForum or not. It may have better software. 

The 2 sets of Wikia central forums:
*[[wikia:community:Admin Central:Forum]] - based on DplForum. 
*[[wikia:community:Special:Forum]] - newer forums. 

The newer forums may be based on "Forum" listed here:
*[[wikia:community:Special:Version]]

It lists its editors as "Hyun Lim, Kyle Florence, Saipetch Kongkatong and Tomasz Odrobny". 

The newer forums can be sorted by most recent reply, or by most replies. It is probably possible to adapt it to allow sorting by thread start date too.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links