Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong values in subfields when value is switched too quickly #61

Open
Rudloff opened this issue Apr 18, 2017 · 4 comments
Open

Wrong values in subfields when value is switched too quickly #61

Rudloff opened this issue Apr 18, 2017 · 4 comments
Labels

Comments

@Rudloff
Copy link
Contributor

Rudloff commented Apr 18, 2017

Soemone reported a very specific issue on one of my wikis.

You can test that here: https://archi-mediawiki.netlib.re/Sp%C3%A9cial:RunQuery/Recherche_avanc%C3%A9e?uselang=fr

  1. Select France in the Pays field.
  2. With the keyboard, use the tab key to select the Ville field.
  3. Quickly type str on your keyboard.

What happens then is that Strasbourg is selected but the Sous-quartier and Rue fields are populated with values from Stosswihr (the value before Strasbourg in the Ville list).
This is probably some kind of race condition because the queries are asynchronous.

I had a hard time reproducing on sandbox because you don't have so many values there, but I think I found a similar issue here: https://sandbox.semantic-mediawiki.org/wiki/Sp%C3%A9cial:RunQuery/Test_keyboard

  1. With the keyboard, use the tab key to select the first field.
  2. Quickly press down then up on your keyboard.

The second field should be empty but it is populated with values from Europe. (Probably because the query for Europe ends after the query for null.)

@kghbln kghbln added the bug label Apr 18, 2017
@kghbln
Copy link
Member

kghbln commented Apr 18, 2017

Thanks a lot for reporting. It is indeed specific but still noteworthy, i.e. worthy for reporting.

Current environment on sandbox:

  • MediaWiki 1.28.1 (819c0d2) 00:51, 7. Apr. 2017
  • PHP 5.6.30-0+deb8u1 (apache2handler)
  • MariaDB 10.0.30-MariaDB-1~jessie
  • Semantic MediaWiki 3.0.0-alpha (aa04827) 09:39, 17. Apr. 2017
  • Semantic Forms Select 2.1.0 (199619f) 12:40, 8. Apr. 2017
  • Page Forms 4.1 (9dde723) 02:11, 3. Apr. 2017

@Rudloff
Copy link
Contributor Author

Rudloff commented May 1, 2017

One way to fix this is to use synchronous queries (so they always complete in the right order):

diff --git a/res/scriptSelect.js b/res/scriptSelect.js
index 00b81ad..9271991 100644
--- a/res/scriptSelect.js
+++ b/res/scriptSelect.js
@@ -253,7 +253,7 @@ function SFSelect_arrayEqual(a, b)
                                        param['approach'] = 'function';
                                }
 
-                               var posting = jQuery.get( mw.config.get('wgScriptPath')  + "/api.php", param );
+                               var posting = jQuery.ajax( mw.config.get('wgScriptPath')  + "/api.php", { data: param, async: false } );
                                posting.done(function( data ) {
                                        // Let's pass values
 

But of course this can cause bad performances.

@kghbln
Copy link
Member

kghbln commented Oct 5, 2018

This issue appears to still be present in the 3.0.0 release.

@toniher A patch was proposed. Perhaps you may have a look into this for the next release.

@toniher
Copy link
Member

toniher commented Oct 14, 2018

@Rudloff @kghbln I wonder how to do this without forcing a synchronous connection... I would try adding a data attribute with a timestamp value to the target HTML element so it should match with the same property value from the resulting data object retrieved from the post query in order to allow its modification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants