* @param User|null $user User object or null to use $wgUser
* @param string[] $tags Change tags to add to the log entry and page revision.
* (This doesn't check $user's permissions.)
+ * @param bool $createNullRevision Set to false to avoid creation of a null revision on file
+ * upload, see T193621
* @return Status On success, the value member contains the
* archive name, or an empty string if it was a new file.
*/
function upload( $src, $comment, $pageText, $flags = 0, $props = false,
- $timestamp = false, $user = null, $tags = []
+ $timestamp = false, $user = null, $tags = [],
+ $createNullRevision = true
) {
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
return $this->readOnlyFatalStatus();
$props,
$timestamp,
$user,
- $tags
+ $tags,
+ $createNullRevision
);
if ( !$uploadStatus->isOK() ) {
if ( $uploadStatus->hasMessage( 'filenotfound' ) ) {
* @param string|bool $timestamp
* @param null|User $user
* @param string[] $tags
+ * @param bool $createNullRevision Set to false to avoid creation of a null revision on file
+ * upload, see T193621
* @return Status
*/
function recordUpload2(
- $oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null, $tags = []
+ $oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null, $tags = [],
+ $createNullRevision = true
) {
global $wgCommentTableSchemaMigrationStage, $wgActorTableSchemaMigrationStage;
$formatter->setContext( RequestContext::newExtraneousContext( $descTitle ) );
$editSummary = $formatter->getPlainActionText();
- $nullRevision = Revision::newNullRevision(
+ $nullRevision = $createNullRevision === false ? null : Revision::newNullRevision(
$dbw,
$descId,
$editSummary,
*/
private $enableUploads;
+ /**
+ * @var bool
+ */
+ private $shouldCreateNullRevision = true;
+
/**
* @param bool $enableUploads
* @param LoggerInterface $logger
$this->logger = $logger;
}
+ /**
+ * Setting this to false will deactivate the creation of a null revision as part of the upload
+ * process logging in LocalFile::recordUpload2, see T193621
+ *
+ * @param bool $shouldCreateNullRevision
+ */
+ public function setNullRevisionCreation( $shouldCreateNullRevision ) {
+ $this->shouldCreateNullRevision = $shouldCreateNullRevision;
+ }
+
/**
* @return StatusValue
*/
$flags,
false,
$importableRevision->getTimestamp(),
- $user
+ $user,
+ [],
+ $this->shouldCreateNullRevision
);
}