summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2007-07-18 09:49:48 +0200
committerPierre Schmitz <pierre@archlinux.de>2007-07-18 09:49:48 +0200
commitfd12989ef8eab0fc9816decb8bcabccd1d213ee8 (patch)
tree68b12cc05704f2181a90d69b898f999309a8c036 /includes
parent1a1c15f5da352895fb32daab8550cb3dca8198ac (diff)
auf 1.10.1 aktualisiert
Diffstat (limited to 'includes')
-rw-r--r--includes/ChangesList.php21
-rw-r--r--includes/DatabasePostgres.php102
-rw-r--r--includes/DefaultSettings.php2
-rw-r--r--includes/Image.php10
-rw-r--r--includes/SearchPostgres.php9
5 files changed, 105 insertions, 39 deletions
diff --git a/includes/ChangesList.php b/includes/ChangesList.php
index bc141579..751e1226 100644
--- a/includes/ChangesList.php
+++ b/includes/ChangesList.php
@@ -497,18 +497,19 @@ class EnhancedChangesList extends ChangesList {
$r .= ') . . ';
- # Character difference
- $chardiff = $rcObj->getCharacterDifference( $block[ count( $block ) - 1 ]->mAttribs['rc_old_len'],
- $block[0]->mAttribs['rc_new_len'] );
- if( $chardiff == '' ) {
- $r .= ' (';
- } else {
- $r .= ' ' . $chardiff. ' . . (';
- }
-
+ if( $wgRCShowChangedSize ) {
+ # Character difference
+ $chardiff = $rcObj->getCharacterDifference( $block[ count( $block ) - 1 ]->mAttribs['rc_old_len'],
+ $block[0]->mAttribs['rc_new_len'] );
+ if( $chardiff == '' ) {
+ $r .= ' (';
+ } else {
+ $r .= ' ' . $chardiff. ' . . ';
+ }
+ }
# History
- $r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
+ $r .= '(' . $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
$this->message['history'], $curIdEq.'&action=history' );
$r .= ')';
}
diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php
index 7158e2d1..07b3339d 100644
--- a/includes/DatabasePostgres.php
+++ b/includes/DatabasePostgres.php
@@ -378,7 +378,10 @@ class DatabasePostgres extends Database {
"WHERE relname = 'pg_pltemplate' AND nspname='pg_catalog'";
$rows = $this->numRows($this->doQuery($SQL));
if ($rows >= 1) {
+ $olde = error_reporting(0);
+ error_reporting($olde - E_WARNING);
$result = $this->doQuery("CREATE LANGUAGE plpgsql");
+ error_reporting($olde);
if (!$result) {
print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>$wgDBname</tt></li>";
dieout("</ul>");
@@ -512,7 +515,7 @@ class DatabasePostgres extends Database {
# TODO:
# hashar : not sure if the following test really trigger if the object
- # fetching failled.
+ # fetching failed.
if( pg_last_error($this->mConn) ) {
throw new DBUnexpectedError($this, 'SQL error: ' . htmlspecialchars( pg_last_error($this->mConn) ) );
}
@@ -558,6 +561,9 @@ class DatabasePostgres extends Database {
}
function affectedRows() {
+ if( !isset( $this->mLastResult ) )
+ return 0;
+
return pg_affected_rows( $this->mLastResult );
}
@@ -619,33 +625,83 @@ class DatabasePostgres extends Database {
}
- function insert( $table, $a, $fname = 'Database::insert', $options = array() ) {
- # Postgres doesn't support options
- # We have a go at faking one of them
- # TODO: DELAYED, LOW_PRIORITY
+ /**
+ * INSERT wrapper, inserts an array into a table
+ *
+ * $args may be a single associative array, or an array of these with numeric keys,
+ * for multi-row insert (Postgres version 8.2 and above only).
+ *
+ * @param array $table String: Name of the table to insert to.
+ * @param array $args Array: Items to insert into the table.
+ * @param array $fname String: Name of the function, for profiling
+ * @param mixed $options String or Array. Valid options: IGNORE
+ *
+ * @return bool Success of insert operation. IGNORE always returns true.
+ */
+ function insert( $table, $args, $fname = 'DatabasePostgres::insert', $options = array() ) {
+ global $wgDBversion;
- if ( !is_array($options))
- $options = array($options);
+ $table = $this->tableName( $table );
+ if (! isset( $wgDBversion ) ) {
+ $this->getServerVersion();
+ $wgDBversion = $this->numeric_version;
+ }
- if ( in_array( 'IGNORE', $options ) )
- $oldIgnore = $this->ignoreErrors( true );
+ if ( !is_array( $options ) )
+ $options = array( $options );
- # IGNORE is performed using single-row inserts, ignoring errors in each
- # FIXME: need some way to distiguish between key collision and other types of error
- $oldIgnore = $this->ignoreErrors( true );
- if ( !is_array( reset( $a ) ) ) {
- $a = array( $a );
+ if ( isset( $args[0] ) && is_array( $args[0] ) ) {
+ $multi = true;
+ $keys = array_keys( $args[0] );
}
- foreach ( $a as $row ) {
- parent::insert( $table, $row, $fname, array() );
+ else {
+ $multi = false;
+ $keys = array_keys( $args );
}
- $this->ignoreErrors( $oldIgnore );
- $retVal = true;
- if ( in_array( 'IGNORE', $options ) )
- $this->ignoreErrors( $oldIgnore );
+ $ignore = in_array( 'IGNORE', $options ) ? 1 : 0;
+ if ( $ignore )
+ $olde = error_reporting( 0 );
+
+ $sql = "INSERT INTO $table (" . implode( ',', $keys ) . ') VALUES ';
+
+ if ( $multi ) {
+ if ( $wgDBversion >= 8.1 ) {
+ $first = true;
+ foreach ( $args as $row ) {
+ if ( $first ) {
+ $first = false;
+ } else {
+ $sql .= ',';
+ }
+ $sql .= '(' . $this->makeList( $row ) . ')';
+ }
+ $res = (bool)$this->query( $sql, $fname, $ignore );
+ }
+ else {
+ $res = true;
+ $origsql = $sql;
+ foreach ( $args as $row ) {
+ $tempsql = $origsql;
+ $tempsql .= '(' . $this->makeList( $row ) . ')';
+ $tempres = (bool)$this->query( $tempsql, $fname, $ignore );
+ if (! $tempres)
+ $res = false;
+ }
+ }
+ }
+ else {
+ $sql .= '(' . $this->makeList( $args ) . ')';
+ $res = (bool)$this->query( $sql, $fname, $ignore );
+ }
+
+ if ( $ignore ) {
+ $olde = error_reporting( $olde );
+ return true;
+ }
+
+ return $res;
- return $retVal;
}
function tableName( $name ) {
@@ -989,9 +1045,9 @@ END;
$this->doQuery("DROP TABLE $wgDBmwschema.$ctest");
}
$SQL = "CREATE TABLE $wgDBmwschema.$ctest(a int)";
- error_reporting( 0 );
+ $olde = error_reporting( 0 );
$res = $this->doQuery($SQL);
- error_reporting( E_ALL );
+ error_reporting( $olde );
if (!$res) {
print "<b>FAILED</b>. Make sure that the user \"$wgDBuser\" can write to the schema \"$wgDBmwschema\"</li>\n";
dieout("</ul>");
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 169d67c9..d9bd3760 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -31,7 +31,7 @@ require_once( 'includes/SiteConfiguration.php' );
$wgConf = new SiteConfiguration;
/** MediaWiki version number */
-$wgVersion = '1.10.0';
+$wgVersion = '1.10.1';
/** Name of the site. It must be changed in LocalSettings.php */
$wgSitename = 'MediaWiki';
diff --git a/includes/Image.php b/includes/Image.php
index 09c2286e..e085936c 100644
--- a/includes/Image.php
+++ b/includes/Image.php
@@ -929,17 +929,19 @@ class Image
$thumbPath = wfImageThumbDir( $this->name, $this->fromSharedDirectory ) . "/$thumbName";
$thumbUrl = $this->thumbUrlFromName( $thumbName );
- $this->migrateThumbFile( $thumbName );
- if ( file_exists( $thumbPath ) ) {
+ if ( !$wgGenerateThumbnailOnParse && !($flags & self::RENDER_NOW ) ) {
$thumb = $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
break;
}
-
- if ( !$wgGenerateThumbnailOnParse && !($flags & self::RENDER_NOW ) ) {
+
+ wfDebug( "Doing stat for $thumbPath\n" );
+ $this->migrateThumbFile( $thumbName );
+ if ( file_exists( $thumbPath ) ) {
$thumb = $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
break;
}
+
$thumb = $handler->doTransform( $this, $thumbPath, $thumbUrl, $params );
// Ignore errors if requested
diff --git a/includes/SearchPostgres.php b/includes/SearchPostgres.php
index 3a624ced..7c3580e7 100644
--- a/includes/SearchPostgres.php
+++ b/includes/SearchPostgres.php
@@ -115,6 +115,12 @@ class SearchPostgres extends SearchEngine {
* @private
*/
function searchQuery( $term, $fulltext, $colname ) {
+ global $wgDBversion;
+
+ if ( !isset( $wgDBversion ) ) {
+ $this->db->getServerVersion();
+ $wgDBversion = $this->db->numeric_version;
+ }
$searchstring = $this->parseQuery( $term );
@@ -140,8 +146,9 @@ class SearchPostgres extends SearchEngine {
}
}
+ $rankscore = $wgDBversion > 8.2 ? 5 : 1;
$query = "SELECT page_id, page_namespace, page_title, ".
- "rank($fulltext, to_tsquery('default',$searchstring),5) AS score ".
+ "rank($fulltext, to_tsquery('default',$searchstring), $rankscore) AS score ".
"FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " .
"AND r.rev_text_id = c.old_id AND $fulltext @@ to_tsquery('default',$searchstring)";
}