'WikiPageDeletionUpdates': manipulate the list of DataUpdates to be applied when
a page is deleted. Called in WikiPage::getDeletionUpdates().
Note that updates specific to a content model should be provided by the
- respective ContentHandler's getDeletionUpdates() method.
+ respective Content's getDeletionUpdates() method.
$page: the WikiPage
&$updates: the array of DataUpdate objects. Hook function may want to add to it.
*/
public function prepareSave( WikiPage $page, $flags, $baseRevId, User $user );
+ /**
+ * Returns a list of updates to perform when this content is deleted.
+ * The necessary updates may be taken from the Content object, or depend on
+ * the current state of the database.
+ *
+ * @since WD.1
+ *
+ * @param $title \Title the title of the deleted page
+ * @param $parserOutput null|\ParserOutput optional parser output object
+ * for efficient access to meta-information about the content object.
+ * Provide if you have one handy.
+ *
+ * @return array A list of DataUpdate instances that will clean up the
+ * database after deletion.
+ */
+ public function getDeletionUpdates( Title $title,
+ ParserOutput $parserOutput = null );
+
# TODO: handle ImagePage and CategoryPage
# TODO: make sure we cover lucene search / wikisearch.
# TODO: make sure ReplaceTemplates still works
return Status::newFatal( "invalid-content-data" );
}
}
+
+ /**
+ * Returns a list of updates to perform when this content is deleted.
+ * The necessary updates may be taken from the Content object, or depend on
+ * the current state of the database.
+ *
+ * @since WD.1
+ *
+ * @param $title \Title the title of the deleted page
+ * @param $parserOutput null|\ParserOutput optional parser output object
+ * for efficient access to meta-information about the content object.
+ * Provide if you have one handy.
+ *
+ * @return array A list of DataUpdate instances that will clean up the
+ * database after deletion.
+ */
+ public function getDeletionUpdates( Title $title,
+ ParserOutput $parserOutput = null )
+ {
+ return array(
+ new LinksDeletionUpdate( $title ),
+ );
+ }
}
/**
return $diff;
}
-
}
/**
* - otherwise, the behaviour is undefined.
*
* @since WD.1
+ * @deprecated since WD.1. Always try to use the content object.
*
* @static
* @param $content Content|null
return true;
}
- /**
- * Returns a list of updates to perform when the given content is deleted.
- * The necessary updates may be taken from the Content object, or depend on
- * the current state of the database.
- *
- * @since WD.1
- *
- * @param $content \Content the Content object for deletion
- * @param $title \Title the title of the deleted page
- * @param $parserOutput null|\ParserOutput optional parser output object
- * for efficient access to meta-information about the content object.
- * Provide if you have one handy.
- *
- * @return array A list of DataUpdate instances that will clean up the
- * database after deletion.
- */
- public function getDeletionUpdates( Content $content, Title $title,
- ParserOutput $parserOutput = null )
- {
- return array(
- new LinksDeletionUpdate( $title ),
- );
- }
-
/**
* Returns true if this content model supports sections.
*
$content = $this->getContent( Revision::RAW );
}
- $updates = $this->getContentHandler()->getDeletionUpdates( $content, $this->mTitle );
+ $updates = $this->getContent()->getDeletionUpdates( $this->mTitle );
wfRunHooks( 'WikiPageDeletionUpdates', array( $this, &$updates ) );
return $updates;
}
}
- public function dataGetDeletionUpdates() {
- return array(
- array("ContentHandlerTest_testGetSecondaryDataUpdates_1", "hello ''world''\n",
- array( 'LinksDeletionUpdate' => array( ) )
- ),
- array("ContentHandlerTest_testGetSecondaryDataUpdates_2", "hello [[world test 21344]]\n",
- array( 'LinksDeletionUpdate' => array( ) )
- ),
- // @todo: more...?
- );
- }
-
- /**
- * @dataProvider dataGetDeletionUpdates
- */
- public function testDeletionUpdates( $title, $text, $expectedStuff ) {
- $title = Title::newFromText( $title );
- $title->resetArticleID( 2342 ); //dummy id. fine as long as we don't try to execute the updates!
-
- $handler = ContentHandler::getForModelID( $title->getContentModel() );
- $content = ContentHandler::makeContent( $text, $title );
-
- $updates = $handler->getDeletionUpdates( $content, $title );
-
- // make updates accessible by class name
- foreach ( $updates as $update ) {
- $class = get_class( $update );
- $updates[ $class ] = $update;
- }
-
- foreach ( $expectedStuff as $class => $fieldValues ) {
- $this->assertArrayHasKey( $class, $updates, "missing an update of type $class" );
-
- $update = $updates[ $class ];
-
- foreach ( $fieldValues as $field => $value ) {
- $v = $update->$field; #if the field doesn't exist, just crash and burn
- $this->assertEquals( $value, $v, "unexpected value for field $field in instance of $class" );
- }
- }
- }
-
public function testSupportsSections() {
$this->markTestIncomplete( "not yet implemented" );
}
$this->assertEquals( $equal, $a->equals( $b ) );
}
+ public function dataGetDeletionUpdates() {
+ return array(
+ array("WikitextContentTest_testGetSecondaryDataUpdates_1", "hello ''world''\n",
+ array( 'LinksDeletionUpdate' => array( ) )
+ ),
+ array("WikitextContentTest_testGetSecondaryDataUpdates_2", "hello [[world test 21344]]\n",
+ array( 'LinksDeletionUpdate' => array( ) )
+ ),
+ // @todo: more...?
+ );
+ }
+
+ /**
+ * @dataProvider dataGetDeletionUpdates
+ */
+ public function testDeletionUpdates( $title, $text, $expectedStuff ) {
+ $title = Title::newFromText( $title );
+ $title->resetArticleID( 2342 ); //dummy id. fine as long as we don't try to execute the updates!
+
+ $handler = ContentHandler::getForModelID( $title->getContentModel() );
+ $content = ContentHandler::makeContent( $text, $title );
+
+ $updates = $content->getDeletionUpdates( $title );
+
+ // make updates accessible by class name
+ foreach ( $updates as $update ) {
+ $class = get_class( $update );
+ $updates[ $class ] = $update;
+ }
+
+ foreach ( $expectedStuff as $class => $fieldValues ) {
+ $this->assertArrayHasKey( $class, $updates, "missing an update of type $class" );
+
+ $update = $updates[ $class ];
+
+ foreach ( $fieldValues as $field => $value ) {
+ $v = $update->$field; #if the field doesn't exist, just crash and burn
+ $this->assertEquals( $value, $v, "unexpected value for field $field in instance of $class" );
+ }
+ }
+ }
+
}