From 8a4101d1cbc9e157d6d83b4992dfe4df7e7611ba Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 30 Mar 2009 20:04:34 +0000 Subject: [PATCH] Kill raw SQL in QueryPage::recache(). I can't find any code that actually calls recache(), though --- includes/QueryPage.php | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 1cef31ea56..b22231fc1a 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -206,7 +206,7 @@ class QueryPage { function recache( $limit, $ignoreErrors = true ) { $fname = get_class( $this ) . '::recache'; $dbw = wfGetDB( DB_MASTER ); - $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), 'QueryPage::recache', 'vslow' ) ); + $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), __METHOD__, 'vslow' ) ); if ( !$dbw || !$dbr ) { return false; } @@ -229,30 +229,23 @@ class QueryPage { if ( $res ) { $num = $dbr->numRows( $res ); # Fetch results - $insertSql = "INSERT INTO $querycache (qc_type,qc_namespace,qc_title,qc_value) VALUES "; - $first = true; + $vals = array(); while ( $res && $row = $dbr->fetchObject( $res ) ) { - if ( $first ) { - $first = false; - } else { - $insertSql .= ','; - } if ( isset( $row->value ) ) { $value = intval( $row->value ); // @bug 14414 } else { $value = 0; } - - $insertSql .= '(' . - $dbw->addQuotes( $row->type ) . ',' . - $dbw->addQuotes( $row->namespace ) . ',' . - $dbw->addQuotes( $row->title ) . ',' . - $dbw->addQuotes( $value ) . ')'; + + $vals[] = array('qc_type' => $row->type, + 'qc_namespace' => $row->namespace, + 'qc_title' => $row->title, + 'qc_value' => $value); } # Save results into the querycache table on the master - if ( !$first ) { - if ( !$dbw->query( $insertSql, $fname ) ) { + if ( count( $vals ) ) { + if ( !$dbw->insert( 'querycache', $vals, __METHOD__ ) { // Set result to false to indicate error $dbr->freeResult( $res ); $res = false; -- 2.20.1