Archives May 2022

Update #9 Lessons learnt after WordPress update

I don’t check my blog every day (and I think you don’t either). Just today I gave my URL to a colleague and more or less by mistake I clicked the link. And so I found out that my site was showing without any CSS and therefore being completely dis-functional. Also the admin pages did not work! Mild panic…

It has taken a few hours to figure out what happened and finally how to fix it: On May 24th an automatic WordPress update was installed. First I thought this had broken my WordPress theme. But even after hacking the database to change the theme to the default theme, the problem was still there.

After some more frustrated trial and error and a lot of googling, I finally had my “Aha Erlebnis” (https://en.wiktionary.org/wiki/Aha-Erlebnis). The new WordPress update had overwritten the wp-settings.php file. This file requires an extra line for my site to work with https. How I figured this out when I started with WordPress, is another story full of frustrations. Anyway, adding the following line to wp-settings.php solved my problems:

if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') $_SERVER['HTTPS']='on';

Now, is there a learning and can I avoid this problem in the future? Well, that is a YES and a NO at the same time.

Read More

Update #8 Worst code ever :-)

I am finishing the chapter on packages, scope and access. Not the most sexy topic, but I am happy to do it. It was itching already for some time when to use public, private, static, final etc… It was used before (of course), but not really explained. Now it is. Again, not something you will need to know in detail in daily practice, but I sorta think this is fundamental knowledge that is good to have.

As part of this chapter, there was a fun challenge to illustrate scope. The assignment: a program that prints primary school “times” list for a value. E.g. for value 3 : 1 * 3 = 3, 2 * 3 = 6, 3 *3 = 9 etc….

One specific condition: all variables, members, methods and classes have to be called x (or X for the class)!! It results in completely unreadable code, but due to scoping in Java, it can be done. See if you can follow the code 🙂

Read More