RM 2.2 XFRM - Loading modal window - critical error

Sado Yasashii

Active member
Hello.

Please pay attention!

When downloading files, most often 7z, rar, esp, esm etc. (any formats not listed in the XF), an error appears that it can not download and displays a message:
Oops! We ran into some problems.
Oops! We ran into some problems. Please try again later. More error details may be in the browser console.
Screen Shot 05-25-22 at 02.29 PM.JPG

The problem is not related to the work of the hosting/VPS - it is related to the work of the JavaScript code of the site (its execution does not depend on the server, JavaScript is executed on the user's computer). If you turn off JavaScript execution in your browser, the downloading starts, the video is available:
View attachment raidgame_net_jsdisabled.mov

If you look at the source code of the site (the code of the "Download" button), you can see that on the working page it looks like: (Example from my working forum)
Code:
<a href="/mods/poleznye-zaklinanija-utility-spells-uts.319/download" class="button--cta button--fullWidth button button--icon button--icon--download" target="_blank"><span class="button-text">Скачать
(<strong>5,8 МБ</strong> / <em>7z</em>)
</span></a>

On pages that are not working it looks like this: (Example from my working forum)
Code:
<a href="/mods/ragdolls.66/download" class="button--cta button--fullWidth button button--icon button--icon--download" target="_blank" data-xf-click="overlay"><span class="button-text">Скачать
  (<strong>1,4 МБ</strong> / <em>7z</em>)
</span></a>

In the second case, there is the parameter data-xf-click="overlay", which is processed by the browser and causes some JavaScript code to be executed.
Where the most important thing here is the data-xf-click="overlay" attribute.
By setting this attribute to an element that has an href (link), XF will automatically query the response to the link address asynchronously and show the result in a modal window.

It turns out that on pages where the file is not downloaded, the binary code of this file tries to be displayed through a modal window, and an error occurs. To solve this problem you need a fix from the developer.

From the UH Team came a proposal to solve the current problem through a template modifier:

Template: xfrm_resource_wrapper_macros
Modification key: remove_data_xf_click
Find:
data-xf-click="{{ $resource.CurrentVersion.file_count > 1 ? 'overlay' : '' }}"
Replace:
Empty

The solution removes the display of a modal window when downloading. If there is more than one file, it opens a new tab for downloading. This does not solve the problem of displaying a modal window, the problem is at the level of JavaScript. Let's hope you fix it.:)
 
Last edited:
The download button should only open an overlay when a resource has multiple files attached, and should display a file selector:
1669870739863.png


Does the resource in question have multiple files attached? And you reproduce this when creating new resources on a default style with all add-ons disabled?
 
When downloading files, most often 7z, rar, esp, esm etc. (any formats not listed in the XF), an error appears that it can not download. It appears after some time. At the same time in the resource only one file. If I add 2 or more, the result is the same. When creating a new resource, the error does not appear immediately.

The problem was tested on a clean installation with a single XFRM plugin on a default style. How the error is manifested, I showed you visually.
The XF console does not respond to the error in any way. Only the browser reacts to it. The problem is in JS. What exactly it doesn't like, that's what we need to find out.
 
Last edited:
As you noted, I have registered today. You said I may not be able to reproduce the issue yet, but I can.


This is the resource where I can see it.

The issue quite simply is something in the template that has changed or shouldn't be there or outdated from a previous version.

This resource, unless I am mistaken, is for a single file. This should not be opening in an overlay.

HTML:
<a href="/mods/bolshe-uluchshenij-motylka-moreseamothupgrades.24/download" class="button--cta button button--icon button--icon--download" target="_blank" data-xf-click="overlay"><span class="button-text">Download</span></a>

Yet the HTML invokes an overlay on click.

As you noted from the previous HTML snippet, if a resource has only one file, it shouldn't be asking to include the overlay click:

HTML:
<xf:button href="{{ link('resources/download', $resource) }}" target="_blank"
   class="button--cta"
   data-xf-click="{{ $resource.CurrentVersion.file_count > 1 ? 'overlay' : '' }}"
   icon="download">{{ phrase('download') }}</xf:button>

The purpose of opening an overlay is for when a resource has more than one file, like this one:


1670340730148.webp

These Download links should never exhibit the issue because there's no reason for them to ever load in an overlay.

At this point I can confidently say it is not a bug, but I'm not entirely clear what's going on other than what I mentioned earlier in this post.
 
As you noted, I have registered today. You said I may not be able to reproduce the issue yet, but I can.


This is the resource where I can see it.

The issue quite simply is something in the template that has changed or shouldn't be there or outdated from a previous version.

This resource, unless I am mistaken, is for a single file. This should not be opening in an overlay.

HTML:
<a href="/mods/bolshe-uluchshenij-motylka-moreseamothupgrades.24/download" class="button--cta button button--icon button--icon--download" target="_blank" data-xf-click="overlay"><span class="button-text">Download</span></a>

Yet the HTML invokes an overlay on click.

As you noted from the previous HTML snippet, if a resource has only one file, it shouldn't be asking to include the overlay click:

HTML:
<xf:button href="{{ link('resources/download', $resource) }}" target="_blank"
   class="button--cta"
   data-xf-click="{{ $resource.CurrentVersion.file_count > 1 ? 'overlay' : '' }}"
   icon="download">{{ phrase('download') }}</xf:button>

The purpose of opening an overlay is for when a resource has more than one file, like this one:


View attachment 277820

These Download links should never exhibit the issue because there's no reason for them to ever load in an overlay.

At this point I can confidently say it is not a bug, but I'm not entirely clear what's going on other than what I mentioned earlier in this post.
Especially for you, I opened a backup copy on another domain - https://raidgamedemo.tk/mods/ragdolls.66/
Here's a link where you can see the error in person. I've given permission for guests to download, so you don't have to register. If you need to, then register and I will give you admin rights. When you're done, let me know, I'll delete the copy.
 
Last edited:
Doesn't really show me anything I can't already see on your site.

The two resources in this category only have one file each, apparently.

In both cases the download link has the HTML to open the resource in an overlay. This is not in the default template so you will need to investigate why that is. It could be a modified template, a template modification, or an add-on injecting code into the template.

If you can demonstrate this in an environment with no customisations, the default style only, and only XFRM enabled then it might be worth a closer look. If that happens, then it could be an issue with the value in the database indicating that there are more files than they should be, but then we'd need to understand why that is. Perhaps the database has been modified in some way, or maybe there could be a bug here with counting the number of files, but ultimately this is not something we can reproduce generally so we'd need a more consistent reproduction case.
 
Doesn't really show me anything I can't already see on your site.

The two resources in this category only have one file each, apparently.

In both cases the download link has the HTML to open the resource in an overlay. This is not in the default template so you will need to investigate why that is. It could be a modified template, a template modification, or an add-on injecting code into the template.

If you can demonstrate this in an environment with no customisations, the default style only, and only XFRM enabled then it might be worth a closer look. If that happens, then it could be an issue with the value in the database indicating that there are more files than they should be, but then we'd need to understand why that is. Perhaps the database has been modified in some way, or maybe there could be a bug here with counting the number of files, but ultimately this is not something we can reproduce generally so we'd need a more consistent reproduction case.
Weird problem. Okay, later on in the test domain I will post a clean installation with XFRM, load a couple of resources with different files and see how soon the problem comes out. If it really is an external problem, then I need to figure it out on my settings. If not, I will repeat my question. Thank you for your consideration of the problem. As I see it requires additional tests.
 
Top Bottom