if ( $source == '' ) {
// Ye olde empty rows. Just kill them.
$this->killRow( $source );
+
return $this->progress( 1 );
}
return $this->progress( 0 );
}
$this->pokeFile( $source, $safe );
+
return $this->progress( 1 );
}
$munged = $title->getDBkey();
$this->output( "page $source ($munged) doesn't match self.\n" );
$this->pokeFile( $source, $munged );
+
return $this->progress( 1 );
}
}
/**
- * @param $name string
+ * @param string $name
*/
private function killRow( $name ) {
if ( $this->dryrun ) {
if ( !isset( $this->repo ) ) {
$this->repo = RepoGroup::singleton()->getLocalRepo();
}
+
return $this->repo->getRootDirectory() . '/' . $this->repo->getHashPath( $name ) . $name;
}
}
private function pageExists( $name, $db ) {
- return $db->selectField( 'page', '1', array( 'page_namespace' => NS_FILE, 'page_title' => $name ), __METHOD__ );
+ return $db->selectField(
+ 'page',
+ '1',
+ array( 'page_namespace' => NS_FILE, 'page_title' => $name ),
+ __METHOD__
+ );
}
private function pokeFile( $orig, $new ) {
if ( !file_exists( $path ) ) {
$this->output( "missing file: $path\n" );
$this->killRow( $orig );
+
return;
}
$version = 0;
$final = $new;
$conflict = ( $this->imageExists( $final, $db ) ||
- ( $this->pageExists( $orig, $db ) && $this->pageExists( $final, $db ) ) );
+ ( $this->pageExists( $orig, $db ) && $this->pageExists( $final, $db ) ) );
while ( $conflict ) {
$this->output( "Rename conflicts with '$final'...\n" );
if ( !wfMkdirParents( $dir, null, __METHOD__ ) ) {
$this->output( "RENAME FAILED, COULD NOT CREATE $dir" );
$db->rollback( __METHOD__ );
+
return;
}
}
$test = Title::makeTitleSafe( NS_FILE, $x );
if ( is_null( $test ) || $test->getDBkey() !== $x ) {
$this->error( "Unable to generate safe title from '$name', got '$x'" );
+
return false;
}