Robert Vogel has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/365575 )
Change subject: BSExtendedSearch: Unified access to file object
......................................................................
BSExtendedSearch: Unified access to file object
... on index update.
Also fixed hook signature for "TitleMoveComplete".
See ERM6670 for details.
Change-Id: I6e07f31cbcc861364eaeb7689de40a02150c0a4c
---
M ExtendedSearch/ExtendedSearch.class.php
M PageAssignments/includes/PageAssignmentsNotificationHooks.php
2 files changed, 24 insertions(+), 10 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions
refs/changes/75/365575/1
diff --git a/ExtendedSearch/ExtendedSearch.class.php
b/ExtendedSearch/ExtendedSearch.class.php
index ffa4ddd..2a36062 100644
--- a/ExtendedSearch/ExtendedSearch.class.php
+++ b/ExtendedSearch/ExtendedSearch.class.php
@@ -414,11 +414,8 @@
//in turn means that we need to update the index entry
of the file
//with the new categories
if ( $oTitle->getNamespace() === NS_FILE ) {
- $oFile = wfFindFile( $oTitle );
- if( !$oFile ) {
- $oFile = LocalFile::newFromTitle(
$oTitle, RepoGroup::singleton()->getLocalRepo() );
- if ( !$oFile ) return true;
- }
+ $oFile = $this->getFileByTitle( $oTitle );
+
//Unfortunately
BuildIndexMwSingleFile::indexCrawledDocuments
//checks if the file is already on the index.
If so it does not
//apply the update. To have our categories be
written to the
@@ -458,7 +455,7 @@
* @param int $iNewID ID of the newly created redirect.
* @return bool allow other hooked methods to be executed. Always true.
*/
- public function onTitleMoveComplete( &$oTitle, &$oNewtitle, &$oUser,
$iOldID, $iNewID ) {
+ public function onTitleMoveComplete( &$oTitle, &$oNewtitle, $oUser,
$iOldID, $iNewID ) {
try {
// Moving article
BuildIndexMainControl::getInstance()->updateIndexWikiByTitleObject( $oNewtitle
);
@@ -468,8 +465,8 @@
}
// Moving file if namespace of title is the file
namespace
if ( $oTitle->getNamespace() == NS_FILE ) {
- $oOldFile = LocalFile::newFromTitle( $oTitle,
RepoGroup::singleton()->getLocalRepo() );
- $oNewFile = RepoGroup::singleton()->findFile(
$oNewtitle );
+ $oOldFile = $this->getFileByTitle( $oTitle );
+ $oNewFile = $this->getFileByTitle( $oNewtitle );
BuildIndexMainControl::getInstance()->deleteIndexFile( $oOldFile->getPath(),
'repo' );
BuildIndexMainControl::getInstance()->updateIndexFile( $oNewFile );
@@ -524,7 +521,7 @@
*/
public function onFileUndeleteComplete( $oTitle, $aFileVersions,
$oUser, $sReason ) {
try {
- $oFile = wfFindFile( $oTitle );
+ $oFile = $this->getFileByTitle( $oTitle );
BuildIndexMainControl::getInstance()->updateIndexFile(
$oFile );
} catch ( BsException $e ) {
wfDebugLog( 'ExtendedSearch', 'onFileUndeleteComplete:
'.$e->getMessage() );
@@ -609,4 +606,21 @@
$aHandlers['searchstats'] = array( 'class' =>
'TagCloudSearchStatsHandler' );
return true;
}
+
+ /**
+ * Tries to create a File object from a Title object
+ * @param Title $oTitle
+ * @throws Exception
+ * @return File|boolean
+ */
+ protected function getFileByTitle( $oTitle ) {
+ $oFile = RepoGroup::singleton()->findFile( $oTitle );
+ if( !$oFile ) {
+ $oFile = LocalFile::newFromTitle(
+ $oTitle, RepoGroup::singleton()->getLocalRepo()
+ );
+ }
+ return $oFile;
+ }
+
}
diff --git a/PageAssignments/includes/PageAssignmentsNotificationHooks.php
b/PageAssignments/includes/PageAssignmentsNotificationHooks.php
index dd6c844..e551360 100644
--- a/PageAssignments/includes/PageAssignmentsNotificationHooks.php
+++ b/PageAssignments/includes/PageAssignmentsNotificationHooks.php
@@ -172,7 +172,7 @@
* @param int $newid
* @return boolean
*/
- public static function onTitleMoveComplete( &$title, &$newtitle,
&$user, $oldid, $newid ) {
+ public static function onTitleMoveComplete( &$title, &$newtitle, $user,
$oldid, $newid ) {
PageAssignmentsNotificationHooks::notify(
'bs-pageassignments-page-move',
$user,
--
To view, visit https://gerrit.wikimedia.org/r/365575
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e07f31cbcc861364eaeb7689de40a02150c0a4c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits