From fac5879a42156b55c405f6598607d25993c11791 Mon Sep 17 00:00:00 2001 From: albul Date: Wed, 23 Jan 2019 09:23:20 +0200 Subject: [PATCH 1/9] Fix PHP Warning: array_splice() expects parameter 2 to be integer, string given in Wikilog.php on line 388 --- Wikilog.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Wikilog.php b/Wikilog.php index 7b553e3..78cc54c 100644 --- a/Wikilog.php +++ b/Wikilog.php @@ -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'; From a3657b098c3a71e9c1aa287e5895fab5d60fe4b5 Mon Sep 17 00:00:00 2001 From: albul Date: Wed, 23 Jan 2019 16:45:15 +0200 Subject: [PATCH 2/9] Change deprecated onArticleSave on onPageContentSave https://www.mediawiki.org/wiki/Manual:Hooks/PageContentSave --- Wikilog.php | 2 +- WikilogHooks.php | 52 ++++++++++++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/Wikilog.php b/Wikilog.php index 78cc54c..1196fe2 100644 --- a/Wikilog.php +++ b/Wikilog.php @@ -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'; diff --git a/WikilogHooks.php b/WikilogHooks.php index c1ca227..79d5623 100644 --- a/WikilogHooks.php +++ b/WikilogHooks.php @@ -237,29 +237,33 @@ 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 ) - { - $t = WikilogUtils::getPublishParameters(); - $txtDate = $t['date']; - $txtUser = $t['user']; - // $article->mExtWikilog piggybacked from WikilogHooks::EditPageAttemptSave(). - if ( isset( $article->mExtWikilog ) && $article->mExtWikilog['signpub'] ) { - $text = rtrim( $text ) . "\n{{wl-publish: $txtDate | $txtUser }}\n"; - } elseif ( Wikilog::getWikilogInfo( $article->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 ); - $text = $wgParser->replaceVariables( $text ); - $text = preg_replace( array_keys( $sigs ), array_values( $sigs ), $text ); - $text = $wgParser->mStripState->unstripBoth( $text ); - } - return true; - } + 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( $wikiPage->mExtWikilog ) && $wikiPage->mExtWikilog['signpub'] ) { + $text = rtrim( $text ) . "\n{{wl-publish: $txtDate | $txtUser }}\n"; + } 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( $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; + } + /** * TitleMoveComplete hook handler function. @@ -377,7 +381,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; } From efbc5c51c841e975dd41be8409a63d32d5296d99 Mon Sep 17 00:00:00 2001 From: albul Date: Wed, 23 Jan 2019 17:17:31 +0200 Subject: [PATCH 3/9] Do not sendEmails when $wgEnableEmail = false; --- WikilogHooks.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/WikilogHooks.php b/WikilogHooks.php index 79d5623..10852be 100644 --- a/WikilogHooks.php +++ b/WikilogHooks.php @@ -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 From 645f1830bc8dfee12374fbfc27ddb3ea1a6d526d Mon Sep 17 00:00:00 2001 From: albul Date: Thu, 24 Jan 2019 13:20:24 +0200 Subject: [PATCH 4/9] Compatibility with Translation extension https://www.mediawiki.org/wiki/Topic:Que3bzw89hb9siuk --- Wikilog.php | 46 ++++++++++++++++++++++---------------------- WikilogItem.php | 12 ++++++++++++ WikilogItemPager.php | 6 +++--- WikilogMainPage.php | 18 ++++++++++++++++- 4 files changed, 55 insertions(+), 27 deletions(-) diff --git a/Wikilog.php b/Wikilog.php index 1196fe2..ec93ba6 100644 --- a/Wikilog.php +++ b/Wikilog.php @@ -341,7 +341,7 @@ static function ArticleFromTitle( $title, &$article ) { return true; // continue hook processing if createInstance returned NULL } elseif ( ( $wi = self::getWikilogInfo( $title ) ) ) { if ( $wi->isItem() ) { - $item = WikilogItem::newFromInfo( $wi ); + $item = WikilogItem::newFromID( $title->getArticleID() ); $article = new WikilogItemPage( $title, $item ); } else { $article = new WikilogMainPage( $title, $wi ); @@ -535,28 +535,28 @@ class WikilogInfo */ function __construct( $title ) { $origns = $title->getNamespace(); - $this->mIsTalk = MWNamespace::isTalk( $origns ); - $ns = MWNamespace::getSubject( $origns ); - $tns = MWNamespace::getTalk( $origns ); - - $parts = explode( '/', $title->getText() ); - if ( count( $parts ) > 1 && ( $this->mIsTalk || count( $parts ) == 2 ) ) { - // If title contains a '/', treat as a wikilog article title. - $this->mWikilogName = array_shift( $parts ); - $this->mItemName = array_shift( $parts ); - $this->mTrailing = implode( '/', $parts ); - $rawtitle = "{$this->mWikilogName}/{$this->mItemName}"; - $this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName ); - $this->mItemTitle = Title::makeTitle( $ns, $rawtitle ); - $this->mItemTalkTitle = Title::makeTitle( $tns, $rawtitle ); - } elseif ( count( $parts ) == 1 ) { - // Title doesn't contain a '/', treat as a wikilog name. - $this->mWikilogName = $title->getText(); - $this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName ); - $this->mItemName = null; - $this->mItemTitle = null; - $this->mItemTalkTitle = null; - } + $this->mIsTalk = MWNamespace::isTalk( $origns ); + $ns = MWNamespace::getSubject( $origns ); + $tns = MWNamespace::getTalk( $origns ); + + $parts = explode( '/', $title->getText() ); + if ( count( $parts ) > 1 && (strlen($parts[1]) > 2 || count( $parts ) > 2)) { + // If title contains a '/', treat as a wikilog article title. + $this->mWikilogName = array_shift( $parts ); + $this->mItemName = array_shift( $parts ); + $this->mTrailing = implode( '/', $parts ); + $rawtitle = "{$this->mWikilogName}/{$this->mItemName}"; + $this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName ); + $this->mItemTitle = Title::makeTitle( $ns, $rawtitle ); + $this->mItemTalkTitle = Title::makeTitle( $tns, $rawtitle ); + } else { + // Title doesn't contain a '/', treat as a wikilog name. + $this->mWikilogName = $title->getText(); + $this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName ); + $this->mItemName = null; + $this->mItemTitle = null; + $this->mItemTalkTitle = null; + } } function isMain() { return $this->mItemTitle === null; } diff --git a/WikilogItem.php b/WikilogItem.php index db496a6..19ea00b 100644 --- a/WikilogItem.php +++ b/WikilogItem.php @@ -236,6 +236,18 @@ public static function newFromRow( $row ) { if ( !is_array( $item->mTags ) ) { $item->mTags = array(); } + + $langCode = $item->mTitle->getPageLanguage()->getCode(); + if ( strlen($langCode) != 0 && strcmp($langCode, "en") !== 0 ) { + $dbr = wfGetDB( DB_SLAVE ); + $displayTitle = $dbr->selectField( + 'page_props', + 'pp_value', + array( 'pp_propname' => 'displaytitle', 'pp_page' => $item->mID ), + __METHOD__ + ); + $item->mName = $displayTitle; + } return $item; } diff --git a/WikilogItemPager.php b/WikilogItemPager.php index e343432..db0a18b 100644 --- a/WikilogItemPager.php +++ b/WikilogItemPager.php @@ -192,9 +192,9 @@ function formatRow( $row ) { $heading = Linker::link( $item->mTitle, $titleText, array(), array(), array( 'known', 'noclasses' ) ); - if ( $this->mShowEditLink && $item->mTitle->quickUserCan( 'edit' ) ) { - $heading = $this->doEditLink( $item->mTitle, $item->mName ) . $heading; - } + //if ( $this->mShowEditLink && $item->mTitle->quickUserCan( 'edit' ) ) { + // $heading = $this->doEditLink( $item->mTitle, $item->mName ) . $heading; + //} $heading = Xml::tags( 'h2', null, $heading ); # Sumary entry header. diff --git a/WikilogMainPage.php b/WikilogMainPage.php index 84ff264..45be50c 100644 --- a/WikilogMainPage.php +++ b/WikilogMainPage.php @@ -62,9 +62,25 @@ public function __construct( &$title, &$wi ) { public function view() { global $wgRequest, $wgOut, $wgMimeType, $wgUser; - $query = new WikilogItemQuery( $this->mTitle ); + $queryTitle; + $parts = explode( '/', $this->mTitle->getText() ); + if (count( $parts ) > 1) { + $origns = $this->mTitle->getNamespace(); + $ns = MWNamespace::getSubject( $origns ); + $queryTitle = Title::makeTitle( $ns, $parts[0] ); + } else { + $queryTitle = $this->mTitle; + } + + $query = new WikilogItemQuery( $queryTitle ); $query->setPubStatus( $wgRequest->getVal( 'show' ) ); + if (count( $parts ) > 1) { + $query->setCategory('News/'.$parts[1]); + } else { + $query->setCategory('News'); + } + # RSS or Atom feed requested. Ignore all other options. if ( ( $feedFormat = $wgRequest->getVal( 'feed' ) ) ) { global $wgWikilogNumArticles; From 0a240d3b355b54254e38701555d4a6d527ce2180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sz=C5=91ts=20=C3=81kos?= Date: Tue, 24 Dec 2019 14:45:26 +0100 Subject: [PATCH 5/9] Restore white spaces to tabs --- Wikilog.php | 44 ++++++++++++++++++------------------- WikilogHooks.php | 53 ++++++++++++++++++++++----------------------- WikilogItem.php | 20 ++++++++--------- WikilogMainPage.php | 28 ++++++++++++------------ 4 files changed, 72 insertions(+), 73 deletions(-) diff --git a/Wikilog.php b/Wikilog.php index ec93ba6..08edda6 100644 --- a/Wikilog.php +++ b/Wikilog.php @@ -535,28 +535,28 @@ class WikilogInfo */ function __construct( $title ) { $origns = $title->getNamespace(); - $this->mIsTalk = MWNamespace::isTalk( $origns ); - $ns = MWNamespace::getSubject( $origns ); - $tns = MWNamespace::getTalk( $origns ); - - $parts = explode( '/', $title->getText() ); - if ( count( $parts ) > 1 && (strlen($parts[1]) > 2 || count( $parts ) > 2)) { - // If title contains a '/', treat as a wikilog article title. - $this->mWikilogName = array_shift( $parts ); - $this->mItemName = array_shift( $parts ); - $this->mTrailing = implode( '/', $parts ); - $rawtitle = "{$this->mWikilogName}/{$this->mItemName}"; - $this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName ); - $this->mItemTitle = Title::makeTitle( $ns, $rawtitle ); - $this->mItemTalkTitle = Title::makeTitle( $tns, $rawtitle ); - } else { - // Title doesn't contain a '/', treat as a wikilog name. - $this->mWikilogName = $title->getText(); - $this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName ); - $this->mItemName = null; - $this->mItemTitle = null; - $this->mItemTalkTitle = null; - } + $this->mIsTalk = MWNamespace::isTalk( $origns ); + $ns = MWNamespace::getSubject( $origns ); + $tns = MWNamespace::getTalk( $origns ); + + $parts = explode( '/', $title->getText() ); + if ( count( $parts ) > 1 && (strlen($parts[1]) > 2 || count( $parts ) > 2)) { + // If title contains a '/', treat as a wikilog article title. + $this->mWikilogName = array_shift( $parts ); + $this->mItemName = array_shift( $parts ); + $this->mTrailing = implode( '/', $parts ); + $rawtitle = "{$this->mWikilogName}/{$this->mItemName}"; + $this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName ); + $this->mItemTitle = Title::makeTitle( $ns, $rawtitle ); + $this->mItemTalkTitle = Title::makeTitle( $tns, $rawtitle ); + } else { + // Title doesn't contain a '/', treat as a wikilog name. + $this->mWikilogName = $title->getText(); + $this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName ); + $this->mItemName = null; + $this->mItemTitle = null; + $this->mItemTalkTitle = null; + } } function isMain() { return $this->mItemTitle === null; } diff --git a/WikilogHooks.php b/WikilogHooks.php index 10852be..510a48f 100644 --- a/WikilogHooks.php +++ b/WikilogHooks.php @@ -240,33 +240,32 @@ 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( &$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( $wikiPage->mExtWikilog ) && $wikiPage->mExtWikilog['signpub'] ) { - $text = rtrim( $text ) . "\n{{wl-publish: $txtDate | $txtUser }}\n"; - } 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( $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; - } - + 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( $wikiPage->mExtWikilog ) && $wikiPage->mExtWikilog['signpub'] ) { + $text = rtrim( $text ) . "\n{{wl-publish: $txtDate | $txtUser }}\n"; + } 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( $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; + } /** * TitleMoveComplete hook handler function. diff --git a/WikilogItem.php b/WikilogItem.php index 19ea00b..73400aa 100644 --- a/WikilogItem.php +++ b/WikilogItem.php @@ -238,16 +238,16 @@ public static function newFromRow( $row ) { } $langCode = $item->mTitle->getPageLanguage()->getCode(); - if ( strlen($langCode) != 0 && strcmp($langCode, "en") !== 0 ) { - $dbr = wfGetDB( DB_SLAVE ); - $displayTitle = $dbr->selectField( - 'page_props', - 'pp_value', - array( 'pp_propname' => 'displaytitle', 'pp_page' => $item->mID ), - __METHOD__ - ); - $item->mName = $displayTitle; - } + if ( strlen($langCode) != 0 && strcmp($langCode, "en") !== 0 ) { + $dbr = wfGetDB( DB_SLAVE ); + $displayTitle = $dbr->selectField( + 'page_props', + 'pp_value', + array( 'pp_propname' => 'displaytitle', 'pp_page' => $item->mID ), + __METHOD__ + ); + $item->mName = $displayTitle; + } return $item; } diff --git a/WikilogMainPage.php b/WikilogMainPage.php index 45be50c..7a04175 100644 --- a/WikilogMainPage.php +++ b/WikilogMainPage.php @@ -62,24 +62,24 @@ public function __construct( &$title, &$wi ) { public function view() { global $wgRequest, $wgOut, $wgMimeType, $wgUser; - $queryTitle; - $parts = explode( '/', $this->mTitle->getText() ); - if (count( $parts ) > 1) { - $origns = $this->mTitle->getNamespace(); - $ns = MWNamespace::getSubject( $origns ); - $queryTitle = Title::makeTitle( $ns, $parts[0] ); - } else { - $queryTitle = $this->mTitle; - } + $queryTitle; + $parts = explode( '/', $this->mTitle->getText() ); + if (count( $parts ) > 1) { + $origns = $this->mTitle->getNamespace(); + $ns = MWNamespace::getSubject( $origns ); + $queryTitle = Title::makeTitle( $ns, $parts[0] ); + } else { + $queryTitle = $this->mTitle; + } $query = new WikilogItemQuery( $queryTitle ); $query->setPubStatus( $wgRequest->getVal( 'show' ) ); - if (count( $parts ) > 1) { - $query->setCategory('News/'.$parts[1]); - } else { - $query->setCategory('News'); - } + if (count( $parts ) > 1) { + $query->setCategory('News/'.$parts[1]); + } else { + $query->setCategory('News'); + } # RSS or Atom feed requested. Ignore all other options. if ( ( $feedFormat = $wgRequest->getVal( 'feed' ) ) ) { From 823aa7bccf457b57d434d3807bfa5eba91566c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sz=C5=91ts=20=C3=81kos?= Date: Tue, 24 Dec 2019 14:48:10 +0100 Subject: [PATCH 6/9] Remove hard-coded, seemingly site-specific code part --- WikilogMainPage.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/WikilogMainPage.php b/WikilogMainPage.php index 7a04175..2ef0aad 100644 --- a/WikilogMainPage.php +++ b/WikilogMainPage.php @@ -75,12 +75,6 @@ public function view() { $query = new WikilogItemQuery( $queryTitle ); $query->setPubStatus( $wgRequest->getVal( 'show' ) ); - if (count( $parts ) > 1) { - $query->setCategory('News/'.$parts[1]); - } else { - $query->setCategory('News'); - } - # RSS or Atom feed requested. Ignore all other options. if ( ( $feedFormat = $wgRequest->getVal( 'feed' ) ) ) { global $wgWikilogNumArticles; From 30d3298ee11974de61c4352140f4960078aa7237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sz=C5=91ts=20=C3=81kos?= Date: Tue, 24 Dec 2019 14:51:01 +0100 Subject: [PATCH 7/9] Restore commented-out code --- WikilogItemPager.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WikilogItemPager.php b/WikilogItemPager.php index db0a18b..e343432 100644 --- a/WikilogItemPager.php +++ b/WikilogItemPager.php @@ -192,9 +192,9 @@ function formatRow( $row ) { $heading = Linker::link( $item->mTitle, $titleText, array(), array(), array( 'known', 'noclasses' ) ); - //if ( $this->mShowEditLink && $item->mTitle->quickUserCan( 'edit' ) ) { - // $heading = $this->doEditLink( $item->mTitle, $item->mName ) . $heading; - //} + if ( $this->mShowEditLink && $item->mTitle->quickUserCan( 'edit' ) ) { + $heading = $this->doEditLink( $item->mTitle, $item->mName ) . $heading; + } $heading = Xml::tags( 'h2', null, $heading ); # Sumary entry header. From 8345407a2b0e47511fd3133e64e447feae8243ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sz=C5=91ts=20=C3=81kos?= Date: Wed, 25 Dec 2019 13:18:22 +0100 Subject: [PATCH 8/9] Replace deprecated DB_SLAVE to DB_REPLICA --- WikilogItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WikilogItem.php b/WikilogItem.php index 73400aa..d4fd53c 100644 --- a/WikilogItem.php +++ b/WikilogItem.php @@ -239,7 +239,7 @@ public static function newFromRow( $row ) { $langCode = $item->mTitle->getPageLanguage()->getCode(); if ( strlen($langCode) != 0 && strcmp($langCode, "en") !== 0 ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $displayTitle = $dbr->selectField( 'page_props', 'pp_value', From 98471478141468783dab2f9c909dddc31fe26cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sz=C5=91ts=20=C3=81kos?= Date: Fri, 4 Sep 2020 07:52:21 +0200 Subject: [PATCH 9/9] Revert "Compatibility with Translation extension" This reverts commit 645f1830bc8dfee12374fbfc27ddb3ea1a6d526d. The edit seems to be overall poor quality. It mixes white space, add site-specific changes, comments out code snippets, changes code parts without comments, and breaks title rendering on international wikis. --- Wikilog.php | 6 +++--- WikilogItem.php | 12 ------------ WikilogMainPage.php | 12 +----------- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/Wikilog.php b/Wikilog.php index 08edda6..1196fe2 100644 --- a/Wikilog.php +++ b/Wikilog.php @@ -341,7 +341,7 @@ static function ArticleFromTitle( $title, &$article ) { return true; // continue hook processing if createInstance returned NULL } elseif ( ( $wi = self::getWikilogInfo( $title ) ) ) { if ( $wi->isItem() ) { - $item = WikilogItem::newFromID( $title->getArticleID() ); + $item = WikilogItem::newFromInfo( $wi ); $article = new WikilogItemPage( $title, $item ); } else { $article = new WikilogMainPage( $title, $wi ); @@ -540,7 +540,7 @@ function __construct( $title ) { $tns = MWNamespace::getTalk( $origns ); $parts = explode( '/', $title->getText() ); - if ( count( $parts ) > 1 && (strlen($parts[1]) > 2 || count( $parts ) > 2)) { + if ( count( $parts ) > 1 && ( $this->mIsTalk || count( $parts ) == 2 ) ) { // If title contains a '/', treat as a wikilog article title. $this->mWikilogName = array_shift( $parts ); $this->mItemName = array_shift( $parts ); @@ -549,7 +549,7 @@ function __construct( $title ) { $this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName ); $this->mItemTitle = Title::makeTitle( $ns, $rawtitle ); $this->mItemTalkTitle = Title::makeTitle( $tns, $rawtitle ); - } else { + } elseif ( count( $parts ) == 1 ) { // Title doesn't contain a '/', treat as a wikilog name. $this->mWikilogName = $title->getText(); $this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName ); diff --git a/WikilogItem.php b/WikilogItem.php index d4fd53c..db496a6 100644 --- a/WikilogItem.php +++ b/WikilogItem.php @@ -236,18 +236,6 @@ public static function newFromRow( $row ) { if ( !is_array( $item->mTags ) ) { $item->mTags = array(); } - - $langCode = $item->mTitle->getPageLanguage()->getCode(); - if ( strlen($langCode) != 0 && strcmp($langCode, "en") !== 0 ) { - $dbr = wfGetDB( DB_REPLICA ); - $displayTitle = $dbr->selectField( - 'page_props', - 'pp_value', - array( 'pp_propname' => 'displaytitle', 'pp_page' => $item->mID ), - __METHOD__ - ); - $item->mName = $displayTitle; - } return $item; } diff --git a/WikilogMainPage.php b/WikilogMainPage.php index 2ef0aad..84ff264 100644 --- a/WikilogMainPage.php +++ b/WikilogMainPage.php @@ -62,17 +62,7 @@ public function __construct( &$title, &$wi ) { public function view() { global $wgRequest, $wgOut, $wgMimeType, $wgUser; - $queryTitle; - $parts = explode( '/', $this->mTitle->getText() ); - if (count( $parts ) > 1) { - $origns = $this->mTitle->getNamespace(); - $ns = MWNamespace::getSubject( $origns ); - $queryTitle = Title::makeTitle( $ns, $parts[0] ); - } else { - $queryTitle = $this->mTitle; - } - - $query = new WikilogItemQuery( $queryTitle ); + $query = new WikilogItemQuery( $this->mTitle ); $query->setPubStatus( $wgRequest->getVal( 'show' ) ); # RSS or Atom feed requested. Ignore all other options.