r36151 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36150‎ | r36151 | r36152 >
Date:14:58, 10 June 2008
Author:mkroetzsch
Status:old
Tags:
Comment:
Fix: always ignore spaces before delimters (only spaces after delimiters might be interesting for escaping)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -537,6 +537,8 @@
538538 } else {
539539 $this->updateRedirects($subject->getDBKey(),$subject->getNamespace());
540540 }
 541+ // always make an ID (pages without ID cannot be in qurey results, not even in fixed value queries!):
 542+ $sid = $this->makeSMWPageID($subject->getDBkey(),$subject->getNamespace(),'');
541543 $db =& wfGetDB( DB_MASTER );
542544
543545 // do bulk updates:
@@ -552,17 +554,16 @@
553555 if ($value->isValid()) {
554556 if ($value->getTypeID() == '_txt') {
555557 $up_text2[] =
556 - array( 's_id' => $this->makeSMWPageID($subject->getDBkey(),$subject->getNamespace(),''),
 558+ array( 's_id' => $sid,
557559 'p_id' => $this->makeSMWPageID($property->getDBkey(),SMW_NS_PROPERTY,''),
558560 'value_blob' => $value->getXSDValue() );
559561 } elseif ($value->getTypeID() == '_wpg') {
560562 $up_rels2[] =
561 - array( 's_id' => $this->makeSMWPageID($subject->getDBkey(),$subject->getNamespace(),''),
 563+ array( 's_id' => $sid,
562564 'p_id' => $this->makeSMWPageID($property->getDBkey(),SMW_NS_PROPERTY,''),
563565 'o_id' => $this->makeSMWPageID($value->getDBkey(),$value->getNamespace(),'') );
564566 $oid = $value->getArticleID();
565567 } elseif ($value->getTypeID() == '__nry') {
566 - $sid = $this->makeSMWPageID($subject->getDBkey(),$subject->getNamespace(),'');
567568 $bnode = $this->makeSMWBnodeID($sid);
568569 $up_rels2[] =
569570 array( 's_id' => $sid,
@@ -600,7 +601,7 @@
601602 }
602603 } else {
603604 $up_atts2[] =
604 - array( 's_id' => $this->makeSMWPageID($subject->getDBkey(),$subject->getNamespace(),''),
 605+ array( 's_id' => $sid,
605606 'p_id' => $this->makeSMWPageID($property->getDBkey(),SMW_NS_PROPERTY,''),
606607 'value_unit' => $value->getUnit(),
607608 'value_xsd' => $value->getXSDValue(),
@@ -618,7 +619,7 @@
619620 foreach($propertyValueArray as $value) {
620621 if ( $value->getNamespace() == NS_CATEGORY ) {
621622 $up_inst2[] =
622 - array('s_id' => $this->makeSMWPageID($subject->getDBkey(),$subject->getNamespace(),''),
 623+ array('s_id' => $sid,
623624 'o_id' => $this->makeSMWPageID($value->getDBkey(),$value->getNamespace(),''));
624625 }
625626 }
@@ -631,7 +632,7 @@
632633 foreach($propertyValueArray as $value) {
633634 if ( $value->getNamespace() == $namespace ) {
634635 $up_subs2[] =
635 - array('s_id' => $this->makeSMWPageID($subject->getDBkey(),$subject->getNamespace(),''),
 636+ array('s_id' => $sid,
636637 'o_id' => $this->makeSMWPageID($value->getDBkey(),$value->getNamespace(),''));
637638 }
638639 }
@@ -642,7 +643,7 @@
643644 $stringvalue = $value->getXSDValue();
644645 }
645646 $up_spec2[] =
646 - array('s_id' => $this->makeSMWPageID($subject->getDBkey(),$subject->getNamespace(),''),
 647+ array('s_id' => $sid,
647648 'sp_id' => $property,
648649 'value_string' => $stringvalue);
649650 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
@@ -922,7 +922,7 @@
923923 if ($stoppattern == '') {
924924 $stoppattern = '\[\[|\]\]|::|:=|<q>|<\/q>|^' . $this->m_categoryprefix . '|\|\||\|';
925925 }
926 - $chunks = preg_split('/(' . $stoppattern . ')/u', $this->m_curstring, 2, PREG_SPLIT_DELIM_CAPTURE);
 926+ $chunks = preg_split('/[\s]*(' . $stoppattern . ')/u', $this->m_curstring, 2, PREG_SPLIT_DELIM_CAPTURE);
927927 if (count($chunks) == 1) { // no matches anymore, strip spaces and finish
928928 if ($consume) {
929929 $this->m_curstring = '';

Status & tagging log