/**
  * Constructor
  *
  * @param WikiPage $page Page we are updating
  * @throws MWException
  */
 function __construct(WikiPage $page)
 {
     parent::__construct(false);
     // no implicit transaction
     $this->mPage = $page;
     if (!$page->exists()) {
         throw new MWException("Page ID not known, perhaps the page doesn't exist?");
     }
 }
Exemplo n.º 2
0
 /**
  * @param WikiPage $page Page we are updating
  * @param integer|null $pageId ID of the page we are updating [optional]
  * @throws MWException
  */
 function __construct(WikiPage $page, $pageId = null)
 {
     parent::__construct(false);
     // no implicit transaction
     $this->page = $page;
     if ($page->exists()) {
         $this->pageId = $page->getId();
     } elseif ($pageId) {
         $this->pageId = $pageId;
     } else {
         throw new MWException("Page ID not known, perhaps the page doesn't exist?");
     }
 }
Exemplo n.º 3
0
 /**
  * Constructor
  *
  * @param Title $title Title of the page we're updating
  * @param ParserOutput $parserOutput Output from a full parse of this page
  * @param bool $recursive Queue jobs for recursive updates?
  * @throws MWException
  */
 function __construct($title, $parserOutput, $recursive = true)
 {
     parent::__construct(false);
     // no implicit transaction
     if (!$title instanceof Title) {
         throw new MWException("The calling convention to LinksUpdate::LinksUpdate() has changed. " . "Please see Article::editUpdates() for an invocation example.\n");
     }
     if (!$parserOutput instanceof ParserOutput) {
         throw new MWException("The calling convention to LinksUpdate::__construct() has changed. " . "Please see WikiPage::doEditUpdates() for an invocation example.\n");
     }
     $this->mTitle = $title;
     $this->mId = $title->getArticleID();
     if (!$this->mId) {
         throw new MWException("The Title object did not provide an article " . "ID. Perhaps the page doesn't exist?");
     }
     $this->mParserOutput = $parserOutput;
     $this->mLinks = $parserOutput->getLinks();
     $this->mImages = $parserOutput->getImages();
     $this->mTemplates = $parserOutput->getTemplates();
     $this->mExternals = $parserOutput->getExternalLinks();
     $this->mCategories = $parserOutput->getCategories();
     $this->mProperties = $parserOutput->getProperties();
     $this->mInterwikis = $parserOutput->getInterwikiLinks();
     # Convert the format of the interlanguage links
     # I didn't want to change it in the ParserOutput, because that array is passed all
     # the way back to the skin, so either a skin API break would be required, or an
     # inefficient back-conversion.
     $ill = $parserOutput->getLanguageLinks();
     $this->mInterlangs = array();
     foreach ($ill as $link) {
         list($key, $title) = explode(':', $link, 2);
         $this->mInterlangs[$key] = $title;
     }
     foreach ($this->mCategories as &$sortkey) {
         # If the sortkey is longer then 255 bytes,
         # it truncated by DB, and then doesn't get
         # matched when comparing existing vs current
         # categories, causing bug 25254.
         # Also. substr behaves weird when given "".
         if ($sortkey !== '') {
             $sortkey = substr($sortkey, 0, 255);
         }
     }
     $this->mRecursive = $recursive;
     Hooks::run('LinksUpdateConstructed', array(&$this));
 }
Exemplo n.º 4
0
 /**
  * Constructor
  *
  * @param Title $title Title of the page we're updating
  * @param ParserOutput $parserOutput Output from a full parse of this page
  * @param bool $recursive Queue jobs for recursive updates?
  * @throws MWException
  */
 function __construct(Title $title, ParserOutput $parserOutput, $recursive = true)
 {
     parent::__construct(false);
     // no implicit transaction
     $this->mTitle = $title;
     $this->mId = $title->getArticleID(Title::GAID_FOR_UPDATE);
     if (!$this->mId) {
         throw new InvalidArgumentException("The Title object yields no ID. Perhaps the page doesn't exist?");
     }
     $this->mParserOutput = $parserOutput;
     $this->mLinks = $parserOutput->getLinks();
     $this->mImages = $parserOutput->getImages();
     $this->mTemplates = $parserOutput->getTemplates();
     $this->mExternals = $parserOutput->getExternalLinks();
     $this->mCategories = $parserOutput->getCategories();
     $this->mProperties = $parserOutput->getProperties();
     $this->mInterwikis = $parserOutput->getInterwikiLinks();
     # Convert the format of the interlanguage links
     # I didn't want to change it in the ParserOutput, because that array is passed all
     # the way back to the skin, so either a skin API break would be required, or an
     # inefficient back-conversion.
     $ill = $parserOutput->getLanguageLinks();
     $this->mInterlangs = array();
     foreach ($ill as $link) {
         list($key, $title) = explode(':', $link, 2);
         $this->mInterlangs[$key] = $title;
     }
     foreach ($this->mCategories as &$sortkey) {
         # If the sortkey is longer then 255 bytes,
         # it truncated by DB, and then doesn't get
         # matched when comparing existing vs current
         # categories, causing bug 25254.
         # Also. substr behaves weird when given "".
         if ($sortkey !== '') {
             $sortkey = substr($sortkey, 0, 255);
         }
     }
     $this->mRecursive = $recursive;
     Hooks::run('LinksUpdateConstructed', array(&$this));
 }
Exemplo n.º 5
0
 /**
  * Constructor
  *
  * @param $page WikiPage Page we are updating
  */
 function __construct(WikiPage $page)
 {
     parent::__construct(false);
     // no implicit transaction
     $this->mPage = $page;
 }