Yaron Koren has uploaded a new change for review. https://gerrit.wikimedia.org/r/170971
Change subject: Removed dependence on SMW in order to run ...................................................................... Removed dependence on SMW in order to run Change-Id: I3b90c23f10a1465502c537db9eb91125eba34000 --- M SemanticForms.php M includes/SF_FormLinker.php M includes/SF_HelperFormAction.php M includes/SF_TemplateField.php M includes/SF_Utils.php 5 files changed, 29 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms refs/changes/71/170971/1 diff --git a/SemanticForms.php b/SemanticForms.php index 8f19503..c26b3a4 100644 --- a/SemanticForms.php +++ b/SemanticForms.php @@ -44,7 +44,9 @@ define( 'SF_VERSION', '2.8' ); if ( !defined( 'SMW_VERSION' ) ) { - die( "ERROR: <a href=\"http://semantic-mediawiki.org\">Semantic MediaWiki</a> must be installed for Semantic Forms to run!" ); + //die( "ERROR: <a href=\"http://semantic-mediawiki.org\">Semantic MediaWiki</a> must be installed for Semantic Forms to run!" ); + define( 'SF_NS_FORM', 106 ); + define( 'SF_NS_FORM_TALK', 107 ); } $GLOBALS['wgExtensionCredits'][defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'specialpage'][] = array( diff --git a/includes/SF_FormLinker.php b/includes/SF_FormLinker.php index fb2af9a..d170dfb 100644 --- a/includes/SF_FormLinker.php +++ b/includes/SF_FormLinker.php @@ -66,6 +66,10 @@ } $store = SFUtils::getSMWStore(); + if ( $store == null ) { + self::$mLinkedPagesRetrieved = true; + return; + } if ( class_exists( 'SMWDataItem' ) ) { $value = SMWDIWikiPage::newFromTitle( $title ); } else { diff --git a/includes/SF_HelperFormAction.php b/includes/SF_HelperFormAction.php index f41bd4d..5127d4f 100644 --- a/includes/SF_HelperFormAction.php +++ b/includes/SF_HelperFormAction.php @@ -48,8 +48,12 @@ } // Make sure that this page is in one of the relevant // namespaces, and that it doesn't exist yet. + $namespacesWithHelperForms = array( NS_TEMPLATE, SF_NS_FORM, NS_CATEGORY ); + if ( defined( 'SMW_NS_PROPERTY' ) ) { + $namespacesWithHelperForms[] = SMW_NS_PROPERTY; + } if ( !isset( $title ) || - ( !in_array( $title->getNamespace(), array( SMW_NS_PROPERTY, NS_TEMPLATE, SF_NS_FORM, NS_CATEGORY ) ) ) ) { + ( !in_array( $title->getNamespace(), $namespacesWithHelperForms ) ) ) { return true; } if ( $title->exists() ) { diff --git a/includes/SF_TemplateField.php b/includes/SF_TemplateField.php index 07aa000..831a255 100644 --- a/includes/SF_TemplateField.php +++ b/includes/SF_TemplateField.php @@ -64,6 +64,10 @@ } function setTypeAndPossibleValues() { + if ( !defined( 'SMW_NS_PROPERTY' ) ) { + return; + } + // The presence of "-" at the beginning of a property name // (which happens if SF tries to parse an inverse query) // leads to an error in SMW - just exit if that's the case. diff --git a/includes/SF_Utils.php b/includes/SF_Utils.php index f8775a7..077494e 100644 --- a/includes/SF_Utils.php +++ b/includes/SF_Utils.php @@ -81,8 +81,10 @@ if ( class_exists( '\SMW\StoreFactory' ) ) { // SMW 1.9+ return \SMW\StoreFactory::getStore(); - } else { + } elseif ( function_exists( 'smwfGetStore' ) ) { return smwfGetStore(); + } else { + return null; } } @@ -90,6 +92,10 @@ * Helper function to handle getPropertyValues(). */ public static function getSMWPropertyValues( $store, $subject, $propID, $requestOptions = null ) { + // If SMW is not installed, exit out. + if ( !class_exists( 'SMWDIWikiPage' ) ) { + return array(); + } if ( is_null( $subject ) ) { $page = null; } else { @@ -366,6 +372,9 @@ global $sfgMaxAutocompleteValues; $store = SFUtils::getSMWStore(); + if ( $store == null ) { + return array(); + } $requestoptions = new SMWRequestOptions(); $requestoptions->limit = $sfgMaxAutocompleteValues; $values = self::getSMWPropertyValues( $store, null, $property_name, $requestoptions ); @@ -457,6 +466,9 @@ global $sfgMaxAutocompleteValues, $sfgAutocompleteOnAllChars; $store = SFUtils::getSMWStore(); + if ( $store == null ) { + return array(); + } $conceptTitle = Title::makeTitleSafe( SMW_NS_CONCEPT, $conceptName ); -- To view, visit https://gerrit.wikimedia.org/r/170971 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3b90c23f10a1465502c537db9eb91125eba34000 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SemanticForms Gerrit-Branch: master Gerrit-Owner: Yaron Koren <yaro...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits