Login to participate
  
Register   Lost ID/password?

Louis Kessler’s Behold Blog

A Bit of Downtime on my Sites - Thu, 6 Jan 2022

Sometimes, website changes go smoothly.

Sometimes they don’t.

On December 28, I had a couple of rare free days, and I thought I’d finally get around to seeing if I could upgrade my sites from PHP 5.6 to PHP 7.4. The programming language PHP is what runs WordPress and does most of the automation of the webpages that transfers data to and from the MySQL databases that contain everything.

I mentioned the necessity to eventually upgrade the PHP version in my blog post from a year ago:  Averting Blog Disaster

It would be nice if I could just flip the switch and everything worked. But then, these are computer systems, and as everyone knows, nothing ever goes smoothly when it comes to computer systems.

My major use of PHP is in my Behold blog, my Behold forum and my GenSoftReviews site which use installations of WordPress on my sites.

I had two choices

1. To upgrade my versions of WordPress so that they’d be the current version that work with PHP 7.4, or

2. To fix any of the underlying PHP code that doesn’t work properly under PHP 7.4 and get it to work.

Only one of these options is truly viable for me at current time. GenSoftReviews has at its core a WordPress plugin that turns it into a rating site. To upgrade wouldn’t only mean WordPress would have to be upgraded, but it would mean that plugin would have to be upgraded as well. Unfortunately, the ratings site plugin is no longer available and I’ve already got the latest version installed on GenSoftReviews. In addition, I’m using about 12 other WordPress plugins on GenSoftReviews and/or my blog/forum, and half of them are in the same boat.

The other problem is that I custom coded my WordPress sites with all sort of nice features that I really like. If I upgraded WordPress, I would lose all those customizations. I’d have to go back and implement them all over again.

I figure upgrading and recustomizing would take me about a month. But fixing the code seemed like it would be easier. If all worked perfectly, I estimated that I’d be able to get the PHP code working in maybe a couple of days.


Step 1: Get it running in my Development Environment

On my computer, I keep a copy of my websites for my own development work. I run them locally on my computer when needed using IIS (Internet Information Services), Microsoft’s webserver.

I have installed PHP and MySQL (the database PHP uses) on my computer. I set up 3 different versions of PHP under IIS and under IIS’ PHP Manager, I can select which one I want to use.

image

The switch is instantaneous. I can select 5.3.28, press OK and open Edge and view my local site in that version of PHP. I can then select 7.4.1, press OK, switch to the site in Edge, press F5 (refresh) and *tada* it’s displaying in the new version of PHP.

This allows me to easily test old version versus new version side-by-side and ensure everything that’s working in 5.3 is also working in 7.4.

I don’t have the greatest development environment for PHP. I’m sure there are good debuggers and PHP development interfaces out there somewhere, but I’m happy enough usomg the good old technique of trackomg down where a problem is happening by adding a debug and a halt statement directly into the PHP code, i.e.:

echo “Here I am!”; exit;

If the “Here I am!” displays and it didn’t get to the problem, then I know the problem happens later in my code and I move the debug line down and try again. If the problem displays, then the “Here I am!” is after the problem and I move the debug line up and try again. I follow the path through the chain of modules that are called to discover which module and what line is causing the problem.

The first issues I encountered were some PHP commands that were either deprecated or otherwise illegal and no longer available in PHP 7.4. These included:

  • "=& new" needed to be changed to "= new"
  • "= @ =" needed to be changed to "="
  • I found two parameters of a function had the same name (both were named $deprecated) which newer PHP doesn’t allow, so I changed the second name to $deprecated2.
  • I found a few PHP opening tags (a less than sign followed by a question mark followed by “php”) without the "php" in them, which won’t work in 7.4.

Once I found those, it wasn’t too difficult to search my code to find all occurrences and fix them.

A more severe problem was that the PHP MySQL extension is now deprecated and I needed to switch it all over to MySQLi. The conversion is non-trivial, but I found and used this great page for the conversion. I then rewrote the entire wpdb.php  (WordPress database) module as well as any other occurrences of MySQL commands to use MySQLi.

This took me a couple of days to do. Once I completed, I had GenSoftReviews and my Behold blog and forum all working on my computer in my test environment.


