SamuKata
Touhou-Project.com
Touhou-Project.com

patreon


Conscious Uncoupling

Hello all, hope you’ve been well! It’s time for another (very) overdue entry on what I have been working on and the recent changes to the site.


You might recall the last time that I mentioned that I was working at normalizing data in the site’s database. A lot of progress has been made on that front and, as of earlier today, the site now fully has a separate table for keeping track of files and associated data. Exciting stuff! 🥳🎉


I’ll spare you the more … abstract, possibly philosophical, arguments why this is a desirable state of things other than briefly saying that it’s a more sensible way of organizing data and doubles as a way of optimization. The latter is easy enough to understand: Instead of every query made to the post table having a lot of extra data about image information (name, filesize, dimensions etc) that may not be used because an operation doesn’t really need it, it’s only appended in specific cases with a relevant join command.

Though that’s all fine and dandy and I could say more about it, I’ll instead pivot to the more practical (to users) aspect. Since images are now wholly decoupled from posts themselves, it also means that having an arbitrary amount of entries on another table that share something like a post id is also possible. These could then be included when you’re calling post information, adding to them multiple entries of file information. So, in other words, it would be possible to have multiple images or other files attached to a single post.

To be clear, I haven’t gone as far as fully implementing that as other parts of board software would need an overhaul, specifically the way file uploads are handled and processed and various checks for spam, validity, etc etc.

But these changes do mean we’re a significant amount of the way there! Indeed, I think I can say that most of the way there, with the more difficult cruft having been dealt with.

This seemingly simple change did involve a lot of preparatory work and involved fiddling with most of the site’s code base. It might not seem obvious but most parts of THP assume specific formats for post data—and it’s not just the queries. The front page, posting, post/file deletion, thread generation, various management staff actions, and all sorts of things parse file data and had to be adjusted accordingly. All in all this meant the partial rewrite of numerous functions and methods which represent a few hundred lines of code. And, well, that implies a lot of testing and it took a long time to make sure that functionality was equal to the old way and that there were no bugs introduced along the way. I spent probably more time testing than writing code, which along to my limited free time partially explains why I haven’t been able to push these changes faster.

While I was at it, modifying database tables and related functions, I took the opportunity to spruce up some of the management tools and distinctions between staff levels. There were a few outstanding corner cases regarding deleting posts and files in a certain way which have been standardized and things like reviewing actions taken by other staff is clearer to admins. The most lower level staff, who cannot ban users but can delete content, have been given more flexibility when it comes to deleting images and mods given greater ease for accepting their actions or restoring content. I’m trying to avoid too many specifics because you likely don’t want to hear the specifics of how this necessitated adding another database table and redoing file quarantine functionality, so you’ll have to take my word about how it had to be done in a meticulous fashion.


As a lot of file-and-post-related things were being worked on, I also took the opportunity to further improve some of the anti-spam capabilities and necrobumping checks. I think that the internal logic as to when a thread can no longer be bumped is now more consistent and should take care of edge cases such as an author updating an old thread past the post limit and others being unable to post. There’s more overrides for staff, as well, to make sure that if the need arises, posts can be made by moderators regardless if a thread is auto-locked. Some of these related changes also help out when there’s threads for a single entry across many boards, such as a contest threads, so it won’t lock users out from responding in the proper place.

To wrap up the file and posting stuff, I’ll add that I’ve also made sure that there are better error messages whenever very large files or those of the wrong format are posted. These messages were mostly there but there were issues with the initial, client-side HTML form data where it’d preempt the server-side warnings and give unhelpful flashes of white to users when they tried posting excessively large files. A simple Javascript pop up will warn you of the max file size now. And, well, if you’re a cheeky fellow that has disabled scripts or modified the client-side check, you’ll still run into the old server-side warnings and your post will be disallowed.

On the subject of warnings, errors, and status messages, that bit of the code has gotten a looking-at as well. More precisely, the parts of code that let users know that they’ve deleted a post, reported something successfully, and the like will no longer output an unstyled flash of white. Instead, there’ll be something more along the lines of the actual error pages, offering much more legible output before the user is automatically redirected. It’s a small thing that’s nice to have—nothing revolutionary—and I took to overhauling a few templates, related style sheets and HTML, and the functions that generate errors and messages like these. It wasn’t exactly smooth sailing and I lost a little too much time trying to fix a bug in a function before simply doing it another way but relatively painless after the aforementioned file overhaul. All in all, always worth it to do quality-of-life things, even if they are small.


On that note, the user-facing scripts also got a slight tune-up, taking care of a few possible corner cases relating to watched threads and keeping track of staff status. More importantly, I had the opportunity to add in a small but cool feature: hovering over a time stamp of a post will display its relative time (eg: 4 hours ago). It’s a silly thing I’ve had on my list for a while but as I was tweaking other stuff I decided I might as well go for it. Now you, too, can enjoy comprehending more completely the inexorable passage of time when you see that your favorite story was posted a decade or more ago. I thought of making it a toggleable function, allowing users to prefer relative time and having the full time on hover, but that hasn’t made it to this round of changes—I think it’s probably better left when future overhauling to post layout is complete.

And well, there’s a lot more I could say. Lots of bugs fixed, code updated to be compliant with future versions of PHP, and other small features, like having emails sent to mods when brute force attempts are detected here and there, have been rolled out. Instead I’ll spare you all more tediousness and tell you that there’s far more in the works and it hopefully won’t take as long to have ready. More concrete steps towards larger overhauls have been taken and I’m looking forward to being able to share them.

I’ll try to be better about status updates as well as I realize that radio silence isn’t the best look.

All the same, until next time, take it easy!

Comments

Always good to see work continuing and hear about it. Thanks for your hard work, as always!

Benjamin Oist


More Creators