WordPress media upload in wrong folder

This one is a little weird. I had inherited a web site; I do some volunteer service, and the original web site was done in FrontPage 98. People who used the web site knew the URL to a particular file on that web site: the meetings directory.

Later, a member showed me an app that was super useful; but the best way to implement it was as a WordPress plugin. I guess I’m learning WordPress now (not that I was a fan of FrontPage 98: good riddance).

After the conversion, the members that knew the URL to the meeting directory complained that their bookmarks were broken. Fair enough, I had broken them. I got a redirector plugin, and created a 301 redirect from the known URL to the new location.

But there was a problem with the new location: my default WordPress URL scheme for the uploads folder includes putting year and month in the URL. So an upload today would be in ./uploads/2023/04/

What’s going to happen next month, when there is a new meetings directory file? It isn’t going in the April folder, I can assure you. Am I going to have to update the redirect every single month?

I’ve been doing computers for 40 years. Having to update the redirect every single month is stupid. Why can’t I just move the file to the root of the uploads directory?

Well … turns out WordPress needs to have a database entry for every file. I can move the file, but that orphans that entry in the database.

Even if I do move it, how does the old office manager update it? A regular old Media Library upload will upload the new file to a dated folder, and now we’ve got two files with the same name but different locations and URLs.

I had to find a plugin that does media file replace (in-place), but that wasn’t too hard. I use Enable Media Replace by ShortPixel. It was pretty easy to train the old office manager to follow the steps: click on the file in the Media Library, find the Replace button, and follow the directions on screen.

That was six years ago. This morning, the new office manager deleted the file. She had the presence of mind to recognize that something was wrong; but not enough to halt before doing damage. The new meeting directory file now has the wrong name and the wrong URL.

I kind of hate WordPress for the permissions trouble. What looked to be simple with the WordPress CLI (command line interface), wp media import did not work. ./wordpress/bin/wp would only ever get Permission denied. I should probably mention that the “user” I’m logged in as is not the same user as who runs the web site and has access to all the files.

Here are the steps I had to take to repair the damage. I got to figure them out; hopefully you will find them useful. And if the file gets damaged again, I’ll have these instructions for a quick repair.

  1. ssh into the server and find the uploaded file. In this case it will be in ./uploads/2023/04/
  2. rename the file to the old file name.
  3. move the file from ./wordpress/htdocs/wp-content/uploads/2023/04/ to ./wordpress/htdocs/wp-content/uploads/
  4. Delete the file in the WordPress Media Library (web page). WordPress will still show you the file, because it isn’t looking at the file, it’s looking at it’s database entries about the file. It looks like the file is there, but it’s a phantom. Delete it.
  5. Back to the server command line prompt: change the file system permisssions to be way too permisive.
  6. ./wordpress/bin/wp media import ./wordpress/htdocs/wp-content/uploads/file.pdf --path=./wordpress/htdocs/ --skip-copy
  7. change the file system permisssions back. ASAP.
  8. When you look at the WordPress Media Library (web page), you will see your file again – but this time it has a non-time-stamped URL. Huzzah! Paste that link into whatever page needs to serve it up. In my case, since I moved the new file to where the old file was, the links were still good.

How to give way too many permissions (this is terrible):

sudo chmod -R 777 /path/to/folder/wordpress

How to fix the permissions:

find ./wordpress -type d -print0 | sudo xargs -0 chmod 755

find ./wordpress -type f -print0 | sudo xargs -0 chmod 644

Windows 11 first impression: it is awful

I want to have a shortcut open cmd.exe with a starting folder location. Not difficult at all in Windows 10.

In Windows 10, I could scroll through the Windows menu and find Command Prompt and then click-and-drag to make a shortcut on my desktop. Then I could modify the properties as I want.

Windows 11 doesn’t let you do this. It will launch the command prompt, and it will let you pin it to either the task bar or the start menu – but those shortcuts do not have properties you can modify. Well, one of them did, but starting folder was not a property I could set.

“Well David, how about choosing New Shortcut and following the prompt?” Okay, sure. Right-click the desktop, choose New ==> Shortcut. It asks “What item would you like to create a shortcut for?” You tell me, dimwits. Under Windows 10, I’d copy the existing shortcut and that would be defined for me already. Does your dialog box have a search function in it? No.

Great. I need to crank up a Windows 10 machine so I can find the location on that box, and on the Windows 11 box browse through arcane mysteries of %windir%\system32\

Finally, I’m getting a shortcut started, and now I need to set the starting directory. Windows 11 helpfully removed the Browse button….

