Last modified: 2010-05-15 16:03:00 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T17298, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 15298 - Cannot Use Parser Inside EditPage::showEditForm:initial Hook
Cannot Use Parser Inside EditPage::showEditForm:initial Hook
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
Page editing (Other open bugs)
1.13.x
PC Windows XP
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-08-25 04:32 UTC by David
Modified: 2010-05-15 16:03 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description David 2008-08-25 04:32:38 UTC
PHP: 5.2.4
MySQL: 5.0.45

Given the following extension, I keep getting a blank page if I uncomment either of the commented lines:

  $wgHooks['EditPage::showEditForm:initial'][] = "wfParserTest";
  
  function wfParserTest( &$editPage )
  {
      global $wgParser;
  
      $localParser = new Parser();
      //$output = $wgParser->parse( '', $this->mTitle );
      //$output = $localParser->parse( '', $this->mTitle );
  
      return true;
  }

This problem occurs if is just try to preprocess any wikitext [using Preprocessor_DOM::preprocessToObj()].
Comment 1 Roan Kattouw 2008-08-25 05:21:39 UTC
(In reply to comment #0)
> PHP: 5.2.4
> MySQL: 5.0.45
> 
> Given the following extension, I keep getting a blank page if I uncomment
> either of the commented lines:
Of course you do, because:

>       //$output = $wgParser->parse( '', $this->mTitle );
>       //$output = $localParser->parse( '', $this->mTitle );
you can't use $this inside a global function.
Comment 2 David 2008-08-25 16:15:43 UTC
Ah, yes.  I'm always amazed by my ability to overlook the obvious.

Nonetheless, if I substitute $this->mTitle with a valid title object whose page exists, such as:

  $wgHooks['EditPage::showEditForm:initial'][] = "wfParserTest";

  function wfParserTest( &$editPage )
  {
      global $wgParser;

      $output = $wgParser->parse( '', Title::newFromText( 'Main Page' ) );

      return true;
  }

I still get a blank page when I follow any page's "edit" link.
Comment 3 Tim Starling 2008-08-25 16:24:09 UTC
This is a bug with your code. Bugzilla is not a support forum. Please request help on one of the support forums such as the IRC channel (#mediawiki) or mailing list (mediawiki-l).

Hint: $wgParser->parse( $text, $title, new ParserOptions );
Comment 4 David 2008-08-25 18:03:55 UTC
My mistake.  When I found that a simple method call such as

  $wgParser->preprocessToDom( '' );

resulted in a blank page, I genuinely though it was a bug.  I'll direct my problem to the proper forums.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links