Open ksangwin opened 2 months ago
Interesting! Since I haven't encountered this myself when reordering and don't know how to reproduce it, I'd like a little more detail, please: What version of Grawlix are you using, and how did you obtain it? Does this happen every time you reorder pages, or only sometimes? It sounds like it's only sometimes? In this example, how many pages in total did your comic have, and how did you reorder your pages (e.g. what was the old page order, and what new numbers did you put in for which pages before clicking sort)? When you re-create the pages, how do you make sure the order is correct, does reordering work correctly then, or do you have to delete and recreate all the following pages?
Looks like I'm on 1.6.0. I think I installed it from here last summer. And I suspect it happens every time I re-order pages. It just happened to me again now.
So here's an example where pages ending in 47 and 46-2 were accidentally mislabeled before import and they went up in the wrong order. So the file ending in 46-2 went up before the file ending in 47 (due to it being lower in numerical order) but I needed it to come after 47. I changed the page order number in book view, effectively swapping number 54 and 55. I don't see a button to "save" these changes, so I hit "sort" afterwards, assuming that's like saving? After the book page reloaded, I notice that there's two 53's... maybe it didn't receive it's label correctly?
Now if I click on the page whose file ends in 46 (which was unchanged, but it previously pointed to 46-2) I see the next link is broken in the book view:
Similarly, the page with filename ending in 46-2 has broken nav links in book view:
If I click on 47 in book view, I see that neither of it's prev/next links work:
Curiously, it still has a thumbnail in my site's archive... although that archive link took me to the other /comic/53 (the file name ending in 46). I've tried bumping the ordering number of the duplicate #53 to become 54, but the change doesn't seem to hold. I checked my site's error log, to see if there was anything there but it hasn't updated all day....
Here is my site archive with page 53 showing the thumnail for one page, but links to the duplicate 53. If I try to navigate to the next page for 54 and 55, they both tell me the pages don't exist. If I go to 56, I'm back on track.
I was able to finally re-label the duplicate 53 as 54 just now. I had to click "Sort" afterwards for the change to be accepted. Is "Sort" like a "save" button? Am I required to press it every time I change page ordering (we really need to make the instructions more clear on this if that's the case. It's not very easy to use at the moment.)
However, my navigation is still busted in the way I mentioned in my previous post. While my pages do appear now in the archive, I can't go prev/next into the affected pages. Grawlix still says they don't exist.
Oh dear... it seems I've lost files 46-2 and 47.... they've completely dropped off the face of my book... I was just trying to reorder them.... 🥲 This feels like a linked list is unraveling from the middle and my page references are floating off into space....
I had an idea to upload the missing pages and append them to the end of chapter 1, since that's close to where they were anyways. Then I figured I could delete any pages that existed between them to get them back into position.
The result was even stranger than I anticipated. By uploading the files that went missing, they re-appeared in the book and archive and navigation between them was restored. I ended up deleting the pages I created so I wouldn't have duplicates in the archive. Things aren't 100% resolved though, since the comic site still wants to step from 59 to 60, and 60 doesn't currently exist. I guess "60" came from the extra pages I uploaded but now that they're gone, I'm getting a "page not found" type error when I try to navigate from 59 to 60. In keeping with the general trend I'm seeing, navigation is broken in book view as well. Here is 59 broken going to 60 And 63 broken going back to 59.
I'm surprised that page deletion isn't working at all. I would assume that if there's a button to delete a page, that the system would clean up the page references in the process. This feels super broken.
Also, checking my own install compared to the git commit history, it looks like I have changes from Fixes to the archive system but not from Added SORT_NATURAL flag to ksort to prevent sorting bugs Before starting my file upload attempts for this comment, I did copy over this change, just in case it's relevant.
ksort($resorted_list, SORT_NATURAL);
I was just checking for any updates to the error log and it looks like I have some warnings now. Not sure what these mean yet, but they seem related to my book/page re-ordering activity today. error.log
Thanks for the error log! While I haven't reproduced the issue you're having and nothing in the error log seems to point to the cause, I can at least work on fixing those warnings. Most, if not all, of these are due to PHP5-style checking for variables being set, which is no longer correct in PHP7+, hence the warnings. Most of the tweaks we've made to Grawlix since taking over the project has been fixing these, looks like we haven't caught them all yet.
The Sort button is the apply/save button for the sort order, yes. The name is technically correct since it sorts the pages based on the values you put in (which need not be the actual page numbers), but it's not very clear, it would probably be better as something like "Save Order".
After the book page reloaded, I notice that there's two 53's... maybe it didn't receive it's label correctly?
This seems the best clue to the cause of this. Normally, on Sort, Grawlix will sort the pages according to the new order numbers you've put in (accounting for potential duplicates by tweaking the numbers slightly), and after this is done, it renumbers all the pages so that all of them have whole-number, non-repeating sort numbers starting with 1. A lot in Grawlix depends on this, and if this step doesn't happen, things will break, and I think that's what you're seeing. The question is: why isn't the renumbering happening (correctly)? If you're interested in doing some debugging, the function that does the renumbering is reset_page_order
in _admin/inc/functions.inc.php, and it's called in several places in Grawlix, such as line 146 in book.view.php where the Sort button finalises its work. Perhaps this function isn't being called? Uploading pages also calls this function, perhaps that's why uploading the "missing" pages "fixed" the old versions of them.
Thanks for the info! I did notice reset_page_order
but I wasn't sure what function we use to log debug statements (this is my first time debugging with PHP)
Another thought that occurred to me last night was that my database might be in a weird state. Prior to this issue, I was having trouble with importing all my pages which might have setup the situation I'm in now. It was something like:
That said, should I try wiping out my database and spinning up a new one? I suppose I'll need to reinstall grawlix if I do that as well... but if I go that path I can copy my grawlix/CSS changes back to my local machine and see if I can setup git on my hosting server this time?
It's possible that messing with the database put it in a weird state since all the sanity checks are done by Grawlix PHP-side (instead of MySQL-side checks like triggers and foreign keys), but I also don't think there's all that much redundant state that Grawlix keeps track of that could cause conflicts like this. The sort order would've ended up in a weird state after the initial edit, but the next reset_page_order, which would've run as soon as you uploaded any more pages, should've fixed those.
That manually deleting pages via Grawlix didn't actually delete them is very strange. GrlxComicPage->deletePage does a DELETE (plus some housekeeping to remove the images) on the rows, so those pages should've been gone, there should have been nothing left for you to delete externally. Sounds like at least as early as that, something must've gone wrong, before you even touched the database externally.
Starting over is certainly an option, but yes, you'd have to reinstall Grawlix - you wouldn't have to re-upload all the files, you'd just need run firstrun.php again after removing the existing tables, I think (firstrun.php sets up the database tables). You may also want to delete files in assets/comics and any other files uploaded via Grawlix, since Grawlix won't "know" about any of those old uploads and won't let you reuse them.
I've noticed a couple times now that if I change the order of the pages with this drop down:
The navigation to/from them will be broken. I try running "sort" after changing their order number, and this sorts them visually but they're still broken on my website. For example, one of the pages might appear in my archive (I notice that it has some connection to the page before it that is half working..) but if I click on it, I get errors saying:
For context, these pages were post-dated from over a month ago, so they should really be available. And perhaps more telling, I saw that the navigation to/from those pages in the admin panel's book view were broken as well. (This is what I mean by "half-working". The broken page, 228 in this case, can see the page before it, but it can't see the page that comes after it, 229)
So far my workaround is to delete the affected pages and re-create them. When I re-create them, they properly link into the rest of the navigation.