jenkins-bot has submitted this change and it was merged.
Change subject: Fixed bug when $options array was empty in $select DomElement
at SF_AutoeditAPI.php
......................................................................
Fixed bug when $options array was empty in $select DomElement at
SF_AutoeditAPI.php
Calling count on objects returns 1, so that condition was always true. Instead
the length property needs to be checked.
Change-Id: Ia71ae63297db7cc66fa080213275a0584f905854
---
M includes/SF_AutoeditAPI.php
1 file changed, 5 insertions(+), 2 deletions(-)
Approvals:
Foxtrott: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/SF_AutoeditAPI.php b/includes/SF_AutoeditAPI.php
index da7dafa..ad48526 100644
--- a/includes/SF_AutoeditAPI.php
+++ b/includes/SF_AutoeditAPI.php
@@ -943,11 +943,14 @@
$options = $select->getElementsByTagName( 'option' );
- if ( count( $options ) && (!$select->hasAttribute(
"multiple" ) || $options->item( 0 )->hasAttribute( 'selected' ) ) ) {
+ // if the current $select is a radio button select
(i.e. not multiple)
+ // set the first option to selected as default. This
may be overwritten
+ // in the loop below
+ if ( $options->length > 0 && (!$select->hasAttribute(
'multiple' ) ) ) {
self::addToArray( $data, $name, $options->item(
0 )->getAttribute( 'value' ) );
}
- for ( $o = 1; $o < $options->length; $o++ ) {
+ for ( $o = 0; $o < $options->length; $o++ ) {
if ( $options->item( $o )->hasAttribute(
'selected' ) ) {
if ( $options->item( $o
)->getAttribute( 'value' ) ) {
self::addToArray( $data, $name,
$options->item( $o )->getAttribute( 'value' ) );
--
To view, visit https://gerrit.wikimedia.org/r/53270
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia71ae63297db7cc66fa080213275a0584f905854
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Vedmaka Wakalaka <[email protected]>
Gerrit-Reviewer: Foxtrott <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Vedmaka Wakalaka <[email protected]>
Gerrit-Reviewer: Yaron Koren <[email protected]>
Gerrit-Reviewer: Yury Katkov <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits