Skip to content

Added a condition to find the latest compatible version - #15754

Merged
williamdes merged 1 commit into
phpmyadmin:QA_5_0from
Gaurav-Punjabi:QA_5_0
Feb 14, 2020
Merged

williamdes merged 1 commit into
phpmyadmin:QA_5_0from
Gaurav-Punjabi:QA_5_0

Conversation

@Gaurav-Punjabi

@Gaurav-Punjabi Gaurav-Punjabi commented Jan 6, 2020 •

Copy link
Copy Markdown
Contributor

Signed-off-by: Gaurav Punjabi [email protected]

Description

Added a condition getLatestCompatibleVersion() to fetch the latest compatible version.

Please describe your pull request.

Fixes #15745

Before submitting pull request, please review the following checklist:

  • Make sure you have read our CONTRIBUTING.md document.
  • Make sure you are making a pull request against the correct branch. For example, for bug fixes in a released version use the corresponding QA branch and for new features use the master branch. If you have a doubt, you can ask as a comment in the bug report or on the mailing list.
  • Every commit has proper Signed-off-by line as described in our DCO. This ensures that the work you're submitting is your own creation.
  • Every commit has a descriptive commit message.
  • Every commit is needed on its own, if you have just minor fixes to previous commits, you can squash them.
  • Any new functionality is covered by tests.

@ibennetch

Copy link
Copy Markdown
Member

I seem to get this error in my logs after applying your patch. My current branch is QA_5_0, so my current version is 5.0.1-dev and the current downloads offered in version.json are 4.9.3 and 5.0.0.

PHP Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /var/www/pma-dev/version_check.php:40\nStack trace:\n#0 {main}\n thrown in /var/www/pma-dev/version_check.php on line 40

@codecov

codecov Bot commented Jan 7, 2020 •

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (QA_5_0@05b4e53). Click here to learn what that means.
The diff coverage is 100%.

@@            Coverage Diff            @@
##             QA_5_0   #15754   +/-   ##
=========================================
  Coverage          ?   53.03%           
  Complexity        ?    14180           
=========================================
  Files             ?      482           
  Lines             ?    62206           
  Branches          ?        0           
=========================================
  Hits              ?    32988           
  Misses            ?    29218           
  Partials          ?        0

@Gaurav-Punjabi

Copy link
Copy Markdown
Contributor Author

I seem to get this error in my logs after applying your patch. My current branch is QA_5_0, so my current version is 5.0.1-dev and the current downloads offered in version.json are 4.9.3 and 5.0.0.

PHP Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /var/www/pma-dev/version_check.php:40\nStack trace:\n#0 {main}\n thrown in /var/www/pma-dev/version_check.php on line 40

Fixed it 👍

@MauricioFauth MauricioFauth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread test/classes/VersionInformationTest.php Resolved
@ecartz

ecartz commented Jan 16, 2020

Copy link
Copy Markdown
            // To compare the current release with the previous latest release
            if ($latestRelease) {
                if ($latestRelease['version'] < $release->version) {
                    $latestRelease = [
                        'version' => $release->version,
                        'date' => $release->date
                    ];
                }
            } else {
                $latestRelease = [
                    'version' => $release->version,
                    'date' => $release->date,
                ];
            }
        }
        // no compatible version
        return $latestRelease;

can more easily be written

            if (is_null($latestRelease) || $latestRelease['version'] < $release->version) {
                $latestRelease = [
                  'version' => $release->version,
                  'date' => $release->date,
                ];
            }
        }

        return $latestRelease;

Then it wouldn't have the code duplicated. And it wouldn't say "no compatible version" right before it returns the compatible version in the most common case. I tested this version on my 5.0.1 installation.

Also, wouldn't this be more readable with the vertical spaces before the comments as used to be there?

It's not clear to me if this is the correct solution. If I'm currently on 4.9.3, what should it say? Upgrade to 5.0.1? Or to 4.9.4? Or both? If I'm on 4.9.4, should it be pushing me to 5.0.1 or not? I.e. this fixes the error of showing 4.9.4 as the latest version when on 5.0.1 (which was the problem that I was experiencing), but it may introduce other errors.

I think that if I'm currently on

  • 5.0.1-Snapshot, it should say that I have a dev version with 5.0.1 the latest stable. And maybe it should tell me if I have the latest dev version or not (is there a newer snapshot?).
  • 5.0.1, it should say I have the latest version.
  • 5.0.0, it should say that there is a newer version, 5.0.1.
  • 4.9.4, it should say that is LTS with 5.0.1 stable.
  • 4.9.3, it should say that there is 4.9.4 LTS and 5.0.1 stable.
  • 4.8.* or older, it should say that it is out of date and needs updated. Not sure what version to recommend.

I think that latest release is itself a weak concept that doesn't quite match actual usage. Security-wise, 4.9.4 is probably a bit safer than 5.0.1, as it gets all the security fixes and none of the new features that might require security fixes. So in my opinion, it shouldn't say that 4.9.4 needs updated to 5.0.1, just that that option is available. But the way it works now, it will always suggest converting to one version for everyone. With the buggy behavior that it was telling people to downgrade from 5.0.1 to 4.9.4.

@ibennetch

Copy link
Copy Markdown
Member

Then it wouldn't have the code duplicated.

That's great.

5.0.1-Snapshot, it should say that I have a dev version with 5.0.1 the latest stable. And maybe it should tell me if I have the latest dev version or not (is there a newer snapshot?).

5.0.1-dev, latest release is 5.0.1 because the user is running a version more recent than the latest stable release.

5.0.1, it should say I have the latest version.

Correct

5.0.0, it should say that there is a newer version, 5.0.1.

I agree

4.9.4, it should say that is LTS with 5.0.1 stable.

I don't know if we currently provide enough information in version.json to display this. If we were to add this, Latest LTS; current stable: 5.0.1 may be a good way to handle it.

4.9.3, it should say that there is 4.9.4 LTS and 5.0.1 stable.

Hm, this one is a bit more difficult. We don't really want people to stay on 4.9, but if someone decides to stay on 4.9 then perhaps it would be good to announce if a new LTS version is available. I don't think we've encountered this specific situation before since the version check feature has been introduced.

I slightly disagree; we're recommending people migrate to 5.x because 4.9 will eventually be deprecated, and for best compatibility with recent MySQL/MariaDB and PHP versions users should upgrade to 5.0, but I can see the case for telling people that a new LTS version is available. I don't know if we currently provide enough metadata in version.json to make that determination.

We historically haven't done much to tell people about LTS version support; we have several other notification methods users can subscribe through to find these announcements. This has been used to show the latest stable version, and I'm not sure that fixing that is going to be easy.

4.8.* or older, it should say that it is out of date and needs updated. Not sure what version to recommend.

@Gaurav-Punjabi

Gaurav-Punjabi commented Jan 17, 2020 •

Copy link
Copy Markdown
Contributor Author
            // To compare the current release with the previous latest release
            if ($latestRelease) {
                if ($latestRelease['version'] < $release->version) {
                    $latestRelease = [
                        'version' => $release->version,
                        'date' => $release->date
                    ];
                }
            } else {
                $latestRelease = [
                    'version' => $release->version,
                    'date' => $release->date,
                ];
            }
        }
        // no compatible version
        return $latestRelease;

can more easily be written

            if (is_null($latestRelease) || $latestRelease['version'] < $release->version) {
                $latestRelease = [
                  'version' => $release->version,
                  'date' => $release->date,
                ];
            }
        }

        return $latestRelease;

Then it wouldn't have the code duplicated. And it wouldn't say "no compatible version" right before it returns the compatible version in the most common case. I tested this version on my 5.0.1 installation.

Also, wouldn't this be more readable with the vertical spaces before the comments as used to be there?

It's not clear to me if this is the correct solution. If I'm currently on 4.9.3, what should it say? Upgrade to 5.0.1? Or to 4.9.4? Or both? If I'm on 4.9.4, should it be pushing me to 5.0.1 or not? I.e. this fixes the error of showing 4.9.4 as the latest version when on 5.0.1 (which was the problem that I was experiencing), but it may introduce other errors.

I think that if I'm currently on

  • 5.0.1-Snapshot, it should say that I have a dev version with 5.0.1 the latest stable. And maybe it should tell me if I have the latest dev version or not (is there a newer snapshot?).
  • 5.0.1, it should say I have the latest version.
  • 5.0.0, it should say that there is a newer version, 5.0.1.
  • 4.9.4, it should say that is LTS with 5.0.1 stable.
  • 4.9.3, it should say that there is 4.9.4 LTS and 5.0.1 stable.
  • 4.8.* or older, it should say that it is out of date and needs updated. Not sure what version to recommend.

I think that latest release is itself a weak concept that doesn't quite match actual usage. Security-wise, 4.9.4 is probably a bit safer than 5.0.1, as it gets all the security fixes and none of the new features that might require security fixes. So in my opinion, it shouldn't say that 4.9.4 needs updated to 5.0.1, just that that option is available. But the way it works now, it will always suggest converting to one version for everyone. With the buggy behavior that it was telling people to downgrade from 5.0.1 to 4.9.4.

Okay i'll make these changes in the code to make it clean.

@williamdes

Copy link
Copy Markdown
Member

For the LTS/security part see #12506

@williamdes

Copy link
Copy Markdown
Member

And yes I did commit this to the main repo in d26b9fb and then revert by 87aa7b0

Sorry.

@williamdes williamdes mentioned this pull request Feb 11, 2020
@williamdes
williamdes force-pushed the QA_5_0 branch 4 times, most recently from bc55abb to de25b76 Compare February 14, 2020 07:49
@williamdes williamdes self-assigned this Feb 14, 2020
Co-authored-by: William Desportes <[email protected]>
Signed-off-by: Gaurav Punjabi <[email protected]>
@williamdes

Copy link
Copy Markdown
Member

Hi everyone
I intend to merge this PR today, could you please review it ?
NB: you can use the approve button :)

@boherm boherm left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me :)

williamdes added a commit that referenced this pull request Feb 14, 2020
…able version

Pull-request: #15754
Fixes: #15745
Closes: #15952
Closes: #15860

Signed-off-by: William Desportes <[email protected]>
@williamdes
williamdes merged commit 96260d9 into phpmyadmin:QA_5_0 Feb 14, 2020
@williamdes

Copy link
Copy Markdown
Member

Thank you @Gaurav-Punjabi for the initial work on this issue !

@Gaurav-Punjabi

Copy link
Copy Markdown
Contributor Author

Thank you @Gaurav-Punjabi for the initial work on this issue !

Glad I could help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants