wiki.techinc.nl/includes/Revision/BadRevisionException.php
Tim Starling 540bddfb1f When content is marked bad, show an error, don't pretend it is empty
It misrepresents the users contribution to show empty text for a
revision when in fact the revision contained some text which we later
lost.

Also, errors from SqlBlobStore::fetchBlobs() did not stop a cache entry
from being written, so a subsequent cache hit would show the bad
revision as empty.

So, in Storage:
* Add BadBlobException, which is thrown by the Storage layer to
  indicate that a revision is marked as bad.
* Have SqlBlobStore::getBlobStore() return an error for bad blobs
  instead of an empty string.
* Duplicate the check for flags=error into SqlBlobStore::expandBlob().
  This avoids an unnecessary cache fetch, and avoids making
  decompressData() throw on error, which would be a b/c break.
* In SqlBlobStore::getBlob(), suppress the cache when there was an
  error.

In Revision:
* Add BadRevisionException, to wrap BadBlobException in the Revision
  layer.
* Return null from RevisionRecord::getContent() on a broader set of
  errors. Make it mostly non-throwing.
* Add RevisionRecord::getContentOrThrow() which returns a non-nullable
  Content.
* Note that SlotRecord::getContent() returns a non-nullable Content so
  now throws in more cases.

In the UI:
* In Article::view(), catch the exception and show an error message.
* In DifferenceEngine, catch the exception and make a suitable error
  message available via getRevisionLoadErrors(). In the diff page, show
  the error message in a box.
* In ApiComparePages and the legacy rvdiffto, show a warning.
* In RawAction, show a 404 by analogy with other error cases.
* In EditPage, there was already handling for $content=null with an
  appropriate error message (missing-revision-content). But having
  $this->textbox1 = null caused PHP 8.1 deprecation warnings, so I fixed
  that.
* In EditPage undo, there was already handling for null content, but I
  improved the error message: "does not exist or was deleted" seems more
  appropriate than "conflicting intermediate edits".

Change-Id: Idd1278d6d756ef37d64addb7b5f3be30747ea603
2022-12-05 22:03:45 +00:00

12 lines
330 B
PHP

<?php
namespace MediaWiki\Revision;
/**
* Exception raised when the text of a revision is permanently missing or
* corrupt. This wraps BadBlobException which is thrown by the Storage layer.
* To mark a revision as permanently missing, use findBadBlobs.php.
*/
class BadRevisionException extends RevisionAccessException {
}