throw new MWException( "Invalid or virtual namespace $ns given." );
}
+ $page = null;
+ if ( !Hooks::run( 'WikiPageFactory', [ $title, &$page ] ) ) {
+ return $page;
+ }
+
switch ( $ns ) {
case NS_FILE:
$page = new WikiFilePage( $title );
* @deprecated since 1.21, getContent() should be used instead.
*/
public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
- ContentHandler::deprecated( __METHOD__, '1.21' );
+ wfDeprecated( __METHOD__, '1.21' );
$this->loadLastEdit();
if ( $this->mLastRevision ) {
$flags & EDIT_MINOR, null, null, &$flags, &$hookStatus ];
// Check if the hook rejected the attempted save
if ( !Hooks::run( 'PageContentSave', $hook_args )
- || !ContentHandler::runLegacyHooks( 'ArticleSave', $hook_args )
+ || !ContentHandler::runLegacyHooks( 'ArticleSave', $hook_args, '1.21' )
) {
if ( $hookStatus->isOK() ) {
// Hook returned false but didn't call fatal(); use generic message
// Trigger post-create hook
$params = [ &$this, &$user, $content, $summary,
$flags & EDIT_MINOR, null, null, &$flags, $revision ];
- ContentHandler::runLegacyHooks( 'ArticleInsertComplete', $params );
+ ContentHandler::runLegacyHooks( 'ArticleInsertComplete', $params, '1.21' );
Hooks::run( 'PageContentInsertComplete', $params );
// Trigger post-save hook
$params = array_merge( $params, [ &$status, $meta['baseRevId'] ] );
- ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params );
+ ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params, '1.21' );
Hooks::run( 'PageContentSaveComplete', $params );
}
* @return object
*/
public function prepareTextForEdit( $text, $revid = null, User $user = null ) {
- ContentHandler::deprecated( __METHOD__, '1.21' );
+ wfDeprecated( __METHOD__, '1.21' );
$content = ContentHandler::makeContent( $text, $this->getTitle() );
return $this->prepareContentForEdit( $content, $revid, $user );
}
} elseif ( $options['changed'] ) { // bug 50785
self::onArticleEdit( $this->mTitle, $revision );
}
- }
-
- /**
- * Edit an article without doing all that other stuff
- * The article must already exist; link tables etc
- * are not updated, caches are not flushed.
- *
- * @param Content $content Content submitted
- * @param User $user The relevant user
- * @param string $comment Comment submitted
- * @param bool $minor Whereas it's a minor modification
- * @param string $serialFormat Format for storing the content in the database
- */
- public function doQuickEditContent(
- Content $content, User $user, $comment = '', $minor = false, $serialFormat = null
- ) {
-
- $serialized = $content->serialize( $serialFormat );
-
- $dbw = wfGetDB( DB_MASTER );
- $revision = new Revision( [
- 'title' => $this->getTitle(), // for determining the default content model
- 'page' => $this->getId(),
- 'user_text' => $user->getName(),
- 'user' => $user->getId(),
- 'text' => $serialized,
- 'length' => $content->getSize(),
- 'comment' => $comment,
- 'minor_edit' => $minor ? 1 : 0,
- ] ); // XXX: set the content object?
- $revision->insertOn( $dbw );
- $this->updateRevisionOn( $dbw, $revision );
-
- Hooks::run( 'NewRevisionFromEditComplete', [ $this, $revision, false, $user ] );
+ ResourceLoaderWikiModule::invalidateModuleCache(
+ $this->mTitle, $options['oldrevision'], $revision, wfWikiID()
+ );
}
/**
// unless they actually try to catch exceptions (which is rare).
// we need to remember the old content so we can use it to generate all deletion updates.
+ $revision = $this->getRevision();
try {
$content = $this->getContent( Revision::RAW );
} catch ( Exception $ex ) {
$content = null;
}
+ $fields = Revision::selectFields();
+ $bitfield = false;
+
// Bitfields to further suppress the content
if ( $suppress ) {
- $bitfield = 0;
- // This should be 15...
- $bitfield |= Revision::DELETED_TEXT;
- $bitfield |= Revision::DELETED_COMMENT;
- $bitfield |= Revision::DELETED_USER;
- $bitfield |= Revision::DELETED_RESTRICTED;
- $deletionFields = [ $dbw->addQuotes( $bitfield ) . ' AS deleted' ];
- } else {
- $deletionFields = [ 'rev_deleted AS deleted' ];
+ $bitfield = Revision::SUPPRESSED_ALL;
+ $fields = array_diff( $fields, [ 'rev_deleted' ] );
}
// For now, shunt the revision data into the archive table.
// the rev_deleted field, which is reserved for this purpose.
// Get all of the page revisions
- $fields = array_diff( Revision::selectFields(), [ 'rev_deleted' ] );
$res = $dbw->select(
'revision',
- array_merge( $fields, $deletionFields ),
+ $fields,
[ 'rev_page' => $id ],
__METHOD__,
'FOR UPDATE'
'ar_flags' => '',
'ar_len' => $row->rev_len,
'ar_page_id' => $id,
- 'ar_deleted' => $row->deleted,
+ 'ar_deleted' => $suppress ? $bitfield : $row->rev_deleted,
'ar_sha1' => $row->rev_sha1,
];
if ( $wgContentHandlerUseDB ) {
$dbw->endAtomic( __METHOD__ );
- $this->doDeleteUpdates( $id, $content );
+ $this->doDeleteUpdates( $id, $content, $revision );
Hooks::run( 'ArticleDeleteComplete', [
&$wikiPageBeforeDelete,
* Do some database updates after deletion
*
* @param int $id The page_id value of the page being deleted
- * @param Content $content Optional page content to be used when determining
+ * @param Content|null $content Optional page content to be used when determining
* the required updates. This may be needed because $this->getContent()
* may already return null when the page proper was deleted.
+ * @param Revision|null $revision The latest page revision
*/
- public function doDeleteUpdates( $id, Content $content = null ) {
+ public function doDeleteUpdates( $id, Content $content = null, Revision $revision = null ) {
try {
$countable = $this->isCountable();
} catch ( Exception $ex ) {
// Clear caches
WikiPage::onArticleDelete( $this->mTitle );
+ ResourceLoaderWikiModule::invalidateModuleCache(
+ $this->mTitle, $revision, null, wfWikiID()
+ );
// Reset this object and the Title object
$this->loadFromRow( false, self::READ_LATEST );