Ayemae / Grawlix-Webcomic-CMS

PHP-based webcomic CMS
22 stars 5 forks source link

Clicking on "Edit book info" in Book View goes to a blank page #7

Closed radiochio closed 2 years ago

radiochio commented 2 years ago

I've been rebuilding my comic site using this version of Grawlix on MAMP locally, and everything seems to work ok. After uploading everything to my live site, suddenly the "Edit book info" link on the Book View page just goes to a blank page. It is a fresh install of Grawlix, so I'm not sure why it would just suddenly stop working correctly. Any suggestions or thoughts on why that might happen?

darth-biomech commented 2 years ago

I think I had something similar happen on my site once, and it turned out I uploaded stuff with a conversion of filenames to lower case.

radiochio commented 2 years ago

I think I had something similar happen on my site once, and it turned out I uploaded stuff with a conversion of filenames to lower case.

Do you mean the filenames for the individual php files? I don't think I've ever had a version of them where those filenames were capitalized. I tried changing it just to see, and it didn't make a difference, still getting the blank white screen when I try to get to Edit Book Info.

eishiya commented 2 years ago

The PHP filenames for Grawlix are case-sensitive, and do include capital letters, e.g. GrlxPage2.php is not the same as grlxpage2.php. The file names being wrong would cause almost everything to break though, rather than just the book view...

There is probably a PHP error that's happening that isn't being output due to your server's error-reporting settings. Try checking your error logs, or putting ini_set('display_errors', 1); near the top of the affected page's file (/_admin/book.view.php in this case) so that the errors are displayed on the page. Seeing this error would help find the issue.

radiochio commented 2 years ago

Ah yes, I wasn't thinking about those files, since I haven't touched any of them and forgot capitalized files do exist.

But, yes, adding the ini_set line did help - I actually added it to book.edit.php and got an entire pageful of errors. This one is a little bit above my skill level, but here's what I've got:

Warning: simplexml_load_string(): Entity: line 2: parser error : StartTag: invalid element name in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ><option>title</option><option>number</option></chapter></archive><rss><option>< in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ^ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): Entity: line 2: parser error : expected '>' in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): title</option><option>number</option></chapter></archive><rss><option><0>image</ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ^ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): Entity: line 2: parser error : Opening and ending tag mismatch: option line 2 and unparseable in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): title</option><option>number</option></chapter></archive><rss><option><0>image</ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ^ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): Entity: line 2: parser error : StartTag: invalid element name in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): le</option><option>number</option></chapter></archive><rss><option><0>image</0>< in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ^ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): Entity: line 2: parser error : expected '>' in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ><option>number</option></chapter></archive><rss><option><0>image</0><1>number</ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ^ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): Entity: line 2: parser error : Opening and ending tag mismatch: rss line 2 and unparseable in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ><option>number</option></chapter></archive><rss><option><0>image</0><1>number</ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ^ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): Entity: line 2: parser error : StartTag: invalid element name in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ption>number</option></chapter></archive><rss><option><0>image</0><1>number</1>< in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ^ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): Entity: line 2: parser error : expected '>' in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): mber</option></chapter></archive><rss><option><0>image</0><1>number</1><2>blog</ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ^ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): Entity: line 2: parser error : Opening and ending tag mismatch: book line 2 and unparseable in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): mber</option></chapter></archive><rss><option><0>image</0><1>number</1><2>blog</ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ^ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): Entity: line 2: parser error : Extra content at the end of the document in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): mber</option></chapter></archive><rss><option><0>image</0><1>number</1><2>blog</ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Warning: simplexml_load_string(): ^ in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 60

Fatal error: Uncaught Error: Call to a member function getName() on bool in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php:100 Stack trace: #0 /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php(30): GrlxXML->getInfo() #1 /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML_Book.php(56): GrlxXML->__construct() #2 /home/MYNAME/follower-comic.com/_admin/book.edit.php(117): GrlxXML_Book->__construct(Array) #3 {main} thrown in /home/MYNAME/follower-comic.com/_admin/lib/GrlxXML.php on line 100
eishiya commented 2 years ago

Thanks, that at least provides a starting point. It looks like the XML that normally contains your book options is somehow busted. I wonder how that happened. Would you mind going into your database (e.g. via PHPMyAdmin, which most webhosts provide), into the grlx_book table, and pasting its full options field here? If you can't do that, then (temporarily) put echo $str; just before line 60 in _admin/lib/GrlxXML.php to output that string right before the warnings start.

Grawlix has checks to make sure it doesn't try to get data out of XML that couldn't be parsed (it should just display an error on the page), but it looks like they're not implemented quite right - Grawlix tries to do some work on the "parsed" XML before it checks that it's valid. I've pushed a fix for that to my fork :] But we still need to figure out why your options are throwing the XML parser off in the first place.

radiochio commented 2 years ago

Thanks so much for your help, I really, really appreciate it!

Here's what's in the options field:

<?xml version="1.0" encoding="UTF-8"?>
<book version="1.1"><archive><behavior>single</behavior><page><layout>grid</layout><option>title</option><option>number</option><option>date</option></page><chapter><layout>list</layout><option>title</option><option>number</option></chapter></archive><rss><option><0>image</0><1>number</1><2>blog</2></option></rss></book>
eishiya commented 2 years ago

Ah, I see the problem, the RSS options have invalid tags:

<option><0>image</0><1>number</1><2>blog</2></option>

This was something that broke with PHP8, the way the SimpleXML object is handled is different.

This and many other PHP8-related issues are fixed on my fork: https://github.com/eishiya/Grawlix-Webcomic-CMS It hasn't been merged into this repo yet because I haven't had opportunity to test certain features (such as multi-book and bulk uploads), but the parts I have checked all work fine. If you don't want to update your entire Grawlix, you can modify just _admin/lib/GrlxXML_Book.php, and if you don't want to update the entire file, you can change one line in updateRSS(), replace:

$this->simpleXML->rss->{$key}->{$key2} = $val2;

with:

$this->simpleXML->rss->{$key}[$key2] = $val2;

Another alternative is to downgrade your PHP to 7.4, but not all hosts offer this as an option. And we could always use more people testing the PHP8 update before we merge it xP

Lastly, even if the code is fixed, you've already got a busted options XML that'll keep breaking things. You need to fix that. In your database, edit it to this:

<?xml version="1.0" encoding="UTF-8"?>
<book version="1.1"><archive><behavior>single</behavior><page><layout>grid</layout><option>title</option><option>number</option><option>date</option></page><chapter><layout>list</layout><option>title</option><option>number</option></chapter></archive><rss><option>image</option><option>number</option><option>blog</option></rss></book>
radiochio commented 2 years ago

Yeah, downgrading PHP was one of the first things I tried last night when I started on this, didn't seem to make a difference, so I went back to 8.

In either case, I tried using your fork instead and (so far) it looks like everything's good! Database stuff is my personal nightmare, I never would have figured that out. Thank you so so much!

eishiya commented 2 years ago

Glad it works!

Let's leave this issue open since even though the problem fixed, the fix isn't in this repo yet.

eishiya commented 2 years ago

The update is now merged, so I'll close this issue.

Darwin1969 commented 2 years ago

WHOOP!

That worked for both the archive issue and the RSS issue! Perfect! Thank you for your help and your patience!

I will pass this on to others in my group who are doing the same kinds of builds!

eishiya commented 2 years ago

I will pass this on to others in my group who are doing the same kinds of builds!

The update is now part of the main repo, so anyone getting the latest version from here starting today should be fine :D

Darwin1969 commented 2 years ago

Very good, I will let them know that as well (I posted the fix above for people who may have already gotten started on them.) I really appreciate your help on this!