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

Filtered format breaks with properties of type:page #568

Closed
krabina opened this issue Feb 24, 2020 · 28 comments · Fixed by #686
Closed

Filtered format breaks with properties of type:page #568

krabina opened this issue Feb 24, 2020 · 28 comments · Fixed by #686
Assignees
Labels

Comments

@krabina
Copy link
Contributor

krabina commented Feb 24, 2020

Setup

  • MW version: 1.31.6
  • DB (MySQL etc.): 10.3.22-MariaDB
  • PHP version: 7.2.14 (fpm-fcgi)
  • SMW version: 3.1.4
  • SRF version: 3.1.0
  • Browsers and versions (if applicable): FF and Chrome, latest versions

Issue

Filtered format show the blue "loading" icon and never finishes if a property of type page is in the query.

Reproducing

  1. Create a simple ask query for properties NOT of type page.
  2. format filtered works
  3. change property type of one of the selected properties in the printout to type page
  4. result: filtered format breaks
  5. now change format=filtered to something else, e. g. fomat=table and you will see the query results with no problems.

Errors

Console shows:

Mixed Content: The page at '<URL>' was loaded over HTTPS, but requested an insecure script '<URL>'. This request has been blocked; the content must be served over HTTPS.
Filtered-Test?debug=true:1 Mixed Content: The page at ../Filtered-Test?debug=true' was loaded over HTTPS, but requested an insecure script ..Vendor/onoi/shared-resources/res/localForage/localforage.min.js'. This request has been blocked; the content must be served over HTTPS.
Filtered-Test?debug=true:1 Mixed Content: The page at '../Filtered-Test?debug=true' was loaded over HTTPS, but requested an insecure script '../Vendor/onoi/shared-resources/res/md5/jquery.md5.js'. This request has been blocked; the content must be served over HTTPS.
Filtered-Test?debug=true:1 Mixed Content: The page at '../Filtered-Test?debug=true' was loaded over HTTPS, but requested an insecure script '../Vendor/onoi/shared-resources/res/jquery.qtip/extended/jquery.qtip.js'. This request has been blocked; the content must be served over HTTPS.
Filtered-Test?debug=true:1 Mixed Content: The page at '../Filtered-Test?debug=true' was loaded over HTTPS, but requested an insecure script '../Vendor/onoi/shared-resources/res/onoi.blobstore.js'. This request has been blocked; the content must be served over HTTPS.
Filtered-Test?debug=true:1 Mixed Content: The page at '../Filtered-Test?debug=true' was loaded over HTTPS, but requested an insecure script '../Vendor/onoi/shared-resources/res/onoi.util.js'. This request has been blocked; the content must be served over HTTPS.
Filtered-Test?debug=true:1 Mixed Content: The page at '../Filtered-Test?debug=true' was loaded over HTTPS, but requested an insecure stylesheet '../Vendor/onoi/shared-resources/res/onoi.util.css'. This request has been blocked; the content must be served over HTTPS.
ext.summaryCards.js?99f7e:456 Uncaught ReferenceError: onoi is not defined
    at ext.summaryCards.js?99f7e:456
Filtered-Test?debug=true:1 Mixed Content: The page at '../Filtered-Test?debug=true' was loaded over HTTPS, but requested an insecure stylesheet '../Vendor/onoi/shared-resources/res/jquery.qtip/extended/jquery.qtip.css'. This request has been blocked; the content must be served over HTTPS.
Filtered-Test?debug=true:1 Mixed Content: The page at '../Filtered-Test?debug=true' was loaded over HTTPS, but requested an insecure stylesheet '../Vendor/onoi/shared-resources/res/onoi.util.css'. This request has been blocked; the content must be served over HTTPS.
@krabina
Copy link
Contributor Author

krabina commented Feb 24, 2020

When trying to reproduce it in sandbox, first both did not work at all

Then I figured that if you hit ctrl+F5 (clearing cache in FF) resolves the problem. However, after saving the page it was there again and you have to clear the cache every time.

Now both 568 and 246 seem to work, but older veresions of 568 still don't:
https://sandbox.semantic-mediawiki.org/w/index.php?title=Issue/SRF/568&oldid=46347

@kghbln kghbln added the bug label Feb 24, 2020
@kghbln
Copy link
Member

kghbln commented Feb 24, 2020

Mixed Content: The page at '' was loaded over HTTPS, but requested an insecure script ''. This request has been blocked; the content must be served over HTTPS.

I wonder why we are getting mixed content warnings here.

@krabina
Copy link
Contributor Author

krabina commented Feb 24, 2020

Please forget my stacktrace. I have the feeling it has more to do with Summary Cards extension. I de-installed this one.

