Euvl has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/71969


Change subject: added support for synonyms in Semantic Glossary, added .idea to 
gitignore
......................................................................

added support for synonyms in Semantic Glossary, added .idea to gitignore

Change-Id: I5073db166165cc2a5aa2ba66113fc176313efd2d
---
M .gitignore
M SemanticGlossaryBackend.php
M SemanticGlossaryCacheHandling.php
3 files changed, 27 insertions(+), 19 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticGlossary 
refs/changes/69/71969/1

diff --git a/.gitignore b/.gitignore
index 98b092a..da5d6dd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+.idea
 .svn
 *~
 *.kate-swp
diff --git a/SemanticGlossaryBackend.php b/SemanticGlossaryBackend.php
index df29c08..bf92648 100644
--- a/SemanticGlossaryBackend.php
+++ b/SemanticGlossaryBackend.php
@@ -89,12 +89,12 @@
        public function next() {
 
                wfProfileIn( __METHOD__ );
-               $ret = null;
+               static $ret = array();
 
                // find next line
                $page = current( $this->mQueryResults );
 
-               if ( $page ) {
+               if ( $page && count( $ret ) == 0 ) {
 
                        next( $this->mQueryResults );
 
@@ -117,13 +117,6 @@
                                $definitions = 
$this->mStore->getPropertyValues( $page, $this->mDiDefinition );
                                $links = $this->mStore->getPropertyValues( 
$page, $this->mDiLink );
 
-                               if ( empty( $terms ) ) {
-                                       $term = null;
-                               } else {
-                                       $this->mDvTerm->setDataItem( $terms[0] 
);
-                                       $term = 
$this->mDvTerm->getShortWikiText();
-                               }
-
                                if ( empty( $definitions ) ) {
                                        $definition = null;
                                } else {
@@ -138,18 +131,32 @@
                                        $link = 
$this->mDvLink->getShortWikiText();
                                }
 
-                               $ret = array(
-                                       LingoElement::ELEMENT_TERM => $term,
-                                       LingoElement::ELEMENT_DEFINITION => 
$definition,
-                                       LingoElement::ELEMENT_LINK => $link,
-                                       LingoElement::ELEMENT_SOURCE => $page
-                               );
-                               $cache->set( $cachekey, $ret );
-                               wfDebug( "Cached glossary entry $cachekey.\n" );
+                               $tmp_terms = array();
+
+                               if ( !empty( $terms ) ) {
+                                       foreach ( $terms as $term ) {
+                                               $this->mDvTerm->setDataItem( 
$term );
+                                               $tmp_terms[] = 
$this->mDvTerm->getShortWikiText();
+                                       }
+                               }
+
+                               foreach ( $tmp_terms as $tmp_term ) {
+                                               $tmp_ret = array(
+                                                       
LingoElement::ELEMENT_TERM => $tmp_term,
+                                                       
LingoElement::ELEMENT_DEFINITION => $definition,
+                                                       
LingoElement::ELEMENT_LINK => $link,
+                                                       
LingoElement::ELEMENT_SOURCE => $page
+                                               );
+
+                                               $cache->set( $cachekey, 
$tmp_ret );
+                                               wfDebug( "Cached glossary entry 
$cachekey.\n" );
+                                               $ret[] = $tmp_ret;
+                               }
                        }
                }
+
                wfProfileOut( __METHOD__ );
-               return $ret;
+               return array_pop($ret);
        }
 
        /**
diff --git a/SemanticGlossaryCacheHandling.php 
b/SemanticGlossaryCacheHandling.php
index 7e14b2f..96b16df 100644
--- a/SemanticGlossaryCacheHandling.php
+++ b/SemanticGlossaryCacheHandling.php
@@ -36,7 +36,7 @@
                // first handle subobjects recursively
                if ( array_key_exists( '_SOBJ', $properties ) ) {
                        foreach ( $data->getPropertyValues( 
$properties['_SOBJ'] ) as $so ) {
-                               self::purgeCacheForData( $store, 
$so->getSemanticData(), false );
+                               self::purgeCacheForData( $store, 
$store->getSemanticData($so), false );
                        }
                }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/71969
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5073db166165cc2a5aa2ba66113fc176313efd2d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticGlossary
Gerrit-Branch: master
Gerrit-Owner: Euvl <eu.vlase...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to