Step 2: Copy the Changes to My Live Website

I use the program Beyond Compare to copy my local files to my live website. It can compares my local website directory to its corresponding live directory at my webhost Netfirms and shows me which files are different. I can then see the differences within each file and easily update the ones that need to be updated.

So I copied over the files. Netfirms also has an interface allowing me to change the PHP version used on my live websites:

image

They allow selection of 8 different versions. I was running PHP 5.6.  The simple selection of “7.4” changes it to that version. Like in IIS on my own machine, the change is instantaneous on my live site. I can make the change and refresh the page and see the difference right away.

But that’s not what you want to do on a live website. You really want to make the change once and have everything work from that point on. With it all seeming to work fine on my test site, I was optimistic that everything would work fine.

But I was wrong. Version 7.4 didn’t work. The sites wouldn’t display. I spent a few hours trying to debug the site live and ran into problems.

I tried to recover and set everything back to PHP 5.6 and leave it for the morning to figure out. … But disaster. GenSoftReviews displayed okay again, but my Behold blog and forum would not. I tried what I could to get them going again in 5.6 but no luck. Something I changed prevented from working again in 5.6.

So sadly I put up the following message that was to be displayed on my blog and forum for the next few days:

image

Some GenSoftReviews Fixes

I thought it best to see if I could get GenSoftReviews going first. There were a few reasons:  I thought it would be easier because GenSoftReviews is made only from WordPress, whereas my blog and forum are a much more complex combination of WordPress and bbPress. Also, I was hoping to announce the 2021 GenSoftReviews User Choice Awards in the new few days, so I needed the site running well for that. And I was hoping that any fixes I needed to make for GenSoftReviews might also apply to my blog and forum and maybe those alone would be enough to fix them, or at least get them to display.

There were quite a few things needing fixing on the GenSoftReviews site.

First, special and accented characters were being displaying incorrectly:

image

A question mark enclosed in a black diamond was being displayed instead of the correct character. The first thing I did was check the database. It is UTF8 and it did have the correct characters in it. That verified it was just a display issue.

It took me a while, but I found the solution as the top answer for this StackOverflow question: UTF-8 all the way through. My fix was to add a set_charset command prior to the selection of the mysqli database:

$this->dbh->set_charset(’utf8mb4′);
mysqli_select_db($this->dbh, $dbname);

The second problem was one not visible to users. The Wordpress admin pages which I need to maintain the GenSoftReviews site were not including the CSS (Cascading Style Sheets) for the site’s theme, so they were just being displayed to me on a blank page.

The reason why I write these sort of one-off technical blog posts is to not only help others who might be running into problems doing something similar to what I’m doing (e.g. upgrading their PHP version), but also to be a place where I can record what I did so that I can come back to recall what that was if I have to do it again in the future. I mention this because, it’s now only a few days later, and I’ve already forgotten what I did to fix the CSS problem. I did fix it however, and if I do remember, I’ll come back here and include what I did.

The third problem was when a review was posted, it was not using the user’s name he entered but was always replacing it with the default: Anonymous. I found that the WordPress filter called “pre_comment_author_name” was blanking out the name the user entered. This was happening in my test environment as well. I didn’t know why and couldn’t fix that filter, but I fixed the problem by using the “the_author” filter instead.

Along the way, I found that the ereg set of commands were deprecated and no longer worked and needed to be replaced with the preg set, i.e.:

  • ereg(‘xxx’ –——> preg_match(‘/xxx/’
  • eregi(‘xxx’ –——>preg_match(‘/xxx/i’
  • ereg_replace(‘xxx’ –——> preg_replace(‘/xxx/’

I found a few 3 parameter eregi calls. The third parameter does not have an equivalent in preg_replace, so those calls are better changed to “mb_eregi” which will do the same and is supported in PHP 7.

    This next one was a tough one. It took me a full day to track down:

    preg_replace with the “/e” option should not be used. Instead use preg_replace_callback.  I found the solution at this page: https://core.trac.wordpress.org/ticket/8689 which helpfully lists all its locations in the WordPress code and the code to replace each occurrence with. Also see: PHP – How to fix the "Warning: preg_replace(): The /e modifier is no longer supported" error in PHP7 (ryadel.com)

    The secret trick is to replace:

    preg_replace(‘#aaa#e’, “bbb”, ccc)

          with

    preg_replace_callback(‘#aaa#’, create_function(‘$match’, “return bbb”), ccc);

    These changes got the live GenSoftReviews site working well under PHP 7.4.

    Getting the Behold Blog and Forum Going Again

    First, I went through all the changes done at GenSoftReviews and did the same where applicable on my blog and forum code.

    There was still a major problem as my pages would not display and there was no error message. So I did the painstaking step-by-step tracking and after a full day of debugging, eventually found the problem was that the hostname for the database was inadvertently set to “localhost” when it should have been “lkessler.netfirmsmysql.com’”.  I’m not sure how I got “localhost” copied from my test server to my live server, but however I managed to do that, it cost me a day of my time and an extra day downtime for my blog and forum.

    Once I fixed that, my blog and forum finally appeared again. But the page would timed out and never finish. That one didn’t take me too long to track down. It was a plugin initializing, so I just commented that out for now and presto, all my blog posts were available again.

    Final Analysis

    As I write this, I’ve now got GenSoftReviews working well, and my Behold Blog and Forum at least back up and displaying all the posts. There’s still some issues left to fix in my blog and forum, such as getting that infinite-loop plugin fixed as well as a couple of other minor items such as the archive year links not working. But I can now relax and fix those in the background over the next few days.

    GenSoftReviews wasn’t down for long, maybe a few hours while I was debugging live. My blog and forum however were down for 6 days from Dec 30 to Jan 5. But now that they’re running again, a bit of downtime wasn’t the worst that could have happened.

    Sometimes you just have to tackle the problem and not give up. The result is worth it.




    Followup: Jan 15, 2022:  I still had a few more puzzles to solve to get everything working right and for a few minutes now and then, my blog or GenSoftReviews might have been down during the past week, or showing strange debug messages. The worst problem was one only on my live site that would cause the server to time out, and if I did it a dozen times in a row while testing it  occasionally bring up this nasty message:
    image

    and I’d have to wait a few minutes for the SQL server to reset itself again before I or anyone else could continue. It took me about 16 hours of debugging over 3 days to track down and fix this particular problem. Believe it or not, the final fix was to initialize an array to null prior to using it in a function call:

       $query_args = array();    <== Had to add this!!
        $query_args = wp_parse_args( $query_args );

    I may find more minor problems in the future, but this was the last of what needed fixing for now.




    Another change Apr 12, 2022: Server was timing out for a certain action in WordPress Admin. It took about 4 hours to debug, but ultimately the solution was to replace the deprecated clean_url function with esc_url which is what WordPress replaced it with.

    My Top Programming and Genealogy Q & As - Mon, 27 Dec 2021

    As I was preparing GenSoftReviews for the annual User Choice Awards that I announce on January 1st or 2nd, I realized that I hadn’t checked the site’s links in a number of years. So I started up my link checker Xenu’s Link Sleuth and let it rip. I was amazed at the number of links I needed to fix. It took me a full day to work through them.

    A lot were links to sites that changed from the non-secure http prefix to the secure https prefix. This is something a website owner needs to make the effort themselves to change. Doing so is a bit of a hassle and involves obtaining an SSL (Secure Sockets Layer) certificate. it was back in 2014 when Google first recommended that sites switch to https and I finally got around to doing it for my sites in May 2020. It was good to see that quite a number of genealogy software sites have been switching over.

    I also found about 25 genealogy programs whose websites were no longer available, so I marked those programs as “unsupported” and changed their link to the most recent copy of their site that was captured by the Internet Archive.

    Along the way, I noticed there was a broken link in my GenSoftReviews FAQ to a question I asked on Stack Overflow that was about javascript.


    Stack Overflow, the Q & A Site for Programmers

    Stack Overflow was created in 2008. It quickly became the go-to site for programmers to get their questions answered and to find solutions to their problems. I joined Stack Overflow in October 2008 and I have made great use of it to help with my Delphi Development of Behold and Double Match Triangulator. There you’ll find over 129 questions that I asked and over 177 answers I provided to other people’s questions.

    To encourage participation, users collect points when someone upvotes one of their questions or answers or selects their answer as the best, and they lose points when they get downvotes. The net upvotes allow the best answers to be shown first. They also allow me to unbiasedly rank my top questions and answers.


    The Big Purge

    After a few years of operation, Stack Overflow decided to only accept questions about programming that are tightly focused on a specific problem. Questions of a broader nature—or those inviting answers that are inherently a matter of opinion were not desired. Many of my early Qs and As, including some of my best, were of the broad type, and many of those were deleted from public view. I realized that when I saw the broken link for my question about javascript.

    This is what you see now from one of these deleted questions:

    image

    On Stack Overflow, the more points you collect, the more capabilities you have on the site. I have participated in Stack Overflow enough to earn the points required to view deleted questions and answers. They don’t say how long these deletions will still be around for, so I thought it best that I save a copy of them while they are still there. Then I can fix the link in my GenSoftReviews FAQ to point to my saved version of the javascript question.


    My Top Stack Overflow Questions and Answers

    The deleted Q&As are among my most popular and interesting, primarily because they are of a general nature. Here are my top 3 questions:

    1. What’s with those Do-Not-Use JavaScript People? This had 154 upvotes, was viewed 36,000 times, and had 33 answers, but was deleted. This was the broken link question that I referred to in my GenSoftReviews FAQ page as mentioned above. 
    2. What ever happened to APL?  This had 95 upvotes, was viewed 22,000 times, and had 31 answers. It was also deleted. APL was my favorite programming language in University. Very terse! See my top answer, below.
    3. How Do I Choose Between the Various Ways to do Threading in Delphi? This has 65 upvotes , 8,000 views and 6 answers. It is my top question that was not deleted. It is specific to the Delphi language that I use. Threading is getting the computer to execute different sets of code at the same time.

    My favorite question is likely this one:

    • A Good and SIMPLE Measure of Randomness had 45 upvotes, was viewed 24,000 times and had 15 answers.  I provided my own answer to my question (which not only is allowed, but is often encouraged) which was 2nd of the 15 answers with 16 votes. I accepted my own answer.

    My top answers were to these questions:

    1. “Strangest Language Feature” received 973 votes. There were 365 answers and my answer had the 8th most votes with 325. I stated that APL’s ability to write any program in just one line which links back to this now archived amazing article and this video. This question has so far escaped the purge, but it has been locked because of being “off-topic” and could be deleted in the future.
    2. Delphi Profiling Tools received 23 votes. There were 10 answers. My answer received 25 votes and was the accepted answer. Profiling tools help you optimize a program to make it faster, sort of a specialty of mine since my days of chess programming. This question is still there as well, but is marked closed as it “does not meet Stack Overflow guidelines” and may be deleted in the future.
    3. how many delphi users over the world? received 42 votes. There were 6 answers. My answer received 22 votes and was the accepted answer. This was a fun question to try to answer. Again, this answer might be deleted.

    I do understand why the Stack Overflow people are locking, closing, and deleting many of the most popular questions. It’s because the most popular ones are general, don’t require a precise answer but often the answer is just an opinion. They did attract attention, but not the sort of attention that was wanted from the site.


    Stack Exchange

    Stack Overflow turned out to be an overwhelming success. It has over 22 million questions asked with over 33 million answers. It gets 9.5 million visits a day and has 5,000 new questions asked each day. 16 million users have participated.

    The company soon allowed the Q&A platform they developed to be used to answer questions on other subjects. They created the StackExchange website to maintain a list of all the topics covered. There are currently 177 different sites with topics ranging from Law to Hinduism to Robotics to Bicycles to Parenting to Chess.

    SNAGHTMLdc0409

    I’m sure any person will find many topics that would interest them. My Stack Exchange profile lists the 31 topics that I have participated in.

    Just for fun, these are my top question and answer on these other sites:

    • My top question was Image of Webpage on Tile in Windows 10 Mobile? on the Windows Phone topic site. I found that site very useful when I still had my Windows phone. The question had 12 upvotes, was viewed 1000 times and had 2 answers.
    • My top answer was to the question Are negative numbers singular or plural? which had 46 upvotes.My answer had the most upvotes (17) but was not the accepted answer which had 13 upvotes. This was on the Meta Stack Exchange site. Every topic site has its own Meta site, for discussing issues about the site itself. This question was asking if the site was displaying negative numbers properly.


    Genealogy and Family History Stack Exchange

    Stack Overflow worked so well for me, that I was sure it would be a great place for Q&A about Genealogy. So in 2012, I helped promote the proposal of a Genealogy Q&A site at Stack Exchange. After 58 days of getting enough interest, we did it. The Stack Exchange people created a live site for Genealogy and Family History questions and answers: https://genealogy.stackexchange.com 

    Over the past 9 years, the site has had 8,900 registered users ask 3,500 questions and give 5,700 answers. I have been a regular participant, supplying many answers (281) as well as a few questions (26).

    My top genealogy questions have been:

    1. What is the Russian town in this census? (18 upvotes) – For a long time, this was one of my most perplexing genealogy mysteries, which I solved 6 months ago when I found a death record giving the answer.
    2. How do I write the year with a double date? (15 upvotes) – I got some really good answers on this one.
    3. Extract Facts from an Army Portrait (14 upvotes) – I still really would like help with this if anyone can contribute.

    My top genealogy answers have been to these questions:

    1. How should a trip be recorded in my family tree software? My answer has 20 upvotes and was the accepted answer.    
    2. Why haven’t more programs adopted Gramps XML free format? My answer has 20 upvotes and was the accepted answer.
    3. What are the key points for a beginning genealogist to consider? My answer has 19 votes and was the accepted answer.


    Do you have your own Questions or Answers?

    As you can see, there are a wide range of questions and answers on all sorts of topics on the Stack Exchange sites. 

    If you are one of my genealogy friends, I invite you to join me and thousands of others at Genealogy and Family History Stack Exchange.

    If you are a programmer, join the world at Stack Overflow.

    And don’t forget to check out your other interests at Stack Exchange.

    5 Years Ago Today, I Retired - Wed, 24 Nov 2021

    Exactly 5 years ago today, which coincided with my 60th birthday, several hundred co-workers, friends and family met in the large conference room at the Manitoba Hydro head office in downtown Winnipeg on my last day of work to help see me off into “retirement”. 2021-11-23_13-49-05

    I had a wonderful 41 years with the company and enjoyed being able to make use of all my computer, maths and statistics skills in all sorts of wide-ranging and exciting projects.

    Today, it is 5 years later, so I’m sure you can guess what age I became today.

    Now it’s time to look back and see what I have accomplished so far in my first 5 years of retirement.


    DNA Testing and Analysis

    These past 5 years I’d call my DNA testing years. I did my first DNA test with Family Tree DNA in Nov 2016 and subsequently tested myself at MyHeritage, 23andMe, Ancestry and LivingDNA. I then took two WGS (Whole Genome Sequencing) tests from Dante Labs, a short read test and a long read test.

    I took all these tests primarily to learn about them and gain expertise in the genetic genealogy field. I have written many articles about DNA analysis in my blog, and have given talks about DNA at several genealogy conferences. I also wrote the program Double Match Triangulator to help analyze your DNA matches. I’m currently working on modifications to DMT that will be released as Version 5.


    Year 1 Started with a Bang!

    I had been an avid squash player 3 times a week for 30 years. We had a great group who would get together and whoever came out would play each other at a pretty competitive level. My expectation was to continue this into my retirement years as long as I could … which turned out to be less than a month. During one game, I displaced my peroneal tendon and a week and a half later had an operation to repair it.

    So that started off my year 1, 2017, which included 4 genealogy conferences: RootsTech in Salt Lake City, the IAJGS at Disney World Florida, the Great Canadian Genealogical Summit in Halifax and FTDNA’s Genetic Genealogy Conference in Houston. I came out with 3rd place at the RootsTech 2017 Innovator Showdown for my program Double Match Triangulator, and I did it wearing a walking boot from my operation.


    Genealogy Conferences and Vacations

    So there were the 4 conferences in 2017. I attended and spoke at the Kelowna District Genealogy Conference in 2018. My first-ever online presentation was in January 2020 at the Family History Fanatics DNA eConference and I have made several others since.

    Vacation-wise, my wife and I took a western Caribbean cruise in Feb 2017 just after RootsTech (and I was still in my walking boot). My wife and I and my older daughter went to Walt Disney World in June 2017 where my younger daughter was working for the summer. I went there a month later for the IAJGS conference and saw my younger daughter again while there. My wife and I took an eastern Caribbean cruise in Feb 2019. Then in July 2019, my wife and I went to Niagara Falls for a 40th anniversary reunion of my Europe Trip people from 1979. And in Feb 2020, my wife and I took a southern Caribbean cruise with my best friend Carl and his wife who now live near Vancouver. We got back just as Covid was taking over.

    I was scheduled to attend the 3rd MyHeritage Live conference in Tel Aviv, Israel in the Fall 2020, but that was kiboshed like everything else by Covid. It would have been my first trip to Israel and my wife and I were looking forward to making a vacation in Israel around it. That will have to wait now until some future time.

    With the onset of Covid in March 2020, so many conferences, webinars and discussions started coming online. Zoom became a word of our vocabulary. Between Legacy Family Tree Webinars, Dear Myrtle, Geneablogger, Family History Fanatics, WikiTree and all the other content providers, you could spend 24 hours a days in front of your computer being totally immersed in genealogy without getting a smidgen of your own genealogy done.


    GEDCOM

    I’ve always been interested in GEDCOM, the standard for transferring genealogy data because my program Behold uses it. I kept up with what FHISO was doing to advance the standard. In 2018, I was one of a number of people who contributed to Tamura Jones’ GEDCOM 5.5.1 Annotated Edition, and then a year later to Tamura’s GEDCOM 5.5.5.  I followed along as FamilySearch released its 7.0.earlier this year.


    Genealogy

    My one greatest accomplishment over the past 5 years has to be my advances in my own genealogy research. This summer I wrote the article: So How’s My Genealogy Going? In it, I described how I selected MyHeritage as my platform of choice and now use it and their Family Tree Builder program to store the working copy of my family tree data.

    I’ve been involved in some major projects that include working with my wife’s cousin Terry Lasky, helping with his DNA project. In that project, I’m still trying to solve how the early Zaslavsky families from Tetiev were connected by using my Double Match Triangulator program. My Romanian Fossaner side has been aided by working with my genealogist cousins Joel Koenig and Phil Rodd who have been doing a lot of research and have found new living cousins in Australia who we have Zoomed with.

    But my major breakthroughs have come in the past 4 years with researchers finding me records of my ancestors in Romania and Ukraine that have taken 5 of the 9 lines I’m researching back another 3 generations to the 1800’s. New records are being photographed and digitized all the time and the next few years should continue to be exciting on this front.

    In order to better understand the records I’m getting, I just finished a fantastic 10 week online Salt Lake Institute of Genealogy (SLIG) course on Researching Russian Records, and now I can read, pronounce and transliterate Russian print and (with a bit more difficulty) Russian handwriting, which is essential to know for anyone researching their Russian Empire roots.

    I was honored in July to be selected as a genealogy guest on the WikiTree Challenge. About 20 WikiTreers all worked together on my tree to make it better and find new sources for me.


    The Next 5 Years

    So much to do, so little time. First step is to try to complete my Zaslavsky project and release Version 5 of Double Match Triangulator. Then I really want to get back to working on Behold which has sort of been in limbo the past 5 years. Now that I don’t mean to make it my primary genealogy editor (that being MyHeritage), I’ve got ideas to take it into a new and interesting direction.

    My genealogy will still take front and center stage. If any new records come up, or I get contacted by relatives or possible family, I will attend to that first. And those boxes of my and my wife’s family material still needs to be gone through, digitized and recorded.

    I also had two little munchkins sprout up in the past 5 years (my sister’s grandchildren) who will be so fun to follow and be a part of during their next 5 years.

    Other than that, I’ll try to keep in shape (walking, swimming and bike riding – did over 1000 km of the latter last year), plus lots of family stuff, house maintenance, errands, appointments, shows and sports on TV, socializing on Facebook and Twitter, keeping up my website, my GenSoftReviews, Behold and DMT sites, and blogging and Zooming from time to time. Hopefully this Covid thing will end soon and we’ll be able to see people and travel again.

    I’ll report back in 5 years from now and let you know how it went.