JoelKP has submitted this change and it was merged.

Change subject: update for PhpTags version 5.0.0 Hook release 7 (v 1.4.3)
......................................................................


update for PhpTags version 5.0.0 Hook release 7 (v 1.4.3)

Bug: T97400
Change-Id: I20998b3bf85ebec65b3b18e3a7a62108306f3894
---
M PhpTagsSMW.json
M PhpTagsSMW.php
M includes/InputConverter.php
M includes/SMWExtArrays.php
M includes/SMWExtSQI.php
M includes/SMWWSemanticData.php
6 files changed, 37 insertions(+), 48 deletions(-)

Approvals:
  JoelKP: Verified; Looks good to me, approved



diff --git a/PhpTagsSMW.json b/PhpTagsSMW.json
index 85b4d63..350f939 100644
--- a/PhpTagsSMW.json
+++ b/PhpTagsSMW.json
@@ -49,7 +49,7 @@
                                },
                                "condition": {
                                        "parameters": [
-                                               { "type": "not object", "name": 
"condition" },
+                                               { "type": "nonobject", "name": 
"condition" },
                                                { "type": "scalar", "name": 
"conditionValue", "default": "null" }
                                        ],
                                        "return": "ExtSQI",
@@ -64,7 +64,7 @@
                                },
                                "printout": {
                                        "parameters": [
-                                               { "type": "not object", "name": 
"printout" }
+                                               { "type": "nonobject", "name": 
"printout" }
                                        ],
                                        "return": "ExtSQI",
                                        "desc": "Adds property to be fetched 
and printed out, use * to print out all properties"
@@ -103,7 +103,7 @@
                                "addValue": {
                                        "parameters": [
                                                { "type": "string", "name": 
"property" },
-                                               { "type": "not object", "name": 
"value" }
+                                               { "type": "nonobject", "name": 
"value" }
                                        ],
                                        "desc": "Add a value for a property to 
the current page. $value can be scalar|null, or an array of scalar|null (which 
is converted into a record value string)"
                                },
diff --git a/PhpTagsSMW.php b/PhpTagsSMW.php
index 9e1ccaa..ea39ab0 100644
--- a/PhpTagsSMW.php
+++ b/PhpTagsSMW.php
@@ -16,7 +16,7 @@
        die( 'This file is an extension to MediaWiki and thus not a valid entry 
point.' );
 }
 
-const PHPTAGS_SMW_VERSION = '1.4.2';
+const PHPTAGS_SMW_VERSION = '1.4.3';
 
 // Register this extension on Special:Version
 $wgExtensionCredits['phptags'][] = array(
@@ -41,11 +41,11 @@
        if ( !defined( 'PHPTAGS_VERSION' ) ) {
        throw new MWException( "\n\nYou need to have the PhpTags extension 
installed in order to use the PhpTags SMW extension." );
        }
-       $needVersion = '4.0.2';
+       $needVersion = '5.0.0';
        if ( version_compare( PHPTAGS_VERSION, $needVersion, '<' ) ) {
                throw new MWException( "\n\nThis version of the PhpTags SMW 
extension requires the PhpTags extension $needVersion or above.\n You have " . 
PHPTAGS_VERSION . ". Please update it." );
        }
-       if ( PHPTAGS_HOOK_RELEASE != 6 ) {
+       if ( PHPTAGS_HOOK_RELEASE != 7 ) {
                throw new MWException( "\n\nThis version of the PhpTags SMW 
extension is outdated and not compatible with current version of the PhpTags 
extension.\n Please update it." );
        }
        return true;
diff --git a/includes/InputConverter.php b/includes/InputConverter.php
index 8f2116a..7c9f88b 100644
--- a/includes/InputConverter.php
+++ b/includes/InputConverter.php
@@ -1,7 +1,9 @@
 <?php
 namespace PhpTagsSMW;
 
-use \PhpTagsObjects\SMWWSemanticProperty as WSemanticProperty;
+use PhpTagsObjects\SMWWSemanticProperty as WSemanticProperty;
+
+use PhpTags\HookException;
 
 /**
  * Class for handling conversion of user input, with type and other
@@ -13,12 +15,6 @@
  * @licence GNU General Public Licence 2.0 or later
  */
 class InputConverter {
-
-       /**
-        * Added as a prefix for exception messages.
-        * @var string
-        */
-       protected $callerName;
 
        /**
         * Title instance for the page associated with the values being
@@ -35,19 +31,12 @@
        protected $contextPage = null;
 
        /**
-        * Constructor. The caller name passed should correspond to what
-        * is visible to (and was used by) the PhpTags user.
+        * Constructor.
         *
-        * @param string $callerName
         * @param \Title $title
         */
-       public function __construct( $callerName, \Title $title ) {
-               $this->callerName = $callerName;
+       public function __construct( \Title $title ) {
                $this->title = $title;
-       }
-
-       protected function getCallerPrefix() {
-               return $this->callerName . ': ';
        }
 
        protected function getTitle() {
@@ -61,21 +50,16 @@
                return $this->contextPage;
        }
 
-       protected function makeWarning( $message ) {
-               $message = $this->getCallerPrefix() . $message;
-               return new \PhpTags\HookException( 
\PhpTags\HookException::EXCEPTION_WARNING, $message );
-       }
-
        /**
         * Make a SMWDIProperty instance for a property given as a string.
         * The property string can be a property label, ID, or page name.
         *
-        * Throws a \PhpTags\HookException warning if it is detected that
+        * Throws a HookException warning if it is detected that
         * the property name is invalid.
         *
         * @param string $property Property label, ID, or page name
         * @return \SMWDIProperty
-        * @throws \PhpTags\HookException
+        * @throws HookException
         */
        public function makeDIProperty( $property ) {
                $id = WSemanticProperty::findId( $property );
@@ -83,8 +67,9 @@
                        $dataItem = new \SMWDIProperty( $id );
                } catch ( \SMWDataItemException $e ) {
                        $printName = WSemanticProperty::normalize( $property );
-                       $message = wfMessage( 'smw_noproperty', $printName 
)->inContentLanguage()->text();
-                       throw $this->makeWarning( $message );
+                       throw new HookException(
+                               wfMessage( 'smw_noproperty', $printName 
)->inContentLanguage()->text()
+                       );
                }
                return $dataItem;
        }
@@ -152,7 +137,7 @@
         *
         * @param scalar|null|array $value Value or array of subvalues
         * @return string
-        * @throws \PhpTags\HookException
+        * @throws HookException
         */
        public function makeValueString( $value ) {
                if ( is_array( $value ) ) {
@@ -160,8 +145,9 @@
                        foreach ( $value as $subvalue ) {
                                $substring = $this->convertSingleValue( 
$subvalue );
                                if ( $substring === null ) {
-                                       $message = 'property value must be 
scalar|null or array of scalar|null, array with value of other type given';
-                                       throw $this->makeWarning( $message );
+                                       throw new HookException(
+                                               'property value must be 
scalar|null or array of scalar|null, array with value of other type given'
+                                       );
                                }
                                // Escape value separator before adding
                                $substring = str_replace( ';', '\;', $substring 
);
@@ -175,8 +161,9 @@
                }
                $string = $this->convertSingleValue( $value );
                if ( $string === null ) {
-                       $message = 'property value must be scalar|null or array 
of scalar|null, non-array value of other type given';
-                       throw $this->makeWarning( $message );
+                       throw new HookException(
+                               'property value must be scalar|null or array of 
scalar|null, non-array value of other type given'
+                       );
                }
                return $string;
        }
@@ -204,14 +191,15 @@
         * @param array $userArray
         * @param string $linkbackProperty For use in subobjects
         * @return array Array of property => array( value string, ... )
-        * @throws \PhpTags\HookException
+        * @throws HookException
         */
        public function makeValueAssignmentArray( $userArray, $linkbackProperty 
= '' ) {
                $array = array();
                foreach ( $userArray as $key => $entry ) {
                        if ( !is_string( $key ) ) {
-                               $message = 'value assignment array must contain 
entries with property string keys, array has value with non-string key';
-                               throw $this->makeWarning( $message );
+                               throw new HookException(
+                                       'value assignment array must contain 
entries with property string keys, array has value with non-string key'
+                               );
                        }
                        if ( !is_array( $entry ) ) {
                                $entry = array( $entry );
@@ -246,7 +234,7 @@
         * @param array $valueAssignments
         * @param string $id Optional named identifier for subobject
         * @return \SMW\Subobject
-        * @throws \PhpTags\HookException
+        * @throws HookException
         */
        public function makeSubobject( $valueAssignments, $id = '' ) {
                $subobject = new \SMW\Subobject( $this->getTitle() );
diff --git a/includes/SMWExtArrays.php b/includes/SMWExtArrays.php
index b9445fb..a6b059b 100644
--- a/includes/SMWExtArrays.php
+++ b/includes/SMWExtArrays.php
@@ -1,6 +1,8 @@
 <?php
 namespace PhpTagsObjects;
 
+use PhpTags\HookException;
+
 /**
  * Description of SMWextArray
  *
@@ -15,7 +17,7 @@
         */
        private static function getExtArrays () {
                if ( true !== class_exists( 'ExtArrays', false ) ) {
-                       throw new \PhpTags\HookException( 
\PhpTags\HookException::EXCEPTION_FATAL, wfMessage( 
'phptagssmw-ext-arrays-not-installed' )->text() );
+                       throw new HookException( wfMessage( 
'phptagssmw-ext-arrays-not-installed' )->inContentLanguage()->text(), 
HookException::EXCEPTION_FATAL );
                }
                return \ExtArrays::get( \PhpTags\Runtime::$parser );
        }
diff --git a/includes/SMWExtSQI.php b/includes/SMWExtSQI.php
index a2ceec9..a8450a6 100644
--- a/includes/SMWExtSQI.php
+++ b/includes/SMWExtSQI.php
@@ -1,6 +1,8 @@
 <?php
 namespace PhpTagsObjects;
 
+use PhpTags\HookException;
+
 /**
  * Description of SMWExtSQI
  *
@@ -10,7 +12,7 @@
 
        public function m___construct( $config = null ) {
                if ( false === class_exists( '\\SQI\\SemanticQueryInterface' ) 
) {
-                       throw new \Exception( wfMessage( 
'phptagssmw-ext-sqi-not-installed' )->text() );
+                       throw new HookException( wfMessage( 
'phptagssmw-ext-sqi-not-installed' )->inContentLanguage()->text(), 
HookException::EXCEPTION_FATAL );
                }
                $this->value = new \SQI\SemanticQueryInterface( $config );
                return true;
diff --git a/includes/SMWWSemanticData.php b/includes/SMWWSemanticData.php
index 085fa78..dc0022b 100644
--- a/includes/SMWWSemanticData.php
+++ b/includes/SMWWSemanticData.php
@@ -39,8 +39,7 @@
 
        public static function s_addValue( $property, $value ) {
                $parserData = self::getParserData();
-               $converter = new InputConverter( 'WSemanticData::addValue()',
-                               $parserData->getTitle() );
+               $converter = new InputConverter( $parserData->getTitle() );
                $diProperty = $converter->makeDIProperty( $property );
                $valueString = $converter->makeValueString( $value );
                if ( $valueString === '' ) {
@@ -53,8 +52,7 @@
 
        public static function s_addValues( $valueAssignments ) {
                $parserData = self::getParserData();
-               $converter = new InputConverter( 'WSemanticData::addValues()',
-                               $parserData->getTitle() );
+               $converter = new InputConverter( $parserData->getTitle() );
                $valueAssignments = $converter->makeValueAssignmentArray( 
$valueAssignments );
                foreach ( $valueAssignments as $property => $values ) {
                        $diProperty = $converter->makeDIProperty( $property );
@@ -68,8 +66,7 @@
 
        public static function s_addSubobject( $valueAssignments, $id = '', 
$linkbackProperty = '' ) {
                $parserData = self::getParserData();
-               $converter = new InputConverter( 
'WSemanticData::addSubobject()',
-                               $parserData->getTitle() );
+               $converter = new InputConverter( $parserData->getTitle() );
                $valueAssignments = $converter->makeValueAssignmentArray( 
$valueAssignments, $linkbackProperty );
                $subobject = $converter->makeSubobject( $valueAssignments, $id 
);
                if ( $subobject->getSemanticData()->isEmpty() ) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I20998b3bf85ebec65b3b18e3a7a62108306f3894
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/PhpTagsSMW
Gerrit-Branch: master
Gerrit-Owner: Pastakhov <[email protected]>
Gerrit-Reviewer: JoelKP <[email protected]>
Gerrit-Reviewer: Pastakhov <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to