From: <lph...@us...> - 2013-05-13 16:47:50
|
Revision: 45925 http://sourceforge.net/p/tikiwiki/code/45925 Author: lphuberdeau Date: 2013-05-13 16:47:35 +0000 (Mon, 13 May 2013) Log Message: ----------- [FIX] Support for flagged revisions (multi-document per id) for elasticsearch Modified Paths: -------------- trunk/lib/core/Search/ContentSource/WikiSource.php trunk/lib/core/Search/Elastic/Index.php trunk/lib/wiki/flaggedrevisionlib.php Modified: trunk/lib/core/Search/ContentSource/WikiSource.php =================================================================== --- trunk/lib/core/Search/ContentSource/WikiSource.php 2013-05-13 16:01:18 UTC (rev 45924) +++ trunk/lib/core/Search/ContentSource/WikiSource.php 2013-05-13 16:47:35 UTC (rev 45925) @@ -39,6 +39,10 @@ $info = $this->tikilib->get_page_info($objectId, true, true); + if (! $info) { + return false; + } + $contributors = $wikilib->get_contributors($objectId, $info['user']); if (! in_array($info['user'], $contributors)) { $contributors[] = $info['user']; @@ -46,7 +50,6 @@ $data = array( 'title' => $typeFactory->sortable($info['pageName']), - 'hash' => $typeFactory->identifier($info['version']), 'language' => $typeFactory->identifier(empty($info['lang']) ? 'unknown' : $info['lang']), 'modification_date' => $typeFactory->timestamp($info['lastModif']), 'description' => $typeFactory->plaintext($info['description']), @@ -56,6 +59,7 @@ 'view_permission' => $typeFactory->identifier('tiki_p_view'), 'url' => $typeFactory->identifier($wikilib->sefurl($info['pageName'])), + 'hash' => $typeFactory->identifier(''), ); if ($this->quantifylib) { @@ -79,6 +83,7 @@ $out[] = array_merge( $data, array( + 'hash' => $typeFactory->identifier('latest'), 'title' => $typeFactory->sortable(tr('%0 (latest)', $info['pageName'])), 'view_permission' => $typeFactory->identifier('tiki_p_wiki_view_latest'), 'wiki_approval_state' => $typeFactory->identifier('pending'), @@ -95,7 +100,6 @@ array( 'wiki_content' => $typeFactory->wikitext($versionInfo['data']), 'wiki_approval_state' => $typeFactory->identifier('approved'), - 'hash' => $typeFactory->identifier($versionInfo['version']), ) ); } Modified: trunk/lib/core/Search/Elastic/Index.php =================================================================== --- trunk/lib/core/Search/Elastic/Index.php 2013-05-13 16:01:18 UTC (rev 45924) +++ trunk/lib/core/Search/Elastic/Index.php 2013-05-13 16:47:35 UTC (rev 45925) @@ -30,8 +30,6 @@ $objectType = $data['object_type']->getValue($factory); $objectId = $data['object_id']->getValue($factory); - unset($this->invalidateList[$objectType . ':' . $objectId]); - $this->generateMapping($objectType, $data); $factory = $this->getTypeFactory(); @@ -42,6 +40,13 @@ ); $objectType = $data['object_type']; $objectId = $data['object_id']; + + if (! empty($data['hash'])) { + $objectId .= "~~{$data['hash']}"; + } + + unset($this->invalidateList[$objectType . ':' . $objectId]); + $this->connection->index($this->index, $objectType, $objectId, $data); } Modified: trunk/lib/wiki/flaggedrevisionlib.php =================================================================== --- trunk/lib/wiki/flaggedrevisionlib.php 2013-05-13 16:01:18 UTC (rev 45924) +++ trunk/lib/wiki/flaggedrevisionlib.php 2013-05-13 16:47:35 UTC (rev 45925) @@ -16,6 +16,8 @@ $histlib = TikiLib::lib('hist'); if ($version_info = $histlib->get_version($pageName, $version)) { + $tx = TikiDb::get()->begin(); + if ($prefs['feature_actionlog'] == 'y') { $logslib = TikiLib::lib('logs'); $logslib->add_action(self::ACTION, $pageName, 'wiki page', "flag=$flag&version=$version&value=$value"); @@ -26,6 +28,8 @@ require_once('lib/search/refresh-functions.php'); refresh_index('pages', $pageName); + refresh_index('pages', "$pageName~~latest"); + $tx->commit(); return true; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |