- /**
- * Check whether the resulting filename is different from the desired one,
- * but ignore things like ucfirst() and spaces/underscore things
- */
- $comparableName = str_replace( ' ', '_', $this->mDesiredDestName );
+ $badFileName = $this->checkBadFileName( $filename, $this->mDesiredDestName );
+ if ( $badFileName !== null ) {
+ $warnings['badfilename'] = $badFileName;
+ }
+
+ $unwantedFileExtensionDetails = $this->checkUnwantedFileExtensions( $this->mFinalExtension );
+ if ( $unwantedFileExtensionDetails !== null ) {
+ $warnings['filetype-unwanted-type'] = $unwantedFileExtensionDetails;
+ }
+
+ $fileSizeWarnings = $this->checkFileSize( $this->mFileSize );
+ if ( $fileSizeWarnings ) {
+ $warnings = array_merge( $warnings, $fileSizeWarnings );
+ }
+
+ $localFileExistsWarnings = $this->checkLocalFileExists( $localFile, $hash );
+ if ( $localFileExistsWarnings ) {
+ $warnings = array_merge( $warnings, $localFileExistsWarnings );
+ }
+
+ if ( $this->checkLocalFileWasDeleted( $localFile ) ) {
+ $warnings['was-deleted'] = $filename;
+ }
+
+ $dupes = $this->checkAgainstExistingDupes( $hash );
+ if ( $dupes ) {
+ $warnings['duplicate'] = $dupes;
+ }
+
+ $archivedDupes = $this->checkAgainstArchiveDupes( $hash );
+ if ( $archivedDupes !== null ) {
+ $warnings['duplicate-archive'] = $archivedDupes;
+ }
+
+ return $warnings;
+ }
+
+ /**
+ * Check whether the resulting filename is different from the desired one,
+ * but ignore things like ucfirst() and spaces/underscore things
+ *
+ * @param string $filename
+ * @param string $desiredFileName
+ *
+ * @return string|null String that was determined to be bad or null if the filename is okay
+ */
+ private function checkBadFileName( $filename, $desiredFileName ) {
+ $comparableName = str_replace( ' ', '_', $desiredFileName );