3

I am trying to get our old script working again.

Foreword; we are using a custom written/modified script from someone who passed away. We cannot use something else. The script runs on the old server, but the server is really getting outdated so I am trying to migrate everything to a newer server. Current (old) server is still running CentOS 5.x along with PHP 5.3 and MySQL 5.5. So it's pretty old.

Anyway, I managed to get it working on a CentOS 6.x server along with MySQL 5.6 after several hours of tweaking. So that is good. I might get it also running on CentOS 7.x, which will be a different step. Currently the main issue is that the script refuses to run on anything higher other than PHP 5.3 unfortunately. Heck, I cannot even get rid of the first error message which it is throwing at me after "upgrading" to PHP 5.4.

As far as I can tell, the issue is caused by a (very outdated) PEAR module called: HTTP_Session2 See here for more information about this PEAR module.

The error which is being displayed is the following:

[Fri May 31 14:05:42 2019] [error] [client 192.168.0.1] PHP Fatal error:  Uncaught MDB2 Error: unknown error Code: -1\n  thrown in /usr/share/pear/HTTP/Session2/Container/MDB2.php on line 187
[Fri May 31 14:05:42 2019] [error] [client 192.168.0.1] PHP Fatal error:  Uncaught MDB2 Error: unknown error Code: -1\n  thrown in /usr/share/pear/HTTP/Session2/Container/MDB2.php on line 187
[Fri May 31 14:05:42 2019] [error] [client 192.168.0.1] PHP Fatal error:  Uncaught MDB2 Error: unknown error Code: -1\n  thrown in /usr/share/pear/HTTP/Session2/Container/MDB2.php on line 187
[Fri May 31 14:05:42 2019] [error] [client 192.168.0.1] PHP Fatal error:  Uncaught MDB2 Error: unknown error Code: -1\n  thrown in /usr/share/pear/HTTP/Session2/Container/MDB2.php on line 187
[Fri May 31 14:05:42 2019] [error] [client 192.168.0.1] PHP Fatal error:  Uncaught MDB2 Error: unknown error Code: -1\n  thrown in /usr/share/pear/HTTP/Session2/Container/MDB2.php on line 187
[Fri May 31 14:05:42 2019] [error] [client 192.168.0.1] PHP Fatal error:  Uncaught MDB2 Error: unknown error Code: -1\n  thrown in /usr/share/pear/HTTP/Session2/Container/MDB2.php on line 187
[Fri May 31 14:05:43 2019] [error] [client 192.168.0.1] PHP Fatal error:  Uncaught MDB2 Error: unknown error Code: -1\n  thrown in /usr/share/pear/HTTP/Session2/Container/MDB2.php on line 187
[Fri May 31 14:05:43 2019] [error] [client 192.168.0.1] PHP Fatal error:  Uncaught MDB2 Error: unknown error Code: -1\n  thrown in /usr/share/pear/HTTP/Session2/Container/MDB2.php on line 187
[Fri May 31 14:05:44 2019] [error] [client 192.168.0.1] PHP Fatal error:  Uncaught MDB2 Error: unknown error Code: -1\n  thrown in /usr/share/pear/HTTP/Session2/Container/MDB2.php on line 187
[Fri May 31 14:05:44 2019] [error] [client 192.168.0.1] PHP Fatal error:  Uncaught MDB2 Error: unknown error Code: -1\n  thrown in /usr/share/pear/HTTP/Session2/Container/MDB2.php on line 187

The complete part of that code is:

    169     /**
    170      * Read session data
    171      *
    172      * @param string $id The Id!
    173      *
    174      * @return mixed
    175      * @throws HTTP_Session2_Exception An exception!?
    176      * @todo   Get rid off sprintf()
    177      */
    178     public function read($id)
    179     {
    180         $query = sprintf("SELECT data FROM %s WHERE id = %s AND expiry >= %d",
    181             $this->options['table'],
    182             $this->db->quote(md5($id)),
    183             time());
    184
    185         $result = $this->db->queryOne($query);
    186         if (MDB2::isError($result)) {
    187             throw new HTTP_Session2_Exception($result->getMessage(),
    188                 $result->getCode());
    189         }
    190         $this->crc = strlen($result) . crc32($result);
    191         return $result;
    192     }

The line #187 is causing the error apparently.

What did I try so far?

Mind you, I am no coding expert whatsoever. So I really did the best I could. I have searched the internet, forums and GitHub for a solution or workaround for this error. But no luck whatsoever.

I also tried removing / commenting out that part of the code, but that results in new error(s). For example:

Fatal error: Class HTTP_Session2_Container_MDB2 contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (HTTP_Session2_Container_Interface::read) in /usr/share/pear/HTTP/Session2/Container/MDB2.php on line 55

I also tried updating all PEAR modules, however some don't have any updates to them at all (including / especially the HTTP_Session2 module).

So I am looking for a workable solution or workaround. So I can use a newer PHP version on the server. If not, I will be using PHP 5.3. Though the server is only accessible by us, I rather have it updated for various reasons.

Maybe it's also possible to remove the HTTP_Session2 module completely from all code or disable it in general? I don't know if it's important to the application though. I do notice the sessions get logged. But who knows? If it's only used to show who is online at the moment or similar, it's probably safe to remove?

Anyways, thank you in advance for taking a look at this thread. If you need more information or anything else, just let me know, I will try to supply as much information as possible.

Update

Probably I am a complete idiot for trying, but I took out all references to "HTTP_Session2" everywhere (in each file where it was located). The result; the interface was loading (for the first time on PHP 5.4), however... For some reason I cannot login any more. I am guessing it really needs it.

The url also changed a little apparently, now it's showing:

hxxp://domain.com/index.php?view=login&PHPSESSID=

Instead of:

hxxp://domain.com/index.php?view=start&session=56d1fdf45cf1400e8e75f

So I guess that's not going to work. Anyone a different idea?

halfer
  • 19,824
  • 17
  • 99
  • 186
Joanne
  • 514
  • 3
  • 8
  • 30
  • I think your problem are the libraries `HTTP_Session2` and `MDB2` supporting only PHP 5.2.0 those are really old packages and hasn't been updated in a while. I may be wrong but I would suggest to get rid of those pear packages and look a composer library that does the same or similar, sadly you will have to refactor everything. Hope this help – ReynierPM May 31 '19 at 15:02
  • When you say "we cannot use anything else" (in relation to a custom script), you could, if you wish, specify why that is. Without a stated reason, this sounds to me like an assumption that may be false (readers cannot know without more detail). For example, some businesses are understandably opposed to rewriting an existing piece of code, because they reckon the existing problem is trivial, and they do not wish to hire a freelancer to do the work. – halfer May 31 '19 at 17:17
  • The impact of this is they spend more money in staff time than they would have done on the freelancer... – halfer May 31 '19 at 17:19
  • Throw that into a Docker container, no need to waste your time on this. – Mike Doe May 31 '19 at 17:20
  • @emix: I agree, but if the question author is having trouble on the above, they may also have trouble with setting up and maintaining Docker. – halfer May 31 '19 at 17:21
  • I’m just giving an idea. – Mike Doe May 31 '19 at 17:43

0 Answers0