bookmarks icon indicating copy to clipboard operation
bookmarks copied to clipboard

Get rid of the gmp dependency

Open rogercreagh opened this issue 6 years ago • 10 comments

If you have NC installed and working and it happens that you don't have sysadmin or sudo access to the server (eg shared hosting) and it happens that php7.3 supplied does not have gmp installed then you are unable to use bookmarks - which is a shame.

Is there any way that the required gmp functionality can be built in? What is it actually needed for? "GNU Multiple Precision Arithmetic Library (GMP) is a free library for arbitrary-precision arithmetic, operating on signed integers, rational numbers, and floating point numbers."

So why is this required for Bookmarks to work. Can't it use standard built-in maths functions?

I see other people have had the same issue - any chance of a non-gmp dependent version of the app?

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

rogercreagh avatar Feb 26 '20 18:02 rogercreagh

I understand the concern. The problem is that it's a subdependency. This app needs a working implementation of the WHATWG URL standard, which PHP doesn't have that built-in, afaik. I have tried to implement this myself in the past and learned that it's much more work than I can afford. Thus I added https://github.com/TRowbotham/URL-Parser as a dependency which works splendidly, but sadly happens to depend on gmp.

The options are thus:

  1. find an alternative to @TRowbotham's library
  2. ask @TRowbotham to consider removing the dependency
  3. Find out if gmp can be polyfilled

marcelklehr avatar Feb 26 '20 21:02 marcelklehr

I am open to removing the dependency on gmp. It is used only to support 32 bit versions of PHP, which is likely getting rare these days.

These are our options:

  1. Drop support for 32 bit PHP, thus removing the need for gmp.
  2. Swap the the gmp dependency for a library such as https://github.com/brick/math
  3. Drop gmp as a hard dependency and make a documentation note that gmp must be installed for 32 bit users and throw an exception if its not installed for 32 bit users.

Please let me know if you prefer one option over the other or if you think of a better solution.

TRowbotham avatar Feb 26 '20 21:02 TRowbotham

Many thanks Trevor, that is really helpful,

Personally I would go for option 3 (which sounds like it is in effect the same as option 1 but requiring a documentation change, and ideally a graceful exception handler with an explanation).

On the other hand if option 1 is easier and makes anything else simpler then go for that. As you say I suspect that 32bit servers might be getting pretty rare even with cheap hosting suppliers.

RogerCO

On 26 Feb 2020, at 21:38, Trevor Rowbotham [email protected] wrote:

I am open to removing the dependency on gmp. It is used only to support 32 bit versions of PHP, which is likely getting rare these days.

These are our options:

Drop support for 32 bit PHP, thus removing the need for gmp. Swap the the gmp dependency for a library such as https://github.com/brick/math https://github.com/brick/math Drop gmp as a hard dependency and make a documentation note that gmp must be installed for 32 bit users and throw an exception if its not installed for 32 bit users. Please let me know if you prefer one option over the other or if you think of a better solution.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nextcloud/bookmarks/issues/922?email_source=notifications&email_token=AKXFPXAJTITEGYR4HR3L4C3RE3OPHA5CNFSM4K4LQAO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENB7VHI#issuecomment-591657629, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKXFPXHTXKYXRME3USCYYN3RE3OPHANCNFSM4K4LQAOQ.

rogercreagh avatar Feb 26 '20 22:02 rogercreagh

None of the options are terribly difficult to implement. So, I guess the question is, are we willing to accept a dependency on the brick/math library to completely support 32-bit versions. @marcelklehr, do you happen to know how many users you have running 32-bit PHP or do you have any objections to my library depending on brick/math?

Option 1 is certainly the easiest, though that leaves 32-bit users in the dark.

Option 2 is the most complete option as it supports the use of both GMP and BCMath and has a fallback to string math in the event neither extension is installed, but has the downside of depending on another library (though brick/math has no dependencies of its own apart from requiring PHP >= 7.1).

As for option 3, I could add support for the BCMath extension in addition to GMP, which would help, but it would still be broken for 32-bit users without either extension.

I'm currently leaning towards option 2 assuming no one has an objection to adding a dependency on brick/math. Otherwise, I think option 3 would be best. I have a working prototype of option 2 so that native math functions are used on 64-bit versions, but it falls back to the brick/math library on 32-bit versions. This removes the dependency on ext-gmp and adds a dependency on brick/math.

TRowbotham avatar Feb 27 '20 05:02 TRowbotham

Given that there is a working prototype of option 2 and it satisfies everyone including the need (me) to be able to install apps using only the php dependencies required by NC itself I think I would now go for that.

On 27 Feb 2020, at 05:03, Trevor Rowbotham [email protected] wrote:

I'm currently leaning towards option 2 assuming no one has an objection to adding a dependency on brick/math. Otherwise, I think option 3 would be best. I have a working prototype of option 2 so that native math functions are used on 64-bit versions, but it falls back to the brick/math library on 32-bit versions. This removes the dependency on ext-gmp and adds a dependency on brick/math.

rogercreagh avatar Feb 27 '20 07:02 rogercreagh

Option 2 does sound most reasonable. Thank you for considering this @TRowbotham :blue_heart:

marcelklehr avatar Feb 29 '20 18:02 marcelklehr

I've released v3.0.1, which implements option 2. Thanks for the feedback!

TRowbotham avatar Feb 29 '20 21:02 TRowbotham

Fixed by #928

marcelklehr avatar Apr 02 '20 14:04 marcelklehr

@marcelklehr I think another change is needed here: https://github.com/nextcloud/bookmarks/blob/master/appinfo/info.xml in the dependencies section and in the documentation.

benjaminrein avatar Apr 04 '20 14:04 benjaminrein

@benjaminrein I'm aware. I'll fix this before the release :)

marcelklehr avatar Apr 04 '20 18:04 marcelklehr