seblucas / cops

Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...)
http://blog.slucas.fr/en/oss/calibre-opds-php-server
GNU General Public License v2.0
1.42k stars 229 forks source link

I'm experiencing a performance problem epubreader.php #531

Open viking-k opened 7 months ago

viking-k commented 7 months ago

COPS 1.5.4 on Synology. When I try to view epub, it gives the following message

300 Fatal error: Uncaught Exception: Failed to read epub file in /volume1/web/cops/vendor/mikespub/php-epub-meta/src/EPub.php:

that is, an error in opening the ZIP file

  /**
     * Summary of openZipFile
     * @param string $zipClass
     * @throws \Exception
     * @return void
     */
    public function openZipFile($zipClass)
    {
        $this->zip = new $zipClass();
        if (!$this->zip->Open($this->file)) {
            throw new Exception('Failed to read epub file');
        }
        $this->zipClass = $zipClass;
    }

What could be the reason?

marioscube commented 7 months ago

@viking-k

Can you unzip the epub manually with unzip on the Synoligy?

It might be broken.

viking-k commented 7 months ago

You are right. indeed unzip is broken.

which 7z -> /bin/7z which zip -> /bin/zip which unzip -> nil

how to change the unzip command (or unzipper) in COPS?

marioscube commented 7 months ago

@viking-k

1 - COPS works with php-zip. I do not think that is available from the command line.

2 - do you get this error with every epub file or just with 1 particular epub file?

3 - Usually zip can be used to unzip as well. Use zip (or 7z) to try to unzip the epub file. This to check if this epub file is corrupted.

