Yetangitu / owncloud-apps

Applications for Nextcloud and Owncloud personal cloud server
GNU Affero General Public License v3.0
87 stars 41 forks source link

XML Parsing Error: mismatched tag #36

Closed CreateWebNZ closed 7 years ago

CreateWebNZ commented 7 years ago

When I open the opds url https://cloud.createweb.de/index.php/apps/files_opds/ in any opds reader, I always get an error message. When I try to open it in a browser I get this error message: XML Parsing Error: mismatched tag. Expected: . Location: https://cloud.createweb.de/index.php/apps/files_opds/ Line Number 92, Column 136:

I am using Nextcloud 10.0.3

Yetangitu commented 7 years ago

Did you enable OPDS Catalog for your user? It looks like the URL does not produce XML but HTML, possibly due to an error somewhere, not necessarily in OPDS Catalog.

Is there anything interesting in the web server and/or Nextcloud log files?

BTW, I'd suggest upgrading to Nextcloud 11, the current stable version.

I also suggest you remove that OPDS link from your post to avoid attracting unwanted visitors.

CreateWebNZ commented 7 years ago

Yes I did enable opds for my account, but I just checked the log and there seems to be an issue with the database:

{"reqId":"WNErylnuQQkAACag@wAAAAAK","remoteAddr":"78.54.90.94","app":"index","message":"Exception: {\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\DriverException\",\"Message\":\"An exception occurred while executing 'UPDATE oc_opds_metadata SETupdated=?,date=?,author=?,title=?,language=?,publisher=?,isbn=?,copyright=?,description=?,subjects=?,cover=?,rescan=? WHERE id=?' with params [\\\"2017-03-21 13:34:03\\\", \\\"\\\", \\\"\\\", \\\"Regener, Sven - Magical Mystery oder Die Rueckkehr des Karl Schmidt\\\", \\\"\\\", \\\"\\\", \\\"9783869710730\\\", \\\"\\\", \\\"\\\", \\\"\\\", null, \\\"2017-03-28T13:34:03+00:00\\\", \\\"106530\\\"]:\\n\\nSQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2017-03-28T13:34:03+00:00' for column 'rescan' at row 1\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/DBALException.php(116): Doctrine\\\\DBAL\\\\Driver\\\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException))\\n#1 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Statement.php(174): Doctrine\\\\DBAL\\\\DBALException::driverExceptionDuringQuery(Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOMySql\\\\Driver), Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException), 'UPDATE oc_opds_...', Array)\\n#2 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/lib\\\/private\\\/legacy\\\/db\\\/statementwrapper.php(74): Doctrine\\\\DBAL\\\\Statement->execute(Array)\\n#3 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/apps\\\/files_opds\\\/lib\\\/meta.php(123): OC_DB_StatementWrapper->execute(Array)\\n#4 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/apps\\\/files_opds\\\/lib\\\/meta.php(204): OCA\\\\Files_Opds\\\\Meta::save(Array)\\n#5 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/apps\\\/files_opds\\\/lib\\\/meta.php(139): OCA\\\\Files_Opds\\\\Meta::scan('106530')\\n#6 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/apps\\\/files_opds\\\/lib\\\/files.php(36): OCA\\\\Files_Opds\\\\Meta::get('106530')\\n#7 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/apps\\\/files_opds\\\/lib\\\/files.php(60): OCA\\\\Files_Opds\\\\Files::formatFileInfo(Object(OC\\\\Files\\\\FileInfo))\\n#8 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/apps\\\/files_opds\\\/lib\\\/feed.php(62): OCA\\\\Files_Opds\\\\Files::formatFileInfos(Array)\\n#9 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/apps\\\/files_opds\\\/index.php(67): OCA\\\\Files_Opds\\\\Feed::serveFeed('\\\/books\\\/', 1, 'root')\\n#10 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/lib\\\/private\\\/Route\\\/Route.php(155) : runtime-created function(1): require_once('\\\/var\\\/www\\\/Cloud\\\/...')\\n#11 [internal function]: __lambda_func()\\n#12 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/lib\\\/private\\\/Route\\\/Router.php(293): call_user_func('\\\\x00lambda_1', Array)\\n#13 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/lib\\\/base.php(998): OC\\\\Route\\\\Router->match('\\\/apps\\\/files_opd...')\\n#14 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/index.php(48): OC::handleRequest()\\n#15 {main}\",\"File\":\"\\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/AbstractMySQLDriver.php\",\"Line\":116}","level":3,"time":"2017-03-21T13:34:03+00:00","method":"GET","url":"\/index.php\/apps\/files_opds\/","user":"rainer","version":"9.1.3.2"}