Currently, when I use format=table or format=filtered on a test page and add &debug=true, both output the same three warnings and no errors:

DevTools failed to parse SourceMap: ../extensions/Bootstrap/resources/bootstrap/js/popper.js.map
DevTools failed to parse SourceMap: ../extensions/SemanticMediaWiki/res/libs/tippy/popper.min.js.map
DevTools failed to parse SourceMap: ../extensions/SemanticMediaWiki/res/libs/tippy/index.js.map

I also tried to rebuild all data in SMW with no effect.

@kghbln
Copy link
Member

kghbln commented Feb 25, 2020

Please forget my stacktrace. I have the feeling it has more to do with Summary Cards extension. I de-installed this one.

Just to make sure. This was not a stack trace from sandbox. If it was we need to create an issue with Summary Cards.

@krabina
Copy link
Contributor Author

krabina commented Feb 25, 2020

no, it was from my testwiki.
I will try to see if re-installing SummaryCards will show up these problems and then will file a bug report there.

More important for me at the moment is this issue....

@kghbln
Copy link
Member

kghbln commented Feb 25, 2020

no, it was from my testwiki.

Thanks for confirming.

I will try to see if re-installing SummaryCards will show up these problems and then will file a bug report there.

Cool. Make sure to make the website HTTPS only for best test results.

More important for me at the moment is this issue....

No objection at all. :)

@krabina
Copy link
Contributor Author

krabina commented Mar 5, 2020

short update: I did everything described here: https://www.semantic-mediawiki.org/wiki/Help:Repairing_SMW%27s_data#Rebuilding_everything

and deactivated every extension except SMW and SRF.

Still no luck...

@krabina
Copy link
Contributor Author

krabina commented Mar 5, 2020

