*
* @param $event String: event name
* @param $args Array: parameters passed to hook functions
+ * @param $warn bool: whether to log a warning (default: true). Should generally be true,
+ * may be set to false for testing.
*
* @return Boolean True if no handler aborted the hook
*/
- public static function runLegacyHooks( $event, $args = array() ) {
+ public static function runLegacyHooks( $event, $args = array(), $warn = true ) {
if ( !Hooks::isRegistered( $event ) ) {
return true; // nothing to do here
}
- wfWarn( "Using obsolete hook $event" );
+ if ( $warn ) {
+ wfWarn( "Using obsolete hook $event" );
+ }
// convert Content objects to text
$contentObjects = array();
if ( $rev !== null ) {
return $rev->getContentModel();
} else {
- wfWarn( "Page exists but has no revision!" );
+ $title = $this->mTitle->getPrefixedDBkey();
+ wfWarn( "Page $title exists but has no (visible) revisions!" );
}
}
}
}
- $page->doEdit( $text, '', EDIT_NEW );
+ $page->doEditContent( ContentHandler::makeContent( $text, $title ), '', EDIT_NEW );
$wgCapitalLinks = $oldCapitalLinks;
}
//Make 1 page with 1 revision
$page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
if ( !$page->getId() == 0 ) {
- $page->doEdit( 'UTContent',
- 'UTPageSummary',
- EDIT_NEW,
- false,
- User::newFromName( 'UTSysop' ) );
+ $page->doEditContent(
+ new WikitextContent( 'UTContent' ),
+ 'UTPageSummary',
+ EDIT_NEW,
+ false,
+ User::newFromName( 'UTSysop' ) );
}
}
$wgContLang = Language::factory( 'es' );
$wgLang = Language::factory( 'fr' );
- $status = $page->doEdit( '{{:{{int:history}}}}', 'Test code for bug 14404', 0, false, $user );
+ $status = $page->doEditContent( new WikitextContent( '{{:{{int:history}}}}' ), 'Test code for bug 14404', 0, false, $user );
$templates1 = $title->getTemplateLinksFrom();
$wgLang = Language::factory( 'de' );
$page->mPreparedEdit = false; // In order to force the rerendering of the same wikitext
// We need an edit, a purge is not enough to regenerate the tables
- $status = $page->doEdit( '{{:{{int:history}}}}', 'Test code for bug 14404', EDIT_UPDATE, false, $user );
+ $status = $page->doEditContent( new WikitextContent( '{{:{{int:history}}}}' ), 'Test code for bug 14404', EDIT_UPDATE, false, $user );
$templates2 = $title->getTemplateLinksFrom();
$this->assertEquals( $templates1, $templates2 );
* Checks for the existence of the backwards compatibility static functions (forwarders to WikiPage class)
*/
function testStaticFunctions() {
+ $this->hideDeprecated( 'Article::getAutosummary' );
+ $this->hideDeprecated( 'WikiPage::getAutosummary' );
+
$this->assertEquals( WikiPage::selectFields(), Article::selectFields(),
"Article static functions" );
$this->assertEquals( true, is_callable( "Article::onArticleCreate" ),
Hooks::register( 'testRunLegacyHooks', __CLASS__ . '::dummyHookHandler' );
$content = new WikitextContent( 'test text' );
- $ok = ContentHandler::runLegacyHooks( 'testRunLegacyHooks', array( 'foo', &$content, 'bar' ) );
+ $ok = ContentHandler::runLegacyHooks( 'testRunLegacyHooks', array( 'foo', &$content, 'bar' ), false );
$this->assertTrue( $ok, "runLegacyHooks should have returned true" );
$this->assertEquals( "TEST TEXT", $content->getNativeData() );
$page = $this->createPage( 'RevisionStorageTest_testFetchRevision', 'one' );
$id1 = $page->getRevision()->getId();
- $page->doEdit( 'two', 'second rev' );
+ $page->doEditContent( new WikitextContent( 'two' ), 'second rev' );
$id2 = $page->getRevision()->getId();
$res = Revision::fetchRevision( $page->getTitle() );
*/
public function testGetText()
{
+ $this->hideDeprecated( 'Revision::getText' );
+
$orig = $this->makeRevision( array( 'text' => 'hello hello.' ) );
$rev = Revision::newFromId( $orig->getId() );
*/
public function testRevText()
{
+ $this->hideDeprecated( 'Revision::revText' );
+
$orig = $this->makeRevision( array( 'text' => 'hello hello rev.' ) );
$rev = Revision::newFromId( $orig->getId() );
*/
public function testGetRawText()
{
+ $this->hideDeprecated( 'Revision::getRawText' );
+
$orig = $this->makeRevision( array( 'text' => 'hello hello raw.' ) );
$rev = Revision::newFromId( $orig->getId() );
* @dataProvider dataGetText
*/
function testGetText( $text, $title, $model, $format, $audience, $expectedText ) {
+ $this->hideDeprecated( 'Revision::getText' );
+
$rev = $this->newTestRevision( $text, $title, $model, $format );
$this->assertEquals( $expectedText, $rev->getText( $audience ) );
* @dataProvider dataGetText
*/
function testGetRawText( $text, $title, $model, $format, $audience, $expectedText ) {
+ $this->hideDeprecated( 'Revision::getRawText' );
+
$rev = $this->newTestRevision( $text, $title, $model, $format );
$this->assertEquals( $expectedText, $rev->getRawText( $audience ) );
$user = new User();
$user->mRights = array( 'createpage', 'edit', 'purge' );
- $status = $page->doEdit( '{{Categorising template}}', 'Create a page with a template', 0, false, $user );
+ $status = $page->doEditContent( new WikitextContent( '{{Categorising template}}' ), 'Create a page with a template', 0, false, $user );
$this->assertEquals(
array()
, $title->getParentCategories()
);
$template = WikiPage::factory( Title::newFromText( 'Template:Categorising template' ) );
- $status = $template->doEdit( '[[Category:Solved bugs]]', 'Add a category through a template', 0, false, $user );
+ $status = $template->doEditContent( new WikitextContent( '[[Category:Solved bugs]]' ), 'Add a category through a template', 0, false, $user );
// Run the job queue
$jobs = new RunJobs;
}
public function testDoEdit() {
+ $this->hideDeprecated( "WikiPage::doEdit" );
+ $this->hideDeprecated( "WikiPage::getText" );
+ $this->hideDeprecated( "Revision::getText" );
+
$title = Title::newFromText( "WikiPageTest_testDoEdit" );
$page = $this->newPage( $title );
public function testDoQuickEdit() {
global $wgUser;
+ $this->hideDeprecated( "WikiPage::doQuickEdit" );
+
$page = $this->createPage( "WikiPageTest_testDoQuickEdit", "original text" );
$text = "quick text";
}
public function testGetText() {
+ $this->hideDeprecated( "WikiPage::getText" );
+
$page = $this->newPage( "WikiPageTest_testGetText" );
$text = $page->getText();
}
public function testGetRawText() {
+ $this->hideDeprecated( "WikiPage::getRawText" );
+
$page = $this->newPage( "WikiPageTest_testGetRawText" );
$text = $page->getRawText();
* @dataProvider dataReplaceSection
*/
public function testReplaceSection( $title, $text, $section, $with, $sectionTitle, $expected ) {
+ $this->hideDeprecated( "WikiPage::replaceSection" );
+
$page = $this->createPage( $title, $text );
$text = $page->replaceSection( $section, $with, $sectionTitle );
$text = trim( $text );
* @dataProvider dataGetAutoSummary
*/
public function testGetAutosummary( $old, $new, $flags, $expected ) {
+ $this->hideDeprecated( "WikiPage::getAutosummary" );
+
$page = $this->newPage( "WikiPageTest_testGetAutosummary" );
$summary = $page->getAutosummary( $old, $new, $flags );
LinkCache::singleton()->clear();
$page = WikiPage::factory( $title );
- $page->doEdit( $text, $comment, 0, false, $user );
+ $page->doEditContent( ContentHandler::makeContent( $text, $title ), $comment, 0, false, $user );
$this->pageList[] = array( $title, $page->getId() );
* @throws MWExcepion
*/
protected function addRevision( Page $page, $text, $summary ) {
- $status = $page->doEdit( $text, $summary );
+ $status = $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), $summary );
if ( $status->isGood() ) {
$value = $status->getValue();
$revision = $value['revision'];
* @throws MWExcepion
*/
private function addRevision( $page, $text, $summary ) {
- $status = $page->doEdit( $text, $summary );
+ $status = $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), $summary );
if ( $status->isGood() ) {
$value = $status->getValue();
$revision = $value['revision'];