Index: trunk/phase3/includes/Import.php |
— | — | @@ -192,6 +192,7 @@ |
193 | 193 | * Dummy for now... |
194 | 194 | */ |
195 | 195 | public function importUpload( $revision ) { |
| 196 | + $revision->importUpload(); |
196 | 197 | //$dbw = wfGetDB( DB_MASTER ); |
197 | 198 | //return $dbw->deadlockLoop( array( $revision, 'importUpload' ) ); |
198 | 199 | return false; |
— | — | @@ -600,13 +601,15 @@ |
601 | 602 | return $this->processUpload( $pageInfo, $uploadInfo ); |
602 | 603 | } |
603 | 604 | |
| 605 | + |
604 | 606 | private function processUpload( $pageInfo, $uploadInfo ) { |
605 | 607 | $revision = new WikiRevision; |
| 608 | + $text = isset( $uploadInfo['text'] ) ? $uploadInfo['text'] : ''; |
606 | 609 | |
607 | 610 | $revision->setTitle( $pageInfo['_title'] ); |
608 | | - $revision->setID( $uploadInfo['id'] ); |
| 611 | + $revision->setID( $pageInfo['id'] ); |
609 | 612 | $revision->setTimestamp( $uploadInfo['timestamp'] ); |
610 | | - $revision->setText( $uploadInfo['text'] ); |
| 613 | + $revision->setText( $text ); |
611 | 614 | $revision->setFilename( $uploadInfo['filename'] ); |
612 | 615 | $revision->setSrc( $uploadInfo['src'] ); |
613 | 616 | $revision->setSize( intval( $uploadInfo['size'] ) ); |
— | — | @@ -619,7 +622,7 @@ |
620 | 623 | $revision->setUserName( $uploadInfo['contributor']['username'] ); |
621 | 624 | } |
622 | 625 | |
623 | | - return $this->uploadCallback( $revision ); |
| 626 | + return call_user_func( $this->mUploadCallback, $revision ); |
624 | 627 | } |
625 | 628 | |
626 | 629 | private function handleContributor() { |
— | — | @@ -1054,8 +1057,7 @@ |
1055 | 1058 | $resultDetails = array( 'internal' => $status->getWikiText() ); |
1056 | 1059 | */ |
1057 | 1060 | |
1058 | | - // @todo Fixme: upload() uses $wgUser, which is wrong here |
1059 | | - // it may also create a page without our desire, also wrong potentially. |
| 1061 | + // @todo Fixme: it may create a page without our desire, also wrong potentially. |
1060 | 1062 | // and, it will record a *current* upload, but we might want an archive version here |
1061 | 1063 | |
1062 | 1064 | $file = wfLocalFile( $this->getTitle() ); |
— | — | @@ -1070,12 +1072,15 @@ |
1071 | 1073 | return false; |
1072 | 1074 | } |
1073 | 1075 | |
| 1076 | + $user = User::newFromName( $this->user_text ); |
| 1077 | + |
1074 | 1078 | $status = $file->upload( $source, |
1075 | 1079 | $this->getComment(), |
1076 | 1080 | $this->getComment(), // Initial page, if none present... |
1077 | 1081 | File::DELETE_SOURCE, |
1078 | 1082 | false, // props... |
1079 | | - $this->getTimestamp() ); |
| 1083 | + $this->getTimestamp(), |
| 1084 | + is_object( $user ) ? ( $user->isLoggedIn() ? $user : null ) : null ); |
1080 | 1085 | |
1081 | 1086 | if( $status->isGood() ) { |
1082 | 1087 | // yay? |