Topic on Project:Support desk

Problem reading article from inside extension

5
2003:E7:5704:900:AD27:9111:48F9:9408 (talkcontribs)

Hello Support.


I have written an extension which loads a Latex preamble, adds contents from Wiki page section and generates and displays the Latex compilation result. It has been working for many years. Now I need to make the preamble editable and I miserably fail.


The working code looks as follows:


    $templateFileName = TEMPLATE_PATH."amstex1.tex";

    $template = file_get_contents( $templateFileName);

    self::debugLog ("have template file \n");


What I now want to do instead is this:


   // attempt to get template from mediawiki itself

    self::debugLog  (" Will now load from mediawiki itself \n");

    try {

      $myTitle = Title::newFromTextThrow( 'MediaWiki:AmstexTemplate' );

      if ($myTitle->canExist) {self::debugLog ("can exist");}

      else {self::debugLog("not existing");}

      $myArticle = new Article( $myTitle );

      $template = $myArticle->getPage()->getContent()->getNativeData();

      self::debugLog ("Done");

    } catch (Exception $e) {  self::debugLog ("In generateTex exception handler");   }

    self::debugLog  ("Loaded template");


My problem is: It looks like the system vanishes into Nirwana in the Title::newFromTextThrow call. I get no debug information, no exception, just nothing. So I also fail to debug this.


What can I do?

2003:E7:5704:900:AD27:9111:48F9:9408 (talkcontribs)

I also had various other versions, such as

$myTitle = Title::newFromTextThrow( 'AmstexTemplate', NS_MEDIAWIKI );

but the problem seems that I get absolutely no debug or return information back.

2003:E7:5704:900:AD27:9111:48F9:9408 (talkcontribs)

Looks like the server is complaining that it does not find the class Title. How come?

2003:E7:5704:900:AD27:9111:48F9:9408 (talkcontribs)

But when I

include "/var/www/html/wiki4/includes/Title.php";

I get a Cannot declare class Title, because the name is already in use.

2003:E7:5704:900:AD27:9111:48F9:9408 (talkcontribs)

Ok. Sorry. Problem solved. It was a twisted logic in the extension. Sorry for bothering.