XML Parsing Error

Today I got a weird error on a web-page that I made: "XML Parsing Error: unclosed token". The web-page does some complicated stuff with JavaScript, such as contacting the server to get data in XML. The data come from a PHP script on the server side. There have been some other problems with things that used to work, and now need to be changed. These come from the browsers, or at least Firefox. For example, if you assign a variable in JavaScript without declaring it first, it is given the value and made global. Wonderful! Then I put the latest version of Firefox on my laptop, for a reason I cannot remember now, and now it gives me warnings about how I should declare the variables. Ugh.

"XML Parsing Error: unclosed token"
Location: http://myserver.local/myprogram.php
Line Number 1, Column 1:
myprogram.php:1:1

Line 1 column 1? That's not helpful.

So I see this error on my laptop, and assume that it is some new problem due to the upgrade like "x = 0;" instead of "var x = 0;". I look at the PHP code quickly, and it looks something like this:

<?php
        ... blah blah blah


I don't have a ?> at the end. This bugs me; I like code (and codings) to be symmetric. I left it off because of some weird problem, like it puts an extra line-feed character in the output. Could this be causing the issue today, like if leaving off the ?> is now fashionable? I put the ?> at the end of the file, and tried again. Now it looks like this.

<?php
        ... blah blah blah
?>


Then it gives me a different error, just as unhelpful.
"XML Parsing Error: no root element found"
Location: http://myserver.local/myprogram.php
Line Number 260, Column 1: myprogram.php:260:1
There are 260 lines in that program. Make up your mind, Firefox, is it the first line or the last line of the program?

I did not digging on the internet, but no one else seems to have this problem. I did some hacking on my end, and came to the conclusion that the server is no longer running PHP. This is weird, but fortunately I happened to have an extra piece of information: I used my program yesterday, and it worked fine. Then I upgraded the OS on the server (from whatever it was to High Sierra), because it sounded like a good idea at the time. And now today the server does not run PHP. After some more digging and internet searching, I found that the old version of "/etc/apache2/httpd.conf" contained

LoadModule php5_module libexec/apache2/libphp5.so

and the current one has

#LoadModule php7_module libexec/apache2/libphp7.so

Now I know what to do, to turn PHP back on.
  myserver:~> cd /etc/apache2/
  myserver:apache2> grep php httpd.conf
  #LoadModule php7_module libexec/apache2/libphp7.so
  myserver:apache2> sudo vi httpd.conf
  myserver:apache2> grep php httpd.conf
  LoadModule php7_module libexec/apache2/libphp7.so
  myserver:apache2>

I rebooted the machine. Now it works.



TL;DR version: "XML Parsing Error" was really caused by upgrading the server's OS, which turned off PHP. I had to tell apache2 to run PHP.

-Michael Weeks, November 2017