/** * * @param Title $title * @param boolean $create * @param string $comment * @return boolean true to continue hook processing or false to abort */ public static function onArticleUndelete(&$title, $create, $comment) { $namespace = $title->getNamespace(); if (!WpPage::isInWikiplaceNamespaces($namespace)) { return true; } $article_id = $title->getArticleID(); $pdb_key = $title->getPrefixedDBkey(); wfDebugLog('wikiplaces-debug', 'onArticleUndelete() trying to restore article=[' . $article_id . ']"' . $pdb_key); if (WpPage::isHomepage($title)) { // WARNING, this case shouldn't be allowed and we should arrive here, because where are not sure the user restoring // the wikiplace is the effective owner (ie: an admin, another artist, ?) // so, who is this wikiplace owner ? wfDebugLog('wikiplaces', 'onArticleUndelete() ERROR wikiplace homepage restored, unknown owner, article="' . $pdb_key . '"'); throw new MWException('Error: wikiplace homepage restored, but unknown owner.'); } else { // restoring a subpage $wp = WpWikiplace::getBySubpage($title->getDBkey(), $namespace); if ($wp == null) { wfDebugLog('wikiplaces', 'onArticleUndelete() ERROR while searching container wikiplace, article=[' . $article_id . ']"' . $pdb_key . '"'); throw new MWException('Error while searching container wikiplace.'); } $wp_id = $wp->getId(); if (WpPage::create($article_id, $wp_id) == null) { wfDebugLog('wikiplaces', 'onArticleUndelete() ERROR while associating restored subpage to its wikiplace, article=[' . $article_id . ']"' . $pdb_key . '"'); throw new MWException('Error while associating the restored subpage to its container wikiplace.'); } wfDebugLog('wikiplaces-debug', 'onArticleUndelete() article [' . $article_id . '] restored in wikiplace [' . $wp_id . ']'); } return true; }