A working filtered list shows this in the sourcode with ?debug=true

 "srfFilteredConfig": {
        "gcja438f1c": {
            "query": "[[Kategorie:Expertinnen und Experten]]",
            "printrequests": {
                "dhyp4unk2a880k4w8gc04c0co": {
                    "mode": 2,
                    "label": "",
                    "outputformat": false,
                    "type": "_wpg"
                },
                "72mo4x0s0ps0owo4gcgo8go80": {
                    "mode": 1,
                    "label": "Geschlecht",
                    "outputformat": "-",
                    "type": "_txt",
                    "property": "Geschlecht"
                },
                "d0vm12nhw7scs4sogks48gsw": {
                    "mode": 1,
                    "label": "Wirkungsraum",
                    "outputformat": "-",
                    "type": "_txt",
                    "property": "Wirkungsraum"
                },
                "ajfcz5wlgxs08gg4okc8go8ok": {
                    "mode": 1,
                    "label": "Position",
                    "outputformat": "-",
                    "type": "_txt",
                    "property": "Position"
                }
            },
            "views": {
                "gcja438aks": {
                    "type": "table"
                }
            },

As soon as I add one printout of a property of type Page, this is missing in the source code and that's why the blue icon does not stop and no results are displayed.

@gesinn-it-gea
Copy link
Member

Any JS errors?

@krabina
Copy link
Contributor Author

krabina commented Mar 18, 2020

no.

@krabina
Copy link
Contributor Author

krabina commented Mar 19, 2020

Here are some warning messages that appear:

Source-Map-Fehler: Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Ressourcen-Adresse: ../extensions/SemanticMediaWiki/res/libs/tippy/popper.min.js?74d0b Source-Map-Adresse: popper.min.js.map
Source-Map-Fehler: Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Ressourcen-Adresse: ../extensions/SemanticMediaWiki/res/libs/tippy/tippy.js?e5280
Source-Map-Adresse: index.js.map
Laden fehlgeschlagen für das <script> mit der Quelle "../extensions/SemanticMediaWiki/res/smw/data/ext.smw.dataItem.wikiPage.js?5bdf7". index.php:1:1
Laden fehlgeschlagen für das <script> mit der Quelle "../extensions/SemanticMediaWiki/res/smw/data/ext.smw.dataItem.uri.js?944c2". index.php:1:1
Laden fehlgeschlagen für das <script> mit der Quelle "../extensions/SemanticMediaWiki/res/smw/data/ext.smw.dataItem.time.js?ea817". index.php:1:1
Laden fehlgeschlagen für das <script> mit der Quelle "../extensions/SemanticMediaWiki/res/smw/data/ext.smw.dataItem.property.js?eaf65". index.php:1:1
Laden fehlgeschlagen für das <script> mit der Quelle "../extensions/SemanticMediaWiki/res/smw/data/ext.smw.dataItem.unknown.js?36eef". index.php:1:1
Laden fehlgeschlagen für das <script> mit der Quelle "../extensions/SemanticMediaWiki/res/smw/data/ext.smw.dataItem.number.js?a7ed6". index.php:1:1
Laden fehlgeschlagen für das <script> mit der Quelle "../extensions/SemanticMediaWiki/res/smw/data/ext.smw.dataItem.text.js?951c9". index.php:1:1
Laden fehlgeschlagen für das <script> mit der Quelle "../extensions/SemanticMediaWiki/res/smw/data/ext.smw.dataItem.geo.js?920cc". index.php:1:1
Laden fehlgeschlagen für das <script> mit der Quelle "../extensions/SemanticMediaWiki/res/smw/data/ext.smw.dataValue.quantity.js?98b3c". index.php:1:1
Laden fehlgeschlagen für das <script> mit der Quelle "./extensions/SemanticMediaWiki/res/smw/data/ext.smw.data.js?51da0".

"Laden fehlgeschlagen.." = "Loading failed for the script..."

@krabina
Copy link
Contributor Author

krabina commented Mar 29, 2020

another hint in yet another installation (bitami mediawiki in AWS):

SyntaxError: expected expression, got ';'Projects:6:54

row 6 is
<script>document.documentElement.className="client-js";RLCONF=;RLSTATE={"site.styles":"ready","noscript":"ready","user.styles":"ready","user":"ready","user.options":"ready","user.tokens":"loading","mediawiki.legacy.commonPrint":"ready","jquery.tablesorter.styles":"ready","mediawiki.skinning.content":"ready","zzz.ext.bootstrap.styles":"ready","ext.srf.styles":"ready","ext.smw.style":"ready","ext.smw.tooltip.styles":"ready"};RLPAGEMODULES=["ext.smw.style","ext.smw.tooltips","ext.srf.filtered.value-filter","ext.srf.filtered.number-filter","ext.srf.filtered.map-view","ext.srf.filtered","site","mediawiki.page.startup","mediawiki.page.ready","jquery.tablesorter","mediawiki.searchSuggest","mediawiki.page.watch.ajax","ext.bootstrap.scripts","ext.smw.purge"];</script>

row 54 is the end of "client-js"

If I remove the only property "Organizer" of the query that is of type page, it works and this error does not show up.

MediaWiki 1.34.1
PHP 7.3.16 (fpm-fcgi)
MySQL 8.0.18
ICU 66.1

@JeroenDeDauw
Copy link
Member

JeroenDeDauw commented Apr 7, 2020

I looked into this a bit and while I did not find the root cause or fix yet, here are some findings already.

The bug

  • only happens when values of type page are present
  • does not happen when none of the pages have a value for the property of type page
  • happens when there is a single value of type page and when all result rows have one
  • happens both for values pointing to existing pages and for redlinks

The non-working pages missing srfFilteredConfig in the page output is very likely what is causing the loading to fail. Unfortunately I cannot reproduce this on my wiki, which makes it very hard to track down further.

image

My guess is that something is going wrong with the $config variable before it gets to this point: https://github.com/SemanticMediaWiki/SemanticResultFormats/blob/3.1.0/formats/filtered/src/Filtered.php#L209 It's surprising there is no error though. It'd be good to inspect and see what value $config has on the broken pages.

I doubt this has anything to do with PHP version or browser. I also doubt the issue lies in the client side, so think the JS console stuff posted so far is not relevant at this point.

JeroenDeDauw added a commit that referenced this issue Apr 7, 2020
@JeroenDeDauw
Copy link
Member

@krabina I don't know what debug config you have in your LocalSettings.php file. Perhaps no error is shown because it is being hidden by MW. You could try adding the following:

error_reporting( -1 );
ini_set( 'display_errors', '1' );

$wgShowSQLErrors = true;
$wgDebugDumpSql  = true;
$wgShowDBErrorBacktrace = true;
$wgDebugToolbar = true;
$wgShowDebug = true;
$wgShowExceptionDetails = true;

Don't do that on a production wiki though, especially not for a longer period, as this is bad for security.

@JeroenDeDauw
Copy link
Member

I narrowed down the problem. It is coming from SMWs getSortKey method on DataItem and can be avoided with this change d061308

This method, for whatever reason, is returning text with messed up enconding. Which then causes the whole $config array to not be output to the page. Example:

image

Good chance that this is a server specific issue, with the root cause being some config or database issue. Bit weird the messed up encoding is just showing up here though.

@mwjames
Copy link
Contributor

mwjames commented Apr 9, 2020 via email

@krabina
Copy link
Contributor Author

krabina commented Apr 9, 2020

hmm. Indeed my settings are

$wgCategoryCollation = "uca-de-u-kn";
$smwgEntityCollation = "uca-de-u-kn";

as I thought they should be in a German language installation.

And indeed, in a wiki where the problem did not show, I did not have these set. After setting them and performing
updateEntityCollation.php
the problem now is showing up.

The reverse is also true: if I remove those settings and do a
updateEntityCollation.php
then the problem goes away.

So now the question remains, how to set it up correctly for a German (or other) language installation. I'd like the list of pages get sorted correctly...

@kghbln
Copy link
Member

kghbln commented Apr 9, 2020

MediaWiki sets: $wgCategoryCollation = 'uppercase'; and so does German Wikipedia. On a German language instance I'd stick to what Wikipedia does for de.

@krabina
Copy link
Contributor Author

krabina commented Apr 9, 2020

I disagree. I couldn't care less what the German Wikipedia does. In an enterprise Wiki, I need the sorting to be as user-friendly as it can get and since this great option is there, I see it as a great opportunity to have correct sorting in any language.

You do realize, that I as Austrian did not set de-AT@collation=phonebook ;-)
(Which is even more preferrable. I think I tried it out at some point but it did not work.)

@krabina
Copy link
Contributor Author

krabina commented Apr 9, 2020

btw. at least numeric as setting works also, but as soon as you use a uca collation, it fails.

@mwjames
Copy link
Contributor

mwjames commented Apr 11, 2020

btw. at least numeric as setting works also, but as soon as you use a uca collation, it fails.

Of course, because numeric has nothing to do with the UCA.

UCA (Unicode collation algorithm) represents a sorting string of calculated codepoints that may contain "invalid" characters [0] due to UCA using a larger UTF (most common UTF-8, UTF-16, UTF-32 [1]) encoding set to build a sort string (see the provided link for more information about UCA). In case the JS cannot deal with those character representations, you need to transform the sort string into something that is UTF-8 safe which can be done in PHP via $sort = json_encode( $sort, JSON_INVALID_UTF8_SUBSTITUTE ) (only PHP 7.2+) or $sort = mb_convert_encoding( $sort, 'UTF-8', 'UTF-8' ); it goes without saying that you are loosing some information about the sorting string but it is surely better than to assume a non UCA sort specially for those items where lexicographic sorting is bound to language dependent rule sets.

[0] https://stackoverflow.com/questions/1301402/example-invalid-utf8-string
[1] https://en.wikipedia.org/wiki/Comparison_of_Unicode_encodings

@krabina
Copy link
Contributor Author

krabina commented Apr 21, 2020

Why is this closed? I interpret the comment of @mwjames that some transformaton needs to be done in JavaScript. Adding smwgEntityCollation to the upgrade key matrix is nice, but does not help, since my settings were not incorrect and I did run both update-scripts after changing the collation.

IMO it is still a bug that if you set the collation to UCA (a documented feature) the filtered format cannot handle it correctly.

@JeroenDeDauw JeroenDeDauw reopened this Apr 21, 2020
@JeroenDeDauw
Copy link
Member

My bad. I did not realize further discussion had happened and was under the impression the root cause was unsupported config.

@D-Groenewegen
Copy link
Contributor

SMW 3.1.6 + SRF 3.1.0

Thanks @krabina. I may have the same 'spinning wheel in perpetual motion' problem, although removing properties of type page does not help here. Nothing to see in the console or error reporting messages.

@krabina
Copy link
Contributor Author

krabina commented Aug 28, 2020

did you check your collation settings? the bug goes away if you don't use UCA collation...

@D-Groenewegen
Copy link
Contributor

Atm, I can't test this I'm afraid. Uca collation is essential to the website and in the absence of a staging environment, I don't have the luxury position where I can simply switch it on and off. It's not a trivial thing either.

@gesinn-it-gea
Copy link
Member

we need to make sure to get this covered by tests

gesinn-it-gea pushed a commit that referenced this issue Nov 23, 2021
* Added failing test for #568 (filtered format breaks for UCA collations)
* Fix filtered format for UCA collations

The sort key provided in the UCA case is not to be interpreted as string but as a byte array. To make it JSON serializable, convert it to hexadecimal representation as intended for sorting.

* Removed MW-1.31 from CI matrix (according to #682)
@krabina
Copy link
Contributor Author

krabina commented Nov 23, 2021

I looked into this and was able to reproduce the bug in MW 1.35. Upgrading to the latest dev-master of SRF fixes the issue!
Thank you @gesinn-it-gea!!

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

Successfully merging a pull request may close this issue.

7 participants