I swear, it seems like whomever is in charge of Windows hates their users and are doing shit just so that the next time their annual review comes up, they can say that they did shit. Sure, it was shit that made user’s lives worse, but there isn’t a feedback mechanism for that, now is there? So that didn’t happen.

At least the icon picker still has a Browse button.

Factorio map generator seed

4010922000

I like this one because there is oil near (enough) and the biters are far enough away that I get some time to build defenses before they go full on constant attack mode.

  1. Start a new game
  2. Next to the Map generator screen
  3. Paste in the new seed
  4. Adjust Resources, terrain, enemy, and Advanced.
    • I change Research queue availability to Always
  5. Preview

Here’s a jumpstart iron miner and smelter:

0eNqdlNtugzAMht/F16FqIDTAq0zTxMHrIoGDknRbVfHuC616XNpSLp3In3//lr2Dqt1gbxQ5KHagak0WircdWLWmsh3f3LZHKEA57IABld0YVRtDaKJOkaJ11BjVtjAwUNTgLxR8YE8J1mnC6NNzyhovcuPhnQGSU07hQco+2H7QpqvQePhDEQx6bX2uprGy58mEwRaKKI19jUYZrA+fYtR4g45P6B+tG6So/kLrAsx0kR6pi3QIkJJbkYosGue//sPEFexKZBxAizsW3u98GVKYnjDOlGR7bVxUYfu42+WtwJCLqxd6P6N52Ej5Aiw5wkQWhmVzpiLyKVPJZ9i5l/nUTr6cg84nofksQ7IphvDJy3QemxzH5td/fymKi9PE4BuNPdTKuJB5LOVKcBlnw/AHrQGN8Q==

My favorite coal jumpstart rig Early Coal Mining Rig:

0eNqdl91uozAQhV8l8jWJbOMfzH0v+wTbqiKJVVkCg4yzahTl3euUlTaNIHjmErA/jg8zzMyF7NuTHYLzkdQXcrTjIbghut6Tmrw0oT1vOued/9wc+m5o7dfuzZOCuEPvR1L/uZDRffqmve2N58GmTS7aLq3wTXe7iqHx49CHuN3bNpJr2uqP9ovU7Fqsbt6fgrdhOwnYHoNr2zsCv74XxProorOTlp+L84c/dXsb0iuWVBRk6Ec3HfJCEmqryp0syJnURuxkesXRBXuYFvCb0Acyx5BlIs+wSgCLg1SKp0bO4Se4mpMpATIpSKYCkBmIrKEG0CcGVPkyZQWSaQBkAyIzCnRAVk8cYICEkuo+7H8JFXNojkGLLDQgwaSG2Ssw/wE1/x9gEgPTCzD1+OGdH22I6dmzrNJZhmoIm64prQC0/+Gfp9RA2NWKUk4xMaqy6gmDCFVrQjmEpkGWckg2SRhaYNAqC43KrWrBXoWBmQWYxpT/KuvQFQZtHtFqDm2glZX9o6/LLsE1y+SzGZSt89kcE74m50uWqKTLCpJSIIKEUbrQy0pELzfRVmOuVIgONJetES1YLhvTOOayDaK3yWQLTLnLZTNEQM+wxW0E/JkZ67s5tiBtk2Dp3uuv0XVDWXr214ZxKsQVE1oYrTSjSqaO9xt1u+Xz

Microsoft Outlook.com is playing Catch-22 with me

My SMTP mail server is relatively new, and it took a few weeks, but Microsoft has blocked it’s IP address. The non-delivery report (NDR) says this:

For further assistance, please send mail to postmaster.

Care to guess what gets rejected because I’m on their block list? That’s right: postmaster@live.com and postmaster@outlook.com

For what it is worth, I’m currently getting a 9.8 out of 10 on mail-tester.com: https://www.mail-tester.com/test-1dcmfmxh8

OpenSuSE upgrade did not work – reinstalled fresh from a new ISO

Pro-tip you should have done a decade ago: add a second hard drive to your machine, and put /home on it. Then during the install of the fresh OS, do not format that disk, simply mount it as /home

In a previous post, I was whining that YouTube videos were not working. I also (rather mean-spiritedly) implied that maybe Google was screwing with the connection because I was looking for ad-blocking videos. That was wrong: this fresh install of OpenSuSE has fixed that problem.

Of course, never does a single thing change, and I happened to roll over into the new month, so T-Mobile doesn’t see me as over my “unlimited” transfer limit.

