saper has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/172437

Change subject: More debug diagnostics for upload by URL
......................................................................

More debug diagnostics for upload by URL

Increased debug log verbosity to
troubleshoot file upload by URL issues

Bug: 73200
Change-Id: I530bd38b85911e0c153280b7d9a9da023f799b02
---
M includes/upload/UploadFromUrl.php
1 file changed, 17 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/37/172437/1

diff --git a/includes/upload/UploadFromUrl.php 
b/includes/upload/UploadFromUrl.php
index b605640..8038d56 100644
--- a/includes/upload/UploadFromUrl.php
+++ b/includes/upload/UploadFromUrl.php
@@ -231,12 +231,16 @@
         * @return int Number of bytes handled
         */
        public function saveTempFileChunk( $req, $buffer ) {
+               wfDebugLog('fileupload', 'Received chunk of ' . strlen($buffer) 
. ' bytes');
                $nbytes = fwrite( $this->mTmpHandle, $buffer );
 
                if ( $nbytes == strlen( $buffer ) ) {
                        $this->mFileSize += $nbytes;
                } else {
                        // Well... that's not good!
+                   wfDebugLog('fileupload', 'Short write ' . $this->nbytes . 
'/' . strlen($buffer) . 
+                               ' bytes, aborting with '  . $this->mFileSize . 
' uploaded so far'
+                       );
                        fclose( $this->mTmpHandle );
                        $this->mTmpHandle = false;
                }
@@ -262,6 +266,7 @@
                if ( !$this->mTmpHandle ) {
                        return Status::newFatal( 'tmp-create-error' );
                }
+               wfDebugLog('fileupload', 'Temporary file created "' . 
$this->mTempPath . '"');
 
                $this->mRemoveTempFile = true;
                $this->mFileSize = 0;
@@ -275,6 +280,10 @@
                if ( $wgCopyUploadTimeout && !isset( $options['timeout'] ) ) {
                        $options['timeout'] = $wgCopyUploadTimeout;
                }
+               wfDebugLog( 'fileupload',
+                       'Starting download from "' . $this->mUrl . '" ' .
+                       '<' . implode( ',', array_keys( array_filter( $options 
) ) ) . '>'
+               );
                $req = MWHttpRequest::factory( $this->mUrl, $options );
                $req->setCallback( array( $this, 'saveTempFileChunk' ) );
                $status = $req->execute();
@@ -288,8 +297,14 @@
                        return Status::newFatal( 'tmp-write-error' );
                }
 
-               if ( !$status->isOk() ) {
-                       return $status;
+               wfDebugLog( 'fileupload', $status );
+               if ( $status->isOk() ) {
+                       wfDebugLog( 'fileupload', 'Download by URL completed 
successfuly.' );
+               } else {
+                       wfDebugLog( 'fileupload',
+                               "Download by URL completed mit HTTP status " . 
$req->getStatus() .
+                               "\nServer returned: \n--------\n" . 
file_get_contents( $this->mTempPath ) .
+                               "\n--------");
                }
 
                return $status;

-- 
To view, visit https://gerrit.wikimedia.org/r/172437
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I530bd38b85911e0c153280b7d9a9da023f799b02
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: saper <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to