viking-k commented 7 months ago
  1. Checked, PHP ZIP extensions are enabled. (zip, zlib) image

  2. Error with any EPUB file. Even from demo site (https://cops-demo.slucas.fr/download/20/Alice%27s%20Adventures%20in%20Wonderland%20-%20Lewis%20Carroll.epub)

  3. Yes, EPUB file is unpacked correctly on NAS (7z x file.epub).

marioscube commented 7 months ago

@viking-k

Your best bet to solve this is to repost your problem, together with the info from your last post, on https://github.com/mikespub-org/seblucas-cops/issues.

dunxd commented 7 months ago

Rather than repost, first try installing a more recent version of COPS available at https://github.com/mikespub-org/seblucas-cops/ as a number of bugs have been squashed. If you still get the same issue then please post an issue there.

Do be careful to read the readme first, as which version to install depends on what version of PHP you are running on your Synology.

marioscube commented 7 months ago

@dunxd

If the most recent version of PHP on the Synology is 7.4 @viking-k has probably installed the most recent compatible version of (new) COPS. Support from that site?

@viking-k Can you install PHP 8.1 on your synology (not saying you should)? With what client are you using COPS (eg. Windows Edge)?

Maybe reinstall COPS 1.5.4 ?

marioscube commented 7 months ago

@viking-k @dunxd

Issue confirmed!

Installed. latest COPS from https://github.com/mikespub-org/seblucas-cops/releases/download/2.2.1/cops-2.2.1.zip and tried to use viewer. PHP 8.2.7.

[Wed Jan 24 14:35:44.976454 2024] [php:error] [pid 1091] [client 192.168.1.yyy:58318] PHP Fatal error: Uncaught Error: Call to a member function getDatabaseId() on null in /var/www/html/cops/lib/Output/EPubReader.php:107\nStack trace:\n#0 /var/www/html/cops/epubreader.php(23): SebLucas\Cops\Output\EPubReader::getReader()\n#1 {main}\n thrown in /var/www/html/cops/lib/Output/EPubReader.php on line 107, referer: http://192.168.1.xxx/cops/index.php?page=10&db=2

I used firefox (Brave browser does not work at all, probably Brave issue)

dunxd commented 7 months ago

That doesn't look to be the same issue reported by @viking-k - that was a 300 error with a specific trace.

Unless viking-k has a specific reason to run a more recent version of PHP than mentioned in the readme on mikespub, I would stick with those versions since they have been shown to work.

For any issues relating to COPS from mikespub report issues there.

If PHP is stuck on version lower than 7 on the Synology for some reason, unfortunately I don't think anyone is still working on that.

On Wed, 24 Jan 2024, 1:08 pm marioscube, @.***> wrote:

@viking-k https://github.com/viking-k @dunxd https://github.com/dunxd

Issue confirmed!

Installed. latest COPS from https://github.com/mikespub-org/seblucas-cops/releases/download/2.2.1/cops-2.2.1.zip http://url and tried to use viewer. PHP 8.2.7.

HTTP error 500

— Reply to this email directly, view it on GitHub https://github.com/seblucas/cops/issues/531#issuecomment-1908090952, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6W2HKPPG2M4NSFTRRV4ATYQEBWHAVCNFSM6AAAAABB3EFU5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBYGA4TAOJVGI . You are receiving this because you were mentioned.Message ID: @.***>

marioscube commented 7 months ago

@dunxd

Both issues are related to the monocle viewer.

In my humble opinion monocle should be removed from COPS and/or replaced with a better working epub viewer.

Maybe I will report this issue in the mikespub repository.

marioscube commented 7 months ago

@viking-k

What is the output of http://YourLocalIP/cops/checkconfig.php ?

viking-k commented 7 months ago

@marioscube

Can you install PHP 8.1 on your synology (not saying you should)?

Unfortunately I am limited to PHP 7.4. This is the newest version of PHP available. So the COPS version available to me is 1.5.4.

With what client are you using COPS (eg. Windows Edge)?

Any (firefox, Chrome, Windows Edge)

Maybe reinstall COPS 1.5.4 ?

I used the https://synocommunity.com/package/cops package. Reinstallation did not yield any results.

What is the output of http://yourlocalip/cops/checkconfig.php ?

Check if PHP version is correct
OK (7.4.30)
Check if GD is properly installed and loaded
OK
Check if Sqlite is properly installed and loaded
OK
Check if libxml is properly installed and loaded
OK
Check if DOM is properly installed and loaded
OK
Check if XMLWriter is properly installed and loaded
OK
Check if Json is properly installed and loaded
OK
Check if mbstring is properly installed and loaded
OK
Check if intl is properly installed and loaded
OK
Check if Normalizer class is properly installed and loaded
OK
Check if zlib is properly installed and loaded
OK
Check if the rendering will be done on client side or server side
Client side rendering
Check if Calibre database path is not an URL
ALL OK
Check if Calibre database file exists and is readable
ALL OK
Check if Calibre database file can be opened with PHP
ALL OK
Check if Calibre database file contains at least some of the needed tables
ALL OK
Check if Calibre database path is not an URL
viking-k commented 7 months ago

@marioscube @dunxd

I realize my version of COPS is too old, anyway thanks for the help.

marioscube commented 7 months ago

@viking-k

what you can do is install version 1.5.4 of COPS directly from GitHub.

install in a new directory copsnew cd copsnew wget https://github.com/mikespub-org/seblucas-cops/releases/download/1.5.4/cops-1.5.4.zip Unzip (7z) cops-1.5.4.zip Copy over the config_local.php

and try again

should work.

dunxd commented 7 months ago

Viewing epubs in the Browser works for me using mikespub version 2.2.2 - every epub I've thrown at it works fine. But yes, monocle's readme itself warns that it is no longer maintained. Do you have thoughts for a replacement?

Please do post your thoughts on monocle over there. I'm not sure it is even possible to make updates to this repo.

viking-k commented 7 months ago

@marioscube

The error persists on the version from https://github.com/mikespub-org/seblucas-cops/releases/download/1.5.4/cops-1.5.4.zip

marioscube commented 7 months ago

@dunxd mikespub version 2.2.1 (most recent download)

Works only on the first library. on other libraries I get either a white screen or the wrong book.

marioscube commented 7 months ago

@viking-k

It might be a PHP error. Can you reinstall PHP7.4?

dunxd commented 7 months ago

Report any issues with the mikespub fork in that fork's repository were it may be picked up by those working on it - not here or by reply to these messages.

Start a new issue at https://github.com/mikespub-org/seblucas-cops/issues.

viking-k commented 7 months ago

comrades, Issues can be closed.

I was able to install the same COPS 1.5.4-9 package on the same version of PHP 7.4 , but on a different synology. No problems with epub viewing. I will now look for the cause in my DSM.

mikespub commented 6 months ago

@marioscube the error you reported above

[Wed Jan 24 14:35:44.976454 2024] [php:error] [pid 1091] [client 192.168.1.yyy:58318] PHP Fatal error: Uncaught Error: Call to a member function getDatabaseId() on null in /var/www/html/cops/lib/Output/EPubReader.php:107\nStack trace:\n#0 /var/www/html/cops/epubreader.php(23): SebLucas\Cops\Output\EPubReader::getReader()\n#1 {main}\n thrown in /var/www/html/cops/lib/Output/EPubReader.php on line 107, referer: http://192.168.1.xxx/cops/index.php?page=10&db=2

should be fixed in release 2.2.2

This is unrelated to the original issue reported by @viking-k