Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.53k stars 2.81k forks source link

Check LastVersion of third party modules ONCE PER SESSION [one line solution PROPOSED] #31236

Open caos30 opened 2 months ago

caos30 commented 2 months ago

Feature Request

Hello, I have already developed 7 modules for Dolibarr (published on Dolistore) and in all of them I have defined the url_last_version property in the module's definition file modMymodule.class.php.

This causes Dolibarr to CHECK if there's a new version of my modules every time the user visits ANY OF THE TABS in the "Setup/Modules" section... which usually takes about 40-60 seconds each time!! This makes it "almost impossible" to work on module configuration and activation, really.

This will worsen as more developers discover that this is possible. Honestly, I think it's something very useful for the users of my modules. But it can't work this slowly.

Use case

No response

Suggested implementation

My improvement proposal, which I've already tested in Dolibarr 20, requires changing one line in the /core/modules/DolibarrModules.class.php file to STORE IN THE USER'S SESSION VARIABLE the last successful query to the REMOTE URL, and in subsequent calls to this function, that value is used for as long as the user session lasts.

In PHP code it would be:

File: /core/modules/DolibarrModules.class.php Method: public function checkForUpdate() Current code:

$lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0);    // Accept http or https links on external remote server only

New code:

if (!empty($_SESSION['lastVersion_'.$this->name])) {
    $lastVersion =  $_SESSION['lastVersion_'.$this->name];
} else {
    $lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0);    // Accept http or https links on external remote server only
    if (isset($lastVersion['content'])) $_SESSION['lastVersion_'.$this->name] = $lastVersion;
}

Thanks in advance.

Note: i've not added a pull request because it is not really a "bug". So i think that main developers should read my proposal and approve it or even improve it.

Suggested steps

No response

clementgde commented 2 months ago

It's not a bug, but it's very annoying for the user experience. In addition, I'd like to add a few closely related points: You should add the possibility of checking whether the url exists before making the request, because the 404 not found messages I've been getting for 5 years because I have old modules are a pain. Finally, on the same level, I think the messages should be more discreet, perhaps on the page intended for the module itself rather than on the general modules page. I'm a developer and I spend my life on this page, and it's a real pain to see “A new version is available” all the time, especially as it's not even major versions, it's 0.2 that become 0.3.

caos30 commented 2 months ago

You should add the possibility of checking whether the url exists before making the request, because the 404 not found messages I've been getting for 5 years because I have old modules are a pain.

clementgde commented 2 months ago

To avoid 404 errors, you could ping the url and record the errors.

caos30 commented 2 months ago

To avoid 404 errors, you could ping the url and record the errors.

Interesting approach, but this would only partially and occasionally address the problem because: