I’ve broken, then fixed the favorites code

TL;DR: I fixed the favorites so everyone can use them on all the subsites, I may have wiped yours, if you’re missing all your favorite posts, let me know below.

There’s a rather nice wordpress plugin that allows users to add posts to their favorites, but it’s broken in several ways, the big ones are:

  1. No wordpress network support, we didnt’ see that too much here since there’s only about 5 sites on the MCS network, but I have about 80 sites on my TWG network, but that’s still on php 5.5
  2. No php 7.1 support, primarily brackets no longer get automatically translated into arrays when you try to append a value to it.

The guy that original wrote the script made some interesting choices like putting all the favorited posts for each user into their own serialized string in the database, which coupled with the get_user_meta’s choice to return strings and not arrays if there’s no results of the query…well that caused some headaches.  There was a point where I upgraded the site from php 5.5 to 7.1 and we got all sorts of nice performance increases, but it incidentally broke the ability of anyone new to the site to add favorite posts, which I discovered when I was trying to fix the images for the  Top 10 page over on the NSFW side of the house.  Some of the images are still broken, but the thing that really attracted my attention was the fact that the “most favorited” sections weren’t populating at all.  That was a damn week ago, but now I have that fixed I can move onto fixing the images.

The images are going to be a bigger issue to fix, because the images are broken due to a decision I made nearly 5 years ago to make a separate subdomain for the NSFW content.  The decision itself was sound and I think it’s turned out for the best.  My method of doing it though was to export all the posts that had a category of NSFW and import them into a new wordpress install.   Everything’s gone great except for some weird image and url issues with the posts, which I just recently discovered was due to a column in the wordpress database that still had the original www url on it.  While I could just find and replace those values, there’s about 20,000 posts with them and I’d rather not blow everything up.  I first ran into the problem when I redid the archives, it worked great for the main site, but good god it’s a mess to load the images from the NSFW posts. I have like three nested if statements and http_referrer checks to see if you’re asking for the post from the nsfw subdomain.

There’s a small possibility that I nuked your favorites.  I made a back up of that column before I started messing with it, so if you’re missing yours let me know below and I’ll restore them.



  • Leave A Comment

    Subscribe
    Notify of
    0 Comments
    Inline Feedbacks
    View all comments
    Advertisements Alcohol Animated Images Architecture Art Awesome Things Batman Bikinis Black and White Cars Comic Books Computers Cosplay Cute As Hell Animals Donald Trump Drugs Fantasy - Science Fiction Fashion Food Forum Fodder Gaming Humor Military Motorcycles Movie Posters Movie Reviews Movies Music Music Videos Nature NeSFW Politics Religion Science! Sexy Sports Star Trek Star Wars Technology Television Vertical Wallpaper Wallpaper Weapons Women WTF

    480 x 360 500 x 281 500 x 375 500 x 500 500 x 750 600 x 450 600 x 600 600 x 750 600 x 800 600 x 900 640 x 480 640 x 640 640 x 800 640 x 853 640 x 960 720 x 720 720 x 960 750 x 600 800 x 600 800 x 800 960 x 720 960 x 960 1024 x 683 1024 x 768 1080 x 1080 1080 x 1350 1200 x 630 1200 x 800 1200 x 900 1280 x 720 1280 x 800 1280 x 960 1280 x 1024 1440 x 900 1600 x 900 1600 x 1200 1680 x 1050 1920 x 1080 1920 x 1200 2048 x 1536 2560 x 1440 2560 x 1600 3024 x 4032 3840 x 2160 x

    ABoringDystopia Amoledbackgrounds AnimalsBeingDerps ATBGE awfuleverything Celebhub Celebs CityPorn comicbookart conceptart cosplaygirls Cyberpunk EarthPorn Eyebleach Faces FreckledGirls funny General Uploads gentlemanboners hmmmm Images Sub Space ImaginaryStarships ImaginaryTechnology InfowarriorRides interestingasfuck MarchAgainstNazis marvelstudios MCS Plus memes MilitaryPorn nocontextpics OldSchoolCool pictures PoliticalHumor PrequelMemes PropagandaPosters RetroFuturism sbubby StarshipPorn startrekmemes Storminator Super News Thanks I Hate It UrbanHell wallpaper