+ /**
+ * Return type of change if one exists for the given edit.
+ *
+ * @since 1.31
+ *
+ * @param Content|null $oldContent The previous text of the page.
+ * @param Content|null $newContent The submitted text of the page.
+ * @param int $flags Bit mask: a bit mask of flags submitted for the edit.
+ *
+ * @return string|null String key representing type of change, or null.
+ */
+ private function getChangeType(
+ Content $oldContent = null,
+ Content $newContent = null,
+ $flags = 0
+ ) {
+ $oldTarget = $oldContent !== null ? $oldContent->getRedirectTarget() : null;
+ $newTarget = $newContent !== null ? $newContent->getRedirectTarget() : null;
+
+ // We check for the type of change in the given edit, and return string key accordingly
+
+ // Blanking of a page
+ if ( $oldContent && $oldContent->getSize() > 0 &&
+ $newContent && $newContent->getSize() === 0
+ ) {
+ return 'blank';
+ }
+
+ // Redirects
+ if ( $newTarget ) {
+ if ( !$oldTarget ) {
+ // New redirect page (by creating new page or by changing content page)
+ return 'new-redirect';
+ } elseif ( !$newTarget->equals( $oldTarget ) ||
+ $oldTarget->getFragment() !== $newTarget->getFragment()
+ ) {
+ // Redirect target changed
+ return 'changed-redirect-target';
+ }
+ } elseif ( $oldTarget ) {
+ // Changing an existing redirect into a non-redirect
+ return 'removed-redirect';
+ }
+
+ // New page created
+ if ( $flags & EDIT_NEW && $newContent && $newContent->getSize() > 0 ) {
+ return 'newpage';
+ }
+
+ // New blank page
+ if ( $flags & EDIT_NEW && $newContent && $newContent->getSize() === 0 ) {
+ return 'newblank';
+ }
+
+ // Removing more than 90% of the page
+ if ( $oldContent && $newContent && $oldContent->getSize() > 10 * $newContent->getSize() ) {
+ return 'replace';
+ }
+
+ // Content model changed
+ if ( $oldContent && $newContent && $oldContent->getModel() !== $newContent->getModel() ) {
+ return 'contentmodelchange';
+ }
+
+ return null;
+ }
+