Skip to content
4 changes: 2 additions & 2 deletions Wikilog.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
// General Wikilog hooks
$wgHooks['ArticleEditUpdates'][] = 'WikilogHooks::ArticleEditUpdates';
$wgHooks['ArticleDelete'][] = 'WikilogHooks::ArticleDelete';
$wgHooks['ArticleSave'][] = 'WikilogHooks::ArticleSave';
$wgHooks['PageContentSave'][] = 'WikilogHooks::ArticleSave';
$wgHooks['TitleMoveComplete'][] = 'WikilogHooks::TitleMoveComplete';
$wgHooks['EditPage::attemptSave'][] = 'WikilogHooks::EditPageAttemptSave';
$wgHooks['EditPage::showEditForm:fields'][] = 'WikilogHooks::EditPageEditFormFields';
Expand Down Expand Up @@ -383,7 +383,7 @@ static function BeforePageDisplay( $output, $skin ) {
static function LinkBegin( $skin, $target, $text, $attribs, $query, &$options, &$ret )
{
if ( $target->isTalkPage() &&
( $i = array_search( 'broken', $options ) ) !== false ) {
( $i = array_search( 'broken', array_keys($options) ) ) !== false ) {
if ( self::nsHasComments( $target ) ) {
array_splice( $options, $i, 1 );
$options[] = 'known';
Expand Down
22 changes: 14 additions & 8 deletions WikilogHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,12 @@ static function ArticleEditUpdates( $article, &$editInfo, $changed ) {
$item->saveData();

if ( !$wasPublished && $item->mPublish ) {
global $wgEnableEmail;
// Send email notifications about the new post
SpecialWikilogSubscriptions::sendEmails( $article,
!empty( $editInfo->pstContent ) ? $editInfo->pstContent->getNativeData() : $article->getText() );
if ( $wgEnableEmail ) {
SpecialWikilogSubscriptions::sendEmails( $article,
!empty( $editInfo->pstContent ) ? $editInfo->pstContent->getNativeData() : $article->getText() );
}
}
} else {
# Remove entry from tables. Entries in wikilog_authors and
Expand Down Expand Up @@ -237,27 +240,30 @@ static function ArticleDelete( $article, $user, $reason, &$error ) {
* Add article signature if user selected "sign and publish" option in
* EditPage, or if there is ~~~~ in the text.
*/
static function ArticleSave( $article, $user, &$text, &$summary,
$minor, $watch, $sectionanchor, &$flags )
static function ArticleSave( &$wikiPage, &$user, &$content, &$summary,
$isMinor, $isWatch, $section, &$flags, &$status )
{
$t = WikilogUtils::getPublishParameters();
$txtDate = $t['date'];
$txtUser = $t['user'];
$text = ContentHandler::getContentText( $content );

// $article->mExtWikilog piggybacked from WikilogHooks::EditPageAttemptSave().
if ( isset( $article->mExtWikilog ) && $article->mExtWikilog['signpub'] ) {
if ( isset( $wikiPage->mExtWikilog ) && $wikiPage->mExtWikilog['signpub'] ) {
$text = rtrim( $text ) . "\n{{wl-publish: $txtDate | $txtUser }}\n";
} elseif ( Wikilog::getWikilogInfo( $article->getTitle() ) ) {
} elseif ( Wikilog::getWikilogInfo( $wikiPage->getTitle() ) ) {
global $wgParser;
$sigs = array(
'/\n?(--)?~~~~~\n?/m' => "\n{{wl-publish: $txtDate }}\n",
'/\n?(--)?~~~~\n?/m' => "\n{{wl-publish: $txtDate | $txtUser }}\n",
'/\n?(--)?~~~\n?/m' => "\n{{wl-author: $txtUser }}\n"
);
$wgParser->startExternalParse( $article->getTitle(), ParserOptions::newFromUser( $user ), Parser::OT_WIKI );
$wgParser->startExternalParse( $wikiPage->getTitle(), ParserOptions::newFromUser( $user ), Parser::OT_WIKI );
$text = $wgParser->replaceVariables( $text );
$text = preg_replace( array_keys( $sigs ), array_values( $sigs ), $text );
$text = $wgParser->mStripState->unstripBoth( $text );
}
$content = new WikitextContent( $text );
return true;
}

Expand Down Expand Up @@ -377,7 +383,7 @@ static function EditPageAttemptSave( $editpage ) {

// Piggyback options into article object. Will be retrieved later
// in 'ArticleEditUpdates' hook.
$editpage->mArticle->mExtWikilog = $options;
$editpage->mArticle->getPage()->mExtWikilog = $options;
return true;
}

Expand Down