But for all that testing I did, what I hadn’t tried was Windows versus Linux. I saved off a problematic YouTube link to my NextCloud Tasks, and logged in to it on a Windows machine. It played perfectly.

D’oh! It’s my OpenSuSE machine that’s borked.

I’d done an Upgrade per SDB: System upgrade to Leap 15.4

So I downloaded the ISO and did an Install not an Upgrade, and now that problematic YouTube video plays correctly.

I’m still going to have to install all the packages that went away. But that is a trade-off I’m willing to make, for being able to see videos of how to open up the connection to Mariadb running on a Synology NAS (for example).

I dread upgrading OpenSuSE to a new version

This time is no different. Ugh.

It always breaks so much stuff.

I don’t understand why it’s so hard to keep the list of Image Magick delegates from one version to the next.

I don’t understand why it’s so hard to find how to add the delegates that were removed during the upgrade.

Today, I need to convert a PDF to a PNG and convert -version tells me I have support for

  • bzlib
  • lzma
  • x
  • xml
  • zlib

none of which are image related.

Of course, this work I need to do is time-sensitive, and instead of being able to get events published to the web site for this coming weekend, I’m having debug why Image Magick is broken again.

I’m an hour in, and it’s still broken, and there’s zero information on how to fix the problem. One person said “just install from xxxx and it just works” – no, it doesn’t.

It shouldn’t take an more than an hour to convert one file from PDF to PNG.

Sometimes I hate being on OpenSuSE.

To be fair, SuSE was always more geared to be a server operating system, on which one could install a desktop environment. And with server environments, one needs to be a little more careful than with a desktop environment. If I break something on a desktop: one person (me) is affected. If I break something on a server: a thousand people are affected. So SuSE doesn’t tend to rush to implement the latest / newest thing. It also imposes defaults that are more secure (less permissive) than you might find on something else.

But apparently during the upgrade, something was reset to not allow me to execute magick filename.pdf filename.png and I’m having a damned time figuring out how to fix that. There doesn’t seem to be a README file anywhere that explains it.

I assumed that when I went into YaST and added ImageMagick and Ghostscript that things would work. You know what you get when you assume, correct?

Nextcloud web on mobile: remove iOS App prompt

New update: A little while ago, I updated my Nextcloud client on my iPhone, and a feature has been added to the “Use The App!” pop-up to turn it off. Thank you! I no longer need to mess with layout.user.php file on the server.


Log in to MySQL, and run this:

insert into oc_appconfig(appid,configkey,configvalue) values ('theming','iTunesAppId','');

There is a file in Nextcloud, layout.user.php which pushes a link to the iOS app. I wish to remove that. It will come back, every time Nextcloud pushes an update, so here is a note on how to remove it.

The file is (web root)/core/templates/layout.user.php

The three lines to delete are:

<?php if ($theme->getiTunesAppId() !== '') { ?>
<meta name="apple-itunes-app" content="app-id=<?php p($theme->getiTunesAppId()); ?>">
<?php } ?>

I don’t know if there is a setting anywhere in Nextcloud which would let me simply disable the prompt to use the app. I don’t see such; so the fallback is to edit the source code. It would be nice if there were a setting stored in the database instead. When the Nextcloud people publish an update, the recorded setting could keep the “Use The App!” prompt disabled. But I don’t think there is a setting I can get at which lets me control this.

That php code implies that the theme could have a setting; but I don’t see anything in the theme setting page for a flag of getiTunesAppId.

Mostly, I use the other pieces of Nextcloud: Calendar, Tasks, Music, and Dashboard. For those, that “Use The App!” prompt is a waste of screen real estate on a platform that doesn’t have a lot of screen real estate to waste.

I wouldn’t terribly mind if the “Use The App!” prompt showed up if I were to visit the Files part of the Nextcloud web UI: that’s the only thing the iOS app is good for. But I almost never use the Files part of Nextcloud when on mobile.

I’ve asked the people in the Nextcloud support forum if I’m missing something; this could be a solved problem already. If I get an answer back, I’ll update this post.

User dakkar-tn did answer my post with the database query above. I am very appreciative of his help.

Rename audio files to just their titles

Another exiftool operation: suppose you have a bunch of files named something like this:

01 - String Quartet in B flat Major, 1st movement "Allegro".ogg
02 - Sonata, K. 310, 1st Movement (Mozart - Alfred Brendel).ogg
03 - Asturias_Leyenda (Albeniz - Alirio Diaz).ogg
04 - Massenet: Meditation from Thais (Mischa Elman).ogg
05 - La Coulicam - Rondement (Rameau - Harnoncourt, Lars Fryden).ogg

11 - Sonatine en trio "Modere" (Ravel - Orpheus Trio).ogg
12 - Preludes - La cathedral engloutie (Debussy - Sviatoslav Richter).ogg
13 - Eili, Eili (Mischa Elman).ogg
14 - Simple Fugue (Gr. 1, D. 1) (Bach - Gustav Leonhardt).ogg
15 - A Felicidade from Black Orpheus (Paula Robison).ogg

But really, you want the files to just be named after the Title of the song. You don’t want the leading track number, and if there are any characters in the file name that would cause Windows heartburn (like slashes, colon, asterisk, question mark, etc.), you would like those stripped out too. For example: Massenet Meditation from Thais (Mischa Elman).ogg

Here’s a handy command:

exiftool '-Filename<${Title;}.%le' *.mp3

So we have exiftool which is the utility that does the work. Thank you to Phil Harvey for doing the work to make this easy.

Then we have two parameters:

'-Filename<${Title;}.%le'

*.mp3

The second parameter says to work on files with the filename extension of .mp3

The first parameter breaks down like this:

-Filename<

Note that the non-change-making version is -Testname< (for testing, obviously)

-Filename tells exiftool that it will be updating the file name. The < symbol says that the replacement for the file name will be incoming from the rest of the parameter.

What follows after the < has two pieces: ${Title;} and .%le

${Title;} is the processed text from the metadata variable Title. The leading $ and the { and } with the ; before the closing curly brace serve to strip out any invalid characters found in the title that wouldn’t work as a file name.

.%le appends a file name extension. Technically, .%e is the file name extension, but adding the l makes it lowercase. So we get the Title as the first part of the file name, and the last part of the file name is .mp3 (because we told exiftool only to look at .mp3 files).

Three Dog Night concert February 10, 2023 Visalia Fox Theater

So much fun. I am glad I went. Three Dog Night was popular when I was in elementary school: they had 21 hits in the top 40 in six years (beginning in 1969). I don’t remember the words too many of their songs, but I do remember singing along to them as a kid.

Some of the songs they did were An Old Fashioned Love Song, One (is the loneliest number), Black and White, Celebrate (dance to the music), Mama Told Me (not to come), Never Been To Spain, Liar, and of course my favorite song of theirs: Joy To The World.

The guys in the band are getting pretty old, but they did seem to be having a lot of fun.

On the one hand, I want to say it was a great show. But on the other hand, I cannot ignore that the mixing was poor. Did I have fun? Yes, definitely. Would I have enjoyed it more if I could have heard the vocals clearly? Definitely.

The band did say they are working on their first new album in twenty years; they sang a song from it. It started out a cappella, and the sound was perfect. The song was beautiful in both lyrics and sound. I’m looking forward to buying the album when it comes out.

But the fact that the vocals were perfect when the mix was a cappella, and indiscernible when instruments were mixed in makes me think it was the mixing that was the problem.

The Visalia Fox Theatre has good acoustics. It is a small enough venue that booming big box echoes aren’t a problem. The theater was packed, so nice absorption. The opening act was one guy and his acoustic guitar: he sounded great. Great singer too.

So it was pretty disappointing that during the first song, I could instantly tell that the vocals were being drowned out by the background instruments.

I enjoyed the show, and I am glad that I went. But I suspect that they would have gotten a warmer reception if we could have heard them well. I’m not trying to say they got a cool reception; they did not. But I do think everyone was hoping for better sound.

Factorio blueprint Extended Starter Base

Extended Starter Base (45 SPM / RGMB Science / Mall)

Features:

• Inputs: 1.5 belts of Iron Ore, 0.5 belts of Copper Ore, 1 belt of Stone and Coal (one belt of Coal is enough to power the base*, smelters and produce all coal-required items); Petroleum Gas and Water (on either right or top side);

• 45 of Red, Green, Grey (Military) and Blue Sciences per minute (with circuit conditions countering the distance from the labs to insure no expensive science packs excess production);

• A (sorta spread-out) mall with all items you need early to pre-mid game including a big military wing with multiple Flamethrower Turrets/Explosive Cannon Shells factories and one Cliff Explosives factory;

• 15 Labs to fit the Lab Research Speed 2 research speed requirement;

• Only four Red Underground Belts needed at the very later stage of base building (Blue Science and Explosive Cannon Shells factories), no Red Belts needed up to that point;

• An empty 4×4 zone in the middle of the base for a Roboport to be placed later, covering up most of the chests with produced materials;