And thanks for pointing out, that the current version is 11, oddly enough my installation states "10.0.3 (stable)" and "Your version is up to date."

Yetangitu commented 7 years ago

Hm, strange, that date - 2017-03-28T13:34:03+00:00. When did this show up? It is a valid ISO-8601 date string but it is not what MySQL expects. Looking at the source these ISO-dates are generated in the ISBN-parser when it can not perform a metadata lookup for some reason (over quotum, no connection, no data, etc). This also explains why you're the first one to notice. If you want a quick fix, apply the following patch (UNTESTED but it should work):

diff --git a/files_opds/lib/isbndb.php b/files_opds/lib/isbndb.php
index 9e4d2f3..75c7100 100644
--- a/files_opds/lib/isbndb.php
+++ b/files_opds/lib/isbndb.php
@@ -62,13 +62,13 @@ class Isbndb
         static function parse($data,&$meta) {
                 /* did the call succeed? If not, schedule a rescan */
                 if (Isbn::REQUEST_LIMIT_EXCEEDED == $data) {
-                        $meta['rescan'] = date("Y-m-d\TH:i:sP", time() + Isbn::RESCAN_LIMIT_EXCEEDED);
+                        $meta['rescan'] = date("Y-m-d H:i:s", time() + Isbn::RESCAN_LIMIT_EXCEEDED);
                         return false;
                 } elseif (Isbn::NOT_FOUND == $data) {
-                        $meta['rescan'] = date("Y-m-d\TH:i:sP", time() + Isbn::RESCAN_NOT_FOUND);
+                        $meta['rescan'] = date("Y-m-d H:i:s", time() + Isbn::RESCAN_NOT_FOUND);
                         return false;
                 } elseif (Isbn::ERROR == $data) {
-                        $meta['rescan'] = date("Y-m-d\TH:i:sP", time() + Isbn::RESCAN_ERROR);
+                        $meta['rescan'] = date("Y-m-d H:i:s", time() + Isbn::RESCAN_ERROR);
                         return false;
                 }

You can also wait 'till I produce a new version with this patch included (might take a day or two).

CreateWebNZ commented 7 years ago

Thanks for the patch, but I'm sorry to say that it's still not working. Cool reader on Android simply throws an error 500 and this is what the log says now:

{"reqId":"WNFVVFnuQQkAACc5DSwAAAAE","remoteAddr":"78.54.90.94","app":"index","message":"Exception: {\"Exception\":\"OCP\\\\Files\\\\NotFoundException\",\"Message\":\"File with id \\\"1\\\" has not been found.\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/lib\\\/private\\\/Files\\\/Filesystem.php(883): OC\\\\Files\\\\View->getPath(1)\\n#1 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/apps\\\/files_opds\\\/index.php(47): OC\\\\Files\\\\Filesystem::getPath(1)\\n#2 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/lib\\\/private\\\/Route\\\/Route.php(155) : runtime-created function(1): require_once('\\\/var\\\/www\\\/Cloud\\\/...')\\n#3 [internal function]: __lambda_func()\\n#4 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/lib\\\/private\\\/Route\\\/Router.php(293): call_user_func('\\\\x00lambda_1', Array)\\n#5 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/lib\\\/base.php(998): OC\\\\Route\\\\Router->match('\\\/apps\\\/files_opd...')\\n#6 \\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/index.php(48): OC::handleRequest()\\n#7 {main}\",\"File\":\"\\\/var\\\/www\\\/Cloud\\\/nextcloud\\\/lib\\\/private\\\/Files\\\/View.php\",\"Line\":1700}","level":3,"time":"2017-03-21T16:31:17+00:00","method":"GET","url":"\/index.php\/apps\/files_opds\/","user":"rainer","version":"9.1.3.2"}

Yetangitu commented 7 years ago

What happens when you try to access the catalog using a browser? There is no reason for the patch to cause this behaviour, nor does ODPS Catalog request a file with fileId === 1 unless it is told to do so.

Can you perform database queries 'by hand'? If so, check the contents of PREFIXopds_metadata for a record with id === 1 (select from prefix*opds_metadata where id='1'; - change prefix to whatever it is on your system)

CreateWebNZ commented 7 years ago

Same error message as described in my first message, only the line numbers changed:

XML Parsing Error: mismatched tag. Expected: </link>. Location: https://cloud.createweb.de/index.php/apps/files_opds/ Line Number 89, Column 136: <link rel="stylesheet" href="/index.php/apps/theming/styles?v=6"/><script src="/index.php/apps/theming/js/theming?v=6"></script> </head> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------^ screenshot from 2017-03-21 23-25-58

There is no entry with id === 1, it starts with 16198. So you think it's an issue with the auto increment? Shouldn't it work properly anyway? Btw. it's my own root server, so I can perform any action you ask me to. ;-)

CreateWebNZ commented 7 years ago

I just emptied the table except for the first entry and changed the index of it to 1, but still the same error, then emptied it entirely but still the same.

Yetangitu commented 7 years ago
"method":"GET","url":"\/index.php\/apps\/files_opds\/","user":"rainer","version":"9.1.3.2"

It says you're using version 9.1.3.2

Are you sure you're running 10.x? FYI, current stable reports itself as "version":"11.0.2.7"

CreateWebNZ commented 7 years ago

I noticed that and was a bit irritated myself, but I definetaly installed 10.0.3 (See screenshot). Btw. The fact that it doesn't show version 11 within the updater is a known issue: https://github.com/nextcloud/server/issues/2832

nextcloud-version

Btw. this problem already existed, while I was still using Owncloud about 1 Year ago. I just didn't find the time to care about it.

Yetangitu commented 7 years ago

Look at the source for any Nextcloud page - I'd suggest using the Files app page - and check what the oc_config object contains. On 11.0.2.7 it looks like this:

var oc_config={"session_lifetime":1440,"session_keepalive":true,"version":"11.0.2.7","versionstring":"11.0.2","enable_avatars":true,"lost_password_link":null,"modRewriteWorking":true};

The interesting bit is the version string...

CreateWebNZ commented 7 years ago

Already fixed that, no change regarding the problem. I'm just updating manually to 11...

CreateWebNZ commented 7 years ago

Same issue after Update to 11, but after truncating the table now I get this log message when I call the opds url: Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'INSERT INTO oc_opds_metadata (id,updated,date,author,title,language,publisher,isbn,copyright,description,subjects,cover,rescan) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)' with params ["106530", "2017-03-22 01:15:11", "", "", "Regener, Sven - Magical Mystery oder Die Rueckkehr des Karl Schmidt", "", "", "9783869710730", "", "", "", null, "2017-03-29T01:15:12+00:00"]: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2017-03-29T01:15:12+00:00' for column 'rescan' at row 1

CreateWebNZ commented 7 years ago

When I empty the database and the books dir, I get a proper xml return. As soon as I add some books, it starts failing again. I suspect, it might be some of the meta data of the books. I keep trying and let you know, when I found the culprit...

CreateWebNZ commented 7 years ago

I found the book that caused all the problems. I can't attach it here for legal reasons, but I did send it to you via email for further investigation. Everything works fine now, so case closed I guess. :-)