http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89677
Revision: 89677
Author: catrope
Date: 2011-06-07 19:14:43 +0000 (Tue, 07 Jun 2011)
Log Message:
-----------
1.17: MFT r88492, r88870, r88871, r89003, r89108, r89114, r89115, r89129,
r89532, r89653
Modified Paths:
--------------
branches/REL1_17/phase3/includes/HttpFunctions.php
branches/REL1_17/phase3/includes/LogEventsList.php
branches/REL1_17/phase3/includes/installer/CliInstaller.php
branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php
branches/REL1_17/phase3/includes/installer/Installer.php
branches/REL1_17/phase3/includes/media/SVGMetadataExtractor.php
branches/REL1_17/phase3/includes/specials/SpecialUserlogin.php
branches/REL1_17/phase3/includes/upload/UploadFromUrl.php
Property Changed:
----------------
branches/REL1_17/phase3/includes/installer/CliInstaller.php
branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php
branches/REL1_17/phase3/includes/installer/Installer.php
Modified: branches/REL1_17/phase3/includes/HttpFunctions.php
===================================================================
--- branches/REL1_17/phase3/includes/HttpFunctions.php 2011-06-07 19:09:07 UTC
(rev 89676)
+++ branches/REL1_17/phase3/includes/HttpFunctions.php 2011-06-07 19:14:43 UTC
(rev 89677)
@@ -307,11 +307,26 @@
}
/**
- * Set the callback
+ * Set a read callback to accept data read from the HTTP request.
+ * By default, data is appended to an internal buffer which can be
+ * retrieved through $req->getContent().
*
+ * To handle data as it comes in -- especially for large files that
+ * would not fit in memory -- you can instead set your own callback,
+ * in the form function($resource, $buffer) where the first parameter
+ * is the low-level resource being read (implementation specific),
+ * and the second parameter is the data buffer.
+ *
+ * You MUST return the number of bytes handled in the buffer; if fewer
+ * bytes are reported handled than were passed to you, the HTTP fetch
+ * will be aborted.
+ *
* @param $callback Callback
*/
public function setCallback( $callback ) {
+ if ( !is_callable( $callback ) ) {
+ throw new MWException( 'Invalid MwHttpRequest callback'
);
+ }
$this->callback = $callback;
}
Modified: branches/REL1_17/phase3/includes/LogEventsList.php
===================================================================
--- branches/REL1_17/phase3/includes/LogEventsList.php 2011-06-07 19:09:07 UTC
(rev 89676)
+++ branches/REL1_17/phase3/includes/LogEventsList.php 2011-06-07 19:14:43 UTC
(rev 89677)
@@ -482,8 +482,7 @@
# Fall back to a blue contributions link
$revert = $this->skin->userToolLinks( 1,
$title->getDBkey() );
}
- $ts = wfTimestamp( TS_UNIX, $row->log_timestamp );
- if( $ts < '20080129000000' ) {
+ if( wfTimestamp( TS_MW, $row->log_timestamp ) <
'20080129000000' ) {
# Suppress $comment from old entries (before
2008-01-29),
# not needed and can contain incorrect links
$comment = '';
Modified: branches/REL1_17/phase3/includes/installer/CliInstaller.php
===================================================================
--- branches/REL1_17/phase3/includes/installer/CliInstaller.php 2011-06-07
19:09:07 UTC (rev 89676)
+++ branches/REL1_17/phase3/includes/installer/CliInstaller.php 2011-06-07
19:14:43 UTC (rev 89677)
@@ -88,7 +88,7 @@
* Main entry point.
*/
public function execute() {
- $vars = $this->getExistingLocalSettings();
+ $vars = Installer::getExistingLocalSettings();
if( $vars ) {
$this->showStatusMessage(
Status::newFatal(
"config-localsettings-cli-upgrade" )
Property changes on: branches/REL1_17/phase3/includes/installer/CliInstaller.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes/installer/CliInstaller.php:51646
/branches/new-installer/phase3/includes/installer/CliInstaller.php:43664-66004
/branches/sqlite/includes/installer/CliInstaller.php:58211-58321
/branches/wmf-deployment/includes/installer/CliInstaller.php:53381
/trunk/phase3/includes/installer/CliInstaller.php:82845,82847-82848,84431,84464,84543,84553,84573-84574,84577,84579,84729,84756,84765,84820,84846,84875,84881-84882,84905,84970,84976,84985,85032,85140,85143,85152,85178,85194,85199,87027,88658
+ /branches/REL1_15/phase3/includes/installer/CliInstaller.php:51646
/branches/new-installer/phase3/includes/installer/CliInstaller.php:43664-66004
/branches/sqlite/includes/installer/CliInstaller.php:58211-58321
/branches/wmf-deployment/includes/installer/CliInstaller.php:53381
/trunk/phase3/includes/installer/CliInstaller.php:82845,82847-82848,84431,84464,84543,84553,84573-84574,84577,84579,84729,84756,84765,84820,84846,84875,84881-84882,84905,84970,84976,84985,85032,85140,85143,85152,85178,85194,85199,87027,88492,88658,88870-88871,89003,89108,89114-89115,89129,89532,89653
Modified: branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php
===================================================================
--- branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php
2011-06-07 19:09:07 UTC (rev 89676)
+++ branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php
2011-06-07 19:14:43 UTC (rev 89677)
@@ -186,11 +186,6 @@
$updater = DatabaseUpdater::newForDB( $this->db );
$extensionUpdates = $updater->getNewExtensions();
- // No extensions need tables (or haven't updated to new
installer support)
- if( !count( $extensionUpdates ) ) {
- return $status;
- }
-
$ourExtensions = array_map( 'strtolower', $this->getVar(
'_Extensions' ) );
foreach( $ourExtensions as $ext ) {
Property changes on:
branches/REL1_17/phase3/includes/installer/DatabaseInstaller.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes/installer/InstallerDBType.php:51646
/branches/new-installer/phase3/includes/installer/InstallerDBType.php:43664-66004
/branches/sqlite/includes/installer/InstallerDBType.php:58211-58321
/branches/wmf-deployment/includes/installer/InstallerDBType.php:53381
/trunk/phase3/includes/installer/DatabaseInstaller.php:78078,78285,79246,79358,79480,79497,79693,79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80163,80222,80238,80322,80492,84875,84881-84882,84970,84976,85021,85066,88658
+ /branches/REL1_15/phase3/includes/installer/InstallerDBType.php:51646
/branches/new-installer/phase3/includes/installer/InstallerDBType.php:43664-66004
/branches/sqlite/includes/installer/InstallerDBType.php:58211-58321
/branches/wmf-deployment/includes/installer/InstallerDBType.php:53381
/trunk/phase3/includes/installer/DatabaseInstaller.php:78078,78285,79246,79358,79480,79497,79693,79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80163,80222,80238,80322,80492,84875,84881-84882,84970,84976,85021,85066,88492,88658,88870-88871,89003,89108,89114-89115,89129,89532,89653
Modified: branches/REL1_17/phase3/includes/installer/Installer.php
===================================================================
--- branches/REL1_17/phase3/includes/installer/Installer.php 2011-06-07
19:09:07 UTC (rev 89676)
+++ branches/REL1_17/phase3/includes/installer/Installer.php 2011-06-07
19:14:43 UTC (rev 89677)
@@ -1143,7 +1143,13 @@
break;
}
- $text = Http::get( $url . $file, array(
'timeout' => 3 ) );
+ try {
+ $text = Http::get( $url . $file, array(
'timeout' => 3 ) );
+ }
+ catch( MWException $e ) {
+ // Http::get throws with
allow_url_fopen = false and no curl extension.
+ $text = null;
+ }
unlink( $dir . $file );
if ( $text == 'exec' ) {
Property changes on: branches/REL1_17/phase3/includes/installer/Installer.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes/installer/Installer.php:51646
/branches/new-installer/phase3/includes/installer/Installer.php:43664-66004
/branches/sqlite/includes/installer/Installer.php:58211-58321
/branches/wmf-deployment/includes/installer/Installer.php:53381
/trunk/phase3/includes/installer/Installer.php:81731,82038-82039,82247,82845,82847-82848,84431,84464,84543,84553,84573-84574,84577,84579,84729,84755,84765,84820,84846,84875,84881-84882,84905,84970,84976,84985,85032,85140,85143,85152,85178,85194,85199,85377,85547,85555,85583,85803,85881,86065,86100,86121,86130,86142,86146,86182,86210,86257,86385,86394,87027,87203,87222,87265,87494,87497,87711,87840,88076,88658,89615
+ /branches/REL1_15/phase3/includes/installer/Installer.php:51646
/branches/new-installer/phase3/includes/installer/Installer.php:43664-66004
/branches/sqlite/includes/installer/Installer.php:58211-58321
/branches/wmf-deployment/includes/installer/Installer.php:53381
/trunk/phase3/includes/installer/Installer.php:81731,82038-82039,82247,82845,82847-82848,84431,84464,84543,84553,84573-84574,84577,84579,84729,84755,84765,84820,84846,84875,84881-84882,84905,84970,84976,84985,85032,85140,85143,85152,85178,85194,85199,85377,85547,85555,85583,85803,85881,86065,86100,86121,86130,86142,86146,86182,86210,86257,86385,86394,87027,87203,87222,87265,87494,87497,87711,87840,88076,88492,88658,88870-88871,89003,89108,89114-89115,89129,89532,89615,89653
Modified: branches/REL1_17/phase3/includes/media/SVGMetadataExtractor.php
===================================================================
--- branches/REL1_17/phase3/includes/media/SVGMetadataExtractor.php
2011-06-07 19:09:07 UTC (rev 89676)
+++ branches/REL1_17/phase3/includes/media/SVGMetadataExtractor.php
2011-06-07 19:14:43 UTC (rev 89677)
@@ -35,6 +35,7 @@
class SVGReader {
const DEFAULT_WIDTH = 512;
const DEFAULT_HEIGHT = 512;
+ const NS_SVG = 'http://www.w3.org/2000/svg';
private $reader = null;
private $mDebug = false;
@@ -101,9 +102,9 @@
$keepReading = $this->reader->read();
}
- if ( !$this->qualifiedNameEquals( $this->reader->name, 'svg',
'svg' ) ) {
+ if ( $this->reader->localName != 'svg' ||
$this->reader->namespaceURI != self::NS_SVG ) {
throw new MWException( "Expected <svg> tag, got ".
- $this->reader->name );
+ $this->reader->localName . " in NS " .
$this->reader->namespaceURI );
}
$this->debug( "<svg> tag is correct." );
$this->handleSVGAttribs();
@@ -111,18 +112,19 @@
$exitDepth = $this->reader->depth;
$keepReading = $this->reader->read();
while ( $keepReading ) {
- $tag = $this->reader->name;
+ $tag = $this->reader->localName;
$type = $this->reader->nodeType;
+ $isSVG = ($this->reader->namespaceURI == self::NS_SVG);
$this->debug( "$tag" );
- if ( $this->qualifiedNameEquals( $tag, 'svg', 'svg' )
&& $type == XmlReader::END_ELEMENT && $this->reader->depth <= $exitDepth ) {
+ if ( $isSVG && $tag == 'svg' && $type ==
XmlReader::END_ELEMENT && $this->reader->depth <= $exitDepth ) {
break;
- } elseif ( $this->qualifiedNameEquals( $tag, 'svg',
'title' ) ) {
+ } elseif ( $isSVG && $tag == 'title' ) {
$this->readField( $tag, 'title' );
- } elseif ( $this->qualifiedNameEquals( $tag, 'svg',
'desc' ) ) {
+ } elseif ( $isSVG && $tag == 'desc' ) {
$this->readField( $tag, 'description' );
- } elseif ( $this->qualifiedNameEquals( $tag, 'svg',
'metadata' ) && $type == XmlReader::ELEMENT ) {
+ } elseif ( $isSVG && $tag == 'metadata' && $type ==
XmlReader::ELEMENT ) {
$this->readXml( $tag, 'metadata' );
} elseif ( $tag !== '#text' ) {
$this->debug( "Unhandled top-level XML tag
$tag" );
@@ -153,7 +155,7 @@
}
$keepReading = $this->reader->read();
while( $keepReading ) {
- if( $this->reader->name == $name &&
$this->reader->nodeType == XmlReader::END_ELEMENT ) {
+ if( $this->reader->localName == $name &&
$this->namespaceURI == self::NS_SVG && $this->reader->nodeType ==
XmlReader::END_ELEMENT ) {
break;
} elseif( $this->reader->nodeType == XmlReader::TEXT ){
$this->metadata[$metafield] = trim(
$this->reader->value );
@@ -173,7 +175,7 @@
return;
}
// TODO: find and store type of xml snippet.
metadata['metadataType'] = "rdf"
- $this->metadata[$metafield] = $this->reader->readInnerXML();
+ $this->metadata[$metafield] = trim(
$this->reader->readInnerXML() );
$this->reader->next();
}
@@ -190,21 +192,16 @@
$exitDepth = $this->reader->depth;
$keepReading = $this->reader->read();
while( $keepReading ) {
- if( $this->reader->name == $name &&
$this->reader->depth <= $exitDepth
+ if( $this->reader->localName == $name &&
$this->reader->depth <= $exitDepth
&& $this->reader->nodeType ==
XmlReader::END_ELEMENT ) {
break;
- } elseif ( $this->reader->nodeType ==
XmlReader::ELEMENT ) {
- switch( $this->reader->name ) {
+ } elseif ( $this->reader->namespaceURI == self::NS_SVG
&& $this->reader->nodeType == XmlReader::ELEMENT ) {
+ switch( $this->reader->localName ) {
case 'animate':
- case 'svg:animate':
case 'set':
- case 'svg:set':
case 'animateMotion':
- case 'svg:animateMotion':
case 'animateColor':
- case 'svg:animateColor':
case 'animateTransform':
- case 'svg:animateTransform':
$this->debug( "HOUSTON WE HAVE
ANIMATION" );
$this->metadata['animated'] =
true;
break;
@@ -313,22 +310,4 @@
return floatval( $length );
}
}
-
- /**
- * XML namespace check
- *
- * Check if a read node name matches the expected nodeName
- * @param $qualifiedName as read by XMLReader
- * @param $prefix the namespace prefix that you expect for this
element, defaults to svg namespace
- * @param $localName the localName part of the element that you want to
match
- *
- * @return boolean
- */
- private function qualifiedNameEquals( $qualifiedName, $prefix="svg",
$localName ) {
- if( ($qualifiedName == $localName && $prefix == "svg" ) ||
- $qualifiedName == ($prefix . ":" . $localName) ) {
- return true;
- }
- return false;
- }
}
Modified: branches/REL1_17/phase3/includes/specials/SpecialUserlogin.php
===================================================================
--- branches/REL1_17/phase3/includes/specials/SpecialUserlogin.php
2011-06-07 19:09:07 UTC (rev 89676)
+++ branches/REL1_17/phase3/includes/specials/SpecialUserlogin.php
2011-06-07 19:14:43 UTC (rev 89677)
@@ -148,7 +148,7 @@
global $wgOut;
if ( $this->mEmail == '' ) {
- $this->mainLoginForm( wfMsgExt( 'noemailcreate', array(
'parsemag', 'escape' ), $this->mName ) );
+ $this->mainLoginForm( wfMsgExt( 'noemailcreate', array(
'parsemag', 'escape' ) ) );
return;
}
Modified: branches/REL1_17/phase3/includes/upload/UploadFromUrl.php
===================================================================
--- branches/REL1_17/phase3/includes/upload/UploadFromUrl.php 2011-06-07
19:09:07 UTC (rev 89676)
+++ branches/REL1_17/phase3/includes/upload/UploadFromUrl.php 2011-06-07
19:14:43 UTC (rev 89677)
@@ -97,41 +97,62 @@
protected function makeTemporaryFile() {
return tempnam( wfTempDir(), 'URL' );
}
+
/**
- * Save the result of a HTTP request to the temporary file
+ * Callback: save a chunk of the result of a HTTP request to the
temporary file
*
- * @param $req MWHttpRequest
- * @return Status
+ * @param $req mixed
+ * @param $buffer string
+ * @return int number of bytes handled
*/
- private function saveTempFile( $req ) {
- if ( $this->mTempPath === false ) {
- return Status::newFatal( 'tmp-create-error' );
+ public function saveTempFileChunk( $req, $buffer ) {
+ $nbytes = fwrite( $this->mTmpHandle, $buffer );
+
+ if ( $nbytes == strlen( $buffer ) ) {
+ $this->mFileSize += $nbytes;
+ } else {
+ // Well... that's not good!
+ fclose( $this->mTmpHandle );
+ $this->mTmpHandle = false;
}
- if ( file_put_contents( $this->mTempPath, $req->getContent() )
=== false ) {
- return Status::newFatal( 'tmp-write-error' );
- }
- $this->mFileSize = filesize( $this->mTempPath );
+ return $nbytes;
+ }
- return Status::newGood();
- }
/**
* Download the file, save it to the temporary file and update the file
* size and set $mRemoveTempFile to true.
*/
protected function reallyFetchFile() {
+ if ( $this->mTempPath === false ) {
+ return Status::newFatal( 'tmp-create-error' );
+ }
+
+ // Note the temporary file should already be created by
makeTemporaryFile()
+ $this->mTmpHandle = fopen( $this->mTempPath, 'wb' );
+ if ( !$this->mTmpHandle ) {
+ return Status::newFatal( 'tmp-create-error' );
+ }
+
+ $this->mRemoveTempFile = true;
+ $this->mFileSize = 0;
+
$req = MWHttpRequest::factory( $this->mUrl );
+ $req->setCallback( array( $this, 'saveTempFileChunk' ) );
$status = $req->execute();
- if ( !$status->isOk() ) {
- return $status;
+ if ( $this->mTmpHandle ) {
+ // File got written ok...
+ fclose( $this->mTmpHandle );
+ $this->mTmpHandle = null;
+ } else {
+ // We encountered a write error during the download...
+ return Status::newFatal( 'tmp-write-error' );
}
- $status = $this->saveTempFile( $req );
- if ( !$status->isGood() ) {
+ if ( !$status->isOk() ) {
return $status;
}
- $this->mRemoveTempFile = true;
return $status;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs