rotdrop / nextcloud-app-pdf-downloader

Recusively convert entire directory trees to PDF and provide the resulting document as download.
Other
3 stars 4 forks source link

Nextcloud 25 crashes after activating pdf-downloader app #30

Closed rinal13 closed 1 year ago

rinal13 commented 1 year ago

I get following error after activating pdf downloader. Result is that nextcloud files crashes.

[index] Fehler: Exception: OCA\PdfDownloader\Service\PdfCombiner::setOverlayPageWidthFraction(): Argument #1 ($overlayPageWidthFraction) must be of type ?float, string given, called in /var/www/nextcloud/apps/pdf_downloader/lib/Service/FileSystemWalker.php on line 176 in file '/var/www/nextcloud/apps/pdf_downloader/lib/Service/PdfCombiner.php' line 290 at <>

  1. /var/www/nextcloud/lib/private/AppFramework/App.php line 172 OC\AppFramework\Http\Dispatcher->dispatch()
  2. /var/www/nextcloud/lib/private/Route/Router.php line 298 OC\AppFramework\App::main()
  3. /var/www/nextcloud/lib/base.php line 1047 OC\Route\Router->match()
  4. /var/www/nextcloud/index.php line 36 OC::handleRequest()

Nextcloud 25.04 PDF Downloader 1.1.1

rotdrop commented 1 year ago

Thanks for reporting. Seems that a type-cast is missing there. I'll have a look.

rotdrop commented 1 year ago

I have now played with this but unfortunately cannot reproduce it. Deliberately I have configured that "page label width fraction" and verified that it is also set in the table in the Nextcloud database. But I do not get this error -- unless I manually set the value to something which really is not convertible to a number like "foobar" or so.

Also through the user interface I am not able to configure this setting to something which is not convertible.

Can you please tell me a little bit more about your setup: PHP version, web-browser. Do you have a chance to inspect the oc_preferences table in the database directly and could you have a look if there is a setting for your user-id, the app "pdf_downloader" and the config-key "pageLabelPageWidthFraction"?

What did you exactly do before the crash was happening?

Thanks

Claus

rotdrop commented 1 year ago

This commit 7f94a0b1d5fcddf3c4863878b0abc5b3fa389d80 should solve the issue with the invalid user preferences. Still it would be good to understand why the user-settings are bogus in you case.

The current pre-release 1.1.2-rc1 has also this commit, perhaps you could give it a try (in case you can install apps from a tarball). Pre-releases cannot be installed from the app-store.

rinal13 commented 1 year ago

I have following Server / Browser Versions in use PHP 8.1.16 / Safari 16.3 / MacOS 13.2.1

The database shows as following:

Bildschirm­foto 2023-03-03 um 21 43 09

I had the app for testing purpose active, but then deactivated. As the app get updated I tried to reactivate the app again and get the described error

As I deleted all entry in the oc_preferences the activation of the app worked again without error.

When I set the pageLabelPageWidthFraction in the personal settings to nothing I get the same error again which shows then likes this in the db.

Bildschirm­foto 2023-03-03 um 22 00 58

If I change the value in the db to 0 it works again.

May you use 0 or 0.0 as an value to deactivate the "pageLabelPageWidthFraction" instead of no entry, do avoid datatype error as the configvalue column is defined as longtext in the database.

rinal13 commented 1 year ago

This commit 7f94a0b should solve the issue with the invalid user preferences. Still it would be good to understand why the user-settings are bogus in you case.

The current pre-release 1.1.2-rc1 has also this commit, perhaps you could give it a try (in case you can install apps from a tarball). Pre-releases cannot be installed from the app-store.

I am not so familiar with that. Where I can find the tarball of the pre-release 1.1.2-rc1? If I have the tarball I can install and test.

rotdrop commented 1 year ago

Sorry for not coming back to this earlier. The pre-release tar should be available from the Github repository here:

https://github.com/rotdrop/nextcloud-app-pdf-downloader/releases/

The tar-archive pdf_downloader.tar.gz is visible if you expand the "assets" section in each particular release.

The last two weaks were quite busy. I have meanwhile some OSX running in a virtual machine. I can eventually try what Safari is doing there. I suspect there might be some differences between Firefox an Safari in the handling of number inputs.

rinal13 commented 1 year ago

I tried, but sorry to say it does not really solve the issue. The changed code only prevent that the file app is not crashing.

Because still the datatype mismatch with the setting value exist. As seen by the following error in the Nextcloud log

[pdf_downloader] Fehler: /var/www/nextcloud/apps/pdf_downloader/lib/Service/FileSystemWalker.php:182: OCA\PdfDownloader\Service\FileSystemWalker::__construct(): The user preferences of user "" for the config-key "pageLabelPageWidthFraction" are broken, this should be a floating point value and between 0 and 1: "".

as the setting "pageLabelPageWidthFraction" is still "" instead of 0 for deactivating "pageLabelPageWidthFraction".

So for the generation of a pdf with the "" setting for the "pageLabelPageWidthFraction" is not working at all.

rotdrop commented 1 year ago

I tried, but sorry to say it does not really solve the issue. The changed code only prevent that the file app is not crashing.

Because still the datatype mismatch with the setting value exist. As seen by the following error in the Nextcloud log

[pdf_downloader] Fehler: /var/www/nextcloud/apps/pdf_downloader/lib/Service/FileSystemWalker.php:182: OCA\PdfDownloader\Service\FileSystemWalker::__construct(): The user preferences of user "" for the config-key "pageLabelPageWidthFraction" are broken, this should be a floating point value and between 0 and 1: "".

as the setting "pageLabelPageWidthFraction" is still "" instead of 0 for deactivating "pageLabelPageWidthFraction".

So for the generation of a pdf with the "" setting for the "pageLabelPageWidthFraction" is not working at all.

Hold on. This error message is generated by my changes which work around this problem. So "not at all" is not quite true here. The error message simply means that the code detected the issue.

Apart from the error message, does the app work now?

rotdrop commented 1 year ago

I have meanwhile some OSX running in a virtual machine. I can eventually try what Safari is doing there. I suspect there might be some differences between Firefox an Safari in the handling of number inputs.

I think that the source of the problem is the way how Safari handles number inputs, but I have to check. Do you have the possibility to test this with another browser, best Firefox? That does not mean that I do not want to resolve the issue, but it helps tracking the problem down and maybe opens a work-around for you until the issue is fixed (where I still have the impression that my previous workaround should compensate the problem and make the app usable).

rinal13 commented 1 year ago

Also in Firefox I get the same error when "pageLabelPageWidthFraction" is set to ""

{"reqId":"hvjSlhdICJOolNBgTYh1","level":3,"time":"2023-03-15T10:16:19+00:00","remoteAddr":"192.168.1.1","user":"rfreuis","app":"pdf_downloader","method":"GET","url":"/settings/admin/logging","message":"/var/www/nextcloud/apps/pdf_downloader/lib/Service/FileSystemWalker.php:182: OCA\PdfDownloader\Service\FileSystemWalker::__construct(): The user preferences of user \"\" for the config-key \"pageLabelPageWidthFraction\" are broken, this should be a floating point value and between 0 and 1: \"\".","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/112.0","version":"25.0.4.1","data":{"app":"pdf_downloader"},"id":"64119af54aa92"}

If the "pageLabelPageWidthFraction" is set to 0.4 i.e the app [v1.1.2-rc1] works flawless.

rotdrop commented 1 year ago

... sorry I was on the wrong track. There will be a fix probably later today or tomorrow.

rotdrop commented 1 year ago

A fixed font size (i.e. empty page label width fraction) might work with the latest pre-release rc3 which can be found in the releases section of this Github project and in the Nextcloud app-store. Thank you for your patience.