Physikerwelt has uploaded a new change for review. https://gerrit.wikimedia.org/r/106117
Change subject: add type hinting and error handing to workload generator ...................................................................... add type hinting and error handing to workload generator Change-Id: I7fae16b00b635fa91e40f8426f995a25fd2bcf07 --- M MathObject.php M MathQueryObject.php M maintenance/GenerateWorkload.php 3 files changed, 11 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch refs/changes/17/106117/1 diff --git a/MathObject.php b/MathObject.php index 1c683d3..a4bcc09 100644 --- a/MathObject.php +++ b/MathObject.php @@ -44,7 +44,7 @@ /** * - * @global type $wgMathDebug + * @global ResultWrapper $wgMathDebug * @param type $res * @return boolean|\self */ @@ -55,7 +55,7 @@ $instance = new $class; $instance->setPageID( $res->mathindex_page_id ); $instance->setAnchorID( $res->mathindex_anchor ); - if ( $wgMathDebug ) { + if ( $wgMathDebug && isset($res->mathindex_timestamp) ) { $instance->index_timestamp = $res->mathindex_timestamp; } $instance->inputHash = $res->mathindex_inputhash; diff --git a/MathQueryObject.php b/MathQueryObject.php index 77520b1..88ee7df 100644 --- a/MathQueryObject.php +++ b/MathQueryObject.php @@ -37,7 +37,7 @@ /** * - * @param type $rpage + * @param ResultWrapper $rpage * @param int $queryID * @return \self */ @@ -94,8 +94,11 @@ } public function serlializeToXML( ){ $cx = simplexml_load_string($this->getCQuery()); - $xCore = preg_replace("/\\n/","\n\t\t", $cx->children('mws',TRUE)->children('m',TRUE)->asXML()); $px = simplexml_load_string($this->getPQuery()); + if ( $cx == false || $px == false ){ + return false; + } + $xCore = preg_replace("/\\n/","\n\t\t", $cx->children('mws',TRUE)->children('m',TRUE)->asXML()); $pmml = preg_replace('#<mi (.*) mathcolor="red">(.*)</mi>#', '<mws:qvar xmlns:mws="http://www.mathweb.org/mws/ns" name="$2"/>', $px->children()->asXML())."\n"; diff --git a/maintenance/GenerateWorkload.php b/maintenance/GenerateWorkload.php index 0bfd57a..39d88cd 100644 --- a/maintenance/GenerateWorkload.php +++ b/maintenance/GenerateWorkload.php @@ -37,6 +37,10 @@ protected function generateIndexString( $row ){ $q = MathQueryObject::newQueryFromEquationRow($row, ++$this->id ); $out = $q->serlializeToXML(); + if( $out == false ){ + echo 'problem with '.var_export($q,true)."\n"; + $out = ''; + } return $out; } -- To view, visit https://gerrit.wikimedia.org/r/106117 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7fae16b00b635fa91e40f8426f995a25fd2bcf07 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MathSearch Gerrit-Branch: master Gerrit-Owner: Physikerwelt <w...@physikerwelt.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits