Foxtrott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/93861
Change subject: fix bug (handling of alternate forms with no default form)
......................................................................
fix bug (handling of alternate forms with no default form)
When only "alternate forms", and not a "default form", were specified for a
property in order to generate red links, too many error messages where
displayed.
Basically the reporting level was not accounted for and the fix consists of
only reporting warnings and errors (i.e. no notices and no debug messages).
In addition alternate forms where not taken into account when looking for the
form to use. Now, if exactly one default form or one alternate form is
specified, that form is used. Else an error is thrown.
Change-Id: Ibcfdee695d4498cfcbaf28bdc1a7d78dc88bbee7
---
M includes/SF_AutoeditAPI.php
M specials/SF_FormEdit.php
2 files changed, 17 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms
refs/changes/61/93861/1
diff --git a/includes/SF_AutoeditAPI.php b/includes/SF_AutoeditAPI.php
index ab09538..997dd27 100644
--- a/includes/SF_AutoeditAPI.php
+++ b/includes/SF_AutoeditAPI.php
@@ -115,7 +115,7 @@
try {
$this->doAction();
} catch ( MWException $e ) {
- $this->logMessage( $e->getMessage() );
+ $this->logMessage( $e->getMessage(), $e->getCode() );
}
$this->finalizeResults();
@@ -255,15 +255,22 @@
$formNames = SFFormLinker::getDefaultFormsForPage(
$targetTitle );
- // if no form can be found, give up
+ // if no default form can be found, try alternate forms
if ( count( $formNames ) === 0 ) {
- throw new MWException( wfMessage(
'sf_autoedit_noformfound' )->parse() );
+
+ $formNames =
SFFormLinker::getFormsThatPagePointsTo( $targetTitle->getText(),
$targetTitle->getNamespace(), SFFormLinker::ALTERNATE_FORM );
+
+ // if still no form can be found, give up
+ if ( count( $formNames ) === 0 ) {
+ throw new MWException( wfMessage(
'sf_autoedit_noformfound' )->parse() );
+ }
+
}
- // if more than one form was found, issue a warning and
use the first form
- // FIXME: If we have more than one form, should we stop?
+ // if more than one form was found, issue a notice and
give up
+ // this happens if no default form but several
alternate forms are defined
if ( count( $formNames ) > 1 ) {
- $this->logMessage( wfMessage(
'sf_autoedit_toomanyformsfound' )->parse(), self::WARNING );
+ throw new MWException( wfMessage(
'sf_autoedit_toomanyformsfound' )->parse(), self::NOTICE );
}
$this->mOptions[ 'form' ] = $formNames[ 0 ];
diff --git a/specials/SF_FormEdit.php b/specials/SF_FormEdit.php
index 9d7affa..85c9558 100644
--- a/specials/SF_FormEdit.php
+++ b/specials/SF_FormEdit.php
@@ -109,7 +109,10 @@
if ( array_key_exists( 'errors', $resultData ) ) {
foreach ($resultData['errors'] as $error) {
- $text .= Html::rawElement( 'p', array(
'class' => 'error' ), $error['message'] ) . "\n";
+ // FIXME: This should probably not be
hard-coded to WARNING but put into a setting
+ if ( $error[ 'level' ] <=
SFAutoeditAPI::WARNING ) {
+ $text .= Html::rawElement( 'p',
array( 'class' => 'error' ), $error[ 'message' ] ) . "\n";
+ }
}
}
}
--
To view, visit https://gerrit.wikimedia.org/r/93861
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibcfdee695d4498cfcbaf28bdc1a7d78dc88bbee7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits