Migrating website to higher version of PHP - php

I have a website hosted on a VPS server using PHP version 5.6.40. I would like to upgrade PHP version to 7.0.33. Is there a way to run some sort of audit to determine if anything would break as a result of migration?

The best way to determine this is to have a full suite of tests for the application in question. You can then run it on the new version.
Failing that, I have used PHP Compatibility before, which is a series of sniffs for PHP Codesniffer, and will at least tell you if the syntax is incompatible with the specified version of PHP. It won't guarantee it will work as expected with that version, but will catch syntax problems, which you can then resolve manually.
It still doesn't offer a cast iron guarantee that it'll catch everything, but if the application is small then coupling it with manual testing may be sufficient.

Related

software not working after change of php version

I have a commercial membership site php program on the server, but after the server upgrade it no longer works. The provider has ceased to operate so there is no support. I am using php 7.0.15, but the server wants me to upgrade to a more recent version, 7.4. This breaks the program /all I get is a blank screen)
My level of PHP does not allow me to debug such a complicated program. My question is:
is there any way of instructing php to only use the older version? I imagine that this would have to be done in the php.ini file on the server?
I would like to upgrade to php 7.4 on the server, but have this software run in php 7.0.
Is this possible?
The simple answer is No - PHP does not offer any options to emulate the behaviour of previous versions.
Partly because features are sometimes removed because they prevented changes in the engine, or would need a lot of work to operate with them; partly just because there is only a limited amount of resources available to work on the core of PHP, and maintaining multiple versions of each feature to enable such compatibility would take effort away from improving the current version.
Your short-term option is to find a way to run an actual copy of PHP 7.0 on the server, or a different server that will allow you to run it. You may need to pay someone who provides unofficial long-term support for old versions, since the last official security patch for that version was over 3 years ago. Even PHP 7.4 will only receive official security patches until the end of this year.
In the long term, your only options are to hire someone to update the application to run on a modern version of PHP, or to migrate to a different application which still has a vendor supporting it.

Typo3 PHP Runtime Notice

I inherited a Typo3 site to maintain and have had no trouble until now. When I try login I get this error message:
Oops, an error occured!
PHP Runtime Notice: Declaration of t3lib_userAuthGroup::checkLogFailures() should be compatible with t3lib_userAuth::checkLogFailures() in /home3/onefoug3/public_html/t3lib/class.t3lib_userauthgroup.php line 113
I checked with my hosting service and they say it is an error with the script. I am not a programmer so I do not know how to fix that...not even sure where to start. How do I fix this?
To give you an overview about the situation with your TYPO3 installation I list a few points, some of them where you've to verify more:
TYPO3 in your installation is very old and outdated. You'll get perhaps many hints to update due to security-reasons. This is not wrong but I'd concentrate first on getting it running, perhaps better on a local server.
The Version of your TYPO3 installation is in any case very useful, you should try to provide it.
It's possible that you need an old PHP version to run that site and that the error is just thrown because of a wrong PHP Version. You could try with PHP 5.2.
It's not improbable that something in the TYPO3 core was changed manually. It might be patches or individual but in many versions I never found the mentioned methods in the line 113 like shown in the error-message.
Rarely I changed in the core somethings too, to circumvent some temporary problems, usually that's neither required nor advisable. Nevertheless if it helps you to get the installation locally running - why not.
The more advised step is to download the current version new and replace the existing core with that. Often you can chose the most recent minor version: assume you've Version 4.7.18, then you can download Version 4.7.20 or newer if available.
The link to get the newest Version of that old branch would be https://get.typo3.org/4.7
Better keep the old core till the problem is solved, even if you replace it.
If you follow my hint to get a higher minor version you should have a look in the install-tool, specifically in the update-wizard there.
I'd advise to update the question to include the Versions of TYPO3, PHP and MySQL, then perhaps it will be easier to help more.
As target I see to get the installation locally running and performing an update instead of serving the old site with insecure core. Based on that I answered in point 5 too, on a live-system it's not advisable especially with your limited knowledge.

how would migrating from Php 5.3 to 5.6 affect other websites on my server

i am thinking about migrating from php 5.3 to php 5.6 on my company's server, but i'm concerned about how it may affect other websites on the server, especially joomla and wordpress app's, which were hosted some few years back, like 2011. I was trying to host a new website that uses 'get_result()' but i was having some errors when hosting it, even though mysqlnd driver was present, i could only fetch my results using'bind_result()'. so i debugged it, and found out that it's because of a certain driver nd_mysqli which is present in php 5.6. So that's why i decided to upgrade. Are there any issues that could come after this upgrade? Or is there another way of getting the nd_mysqli driver? though honestly i'd prefer to upgrade, this is 2017, it's about time for that.
A fair amount has changed between 5.3 and 5.6, so it is hard to say exactly what issues you may face.
If you are running recent versions of joomla and wordpress the chances are they are compatible as the relevant developers will already have fixed any issues, but if they are as old as php 5.3 then you may run into issues.
Whatever you do, you should create a test server to be sure.
The following pages show the changes that have been made:
http://php.net/manual/en/migration54.php
http://php.net/manual/en/migration55.php
http://php.net/manual/en/migration56.php
You really should upgrade though php 5.3 no longer receives security patches and you are likely vulnerable to something.
It depends on the versions of Joomla and WordPress.
For example, it might be possible to get Joomla 1.5 and older versions of WordPress running on PHP 5.6, but you will need to suppress strict errors as per https://stackoverflow.com/a/9984309/1983389 or similar. It will also depend on what extensions / add-ons are being used.
As #Theo says, it is probably best to do this change in a test environment first so that any issues can be identified and resolved before proceeding with the change on the production server.
An alternative and better long term strategy might be to upgrade the Joomla, WordPress and any other applications on the server before upgrading PHP.

Can a PHP app be compatible to PHP5 and PHP7 at the same time?

I have a complicated custom PHP app written for PHP5.
Can an app be modified to be compatible with both PHP5 and PHP7?
The background is that the server runs PHP5. What if it was upgraded to PHP7, could the upgrade be seamless.
Most likely yes. But only if the app doesn't use PHP7 functions or syntax (In you issue it's only that). The best way to find out is to make a second server to test it out. An example: In Magento (big PHP app, I would say), there is only one line of code that crashes the app. This is a Syntax thing. But without testing out and reading the error log, you will most likely not finding it out by pure source code reading. I port multiple websites a week from PHP5 to PHP7. Most of the time the only problem is that some apps use MySQL instead of MySQLi (talking about the PHP-Modul. Not the Databases itself)
From PHP5 to PHP7 is major version change. It would be surprise if the code worked as it is! As a starting point, you can see this http://php.net/manual/en/migration70.php

Ubuntu server 11.10 and PHP 5.2 for use with Drupal 6

I'm trying to figure something out:
I am using Ubuntu server 11.10 virtualized on Win7 (I don't think that matters but more info is better than less) to work on a Drupal 6 website I inherited and need to make significant changes to.
I want to set up a development copy of this Drupal website on my Ubuntu server so I can work without worrying about torching the production website.
I successfully got the production files downloaded and onto my machine, I got the production MySQL database exported and imported into the dev MySQL server, and I set up a symbolic link from the directory /home/myname/thewebsite.com to /var/www/thewebsite.com so I can easily access it.
When I got the website they didn't know the admin password so I dug around online and reset it in the dev db using phpmyadmin and finally log in.
When logging in and poking around the site there are lots of errors, which when googled lead me to believe that PHP 5.3 is causing them and that there are some modules in use that only work with PHP 5.2
After looking around a lot online and on stackoverflow there seems to be no easy way to install PHP 5.2 on Ubuntu Server 11.10. With no packages for 5.2 available through apt-get or aptitude what should/can I do?
1) Install 5.2 from source - how do I get it to interface with MySQL and Apache2? Also, I've never installed anything significant from source. Is there a walkthrough?
2) Replace the repositories with old ones? Will this work on 11.10? The newest instructions I found were for 10.04
3) Use already built PHP 5.2 packages for Ubuntu? Couldn't find these
4) Pay someone who knows more to do it for me? (Just kidding, this isn't really an option...)
Cheers and thanks for your help!
PHP dropped support for 5.2 in August 2011; operating system providers such as Ubuntu will not supply a version that is out of support, so you absolutely won't get an official copy of PHP 5.2 on the current version of Ubuntu (or any other OS).
If you're running an older version of Ubuntu (eg 10.04), you might be able to do it; it would still be a downgrade, because PHP 5.3 has been the default version for quite a long time now.
If you're on a newer version of Ubuntu, ie 11.10 as you state, it is going to be a problem for you.
The Drupal developers dropped the ball badly on this one. I guess it was because Drupal 7 tool so long to finish; they were expecting D7 to be out much sooner, and so they never bothered fixing up D6 to work with PHP5.3. As it turned out, this was a big mistake, because in fact D7 still wasn't officially released when PHP dropped support for 5.2.
But even so, they should have fixed it, because they're still officially supporting Drupal 6, so they need it to work with the current version of PHP. This is definitely Drupal's problem, not PHP's, Ubuntu's or yours.
But you still need to deal with it.
I found this question over on AskUbuntu.com, which gives an answer applicable to 11.04. It isn't quite 11.10 you were asking for, but it it a lot more recent than the best you'd found, so it might be helpful.
Alternatively, you could research exactly what it is about Drupal6 and your specific modules that doesn't work in PHP5.3. The language differences between 5.2 and 5.3 that can break things are not big, so I would expect any code changes required to be fairly small. You might find you can fix the code yourself. And maybe even submit the changes to the community -- Drupal is open source, after all.
Another tack you could take is to consider whether this saga represents an opportunity for you to move the site to Drupal 7?
This may or may not be feasible, depending on the modules you're using, etc, but if it is possible, it will solve the problem, because D7 is of course fully compatible with PHP5.3.
And just to cheer you up, I'll close by mentioning that PHP are on the verge of releasing PHP 5.4. Hopefully the Drupal devs will be more on the ball this time.

Categories