PHP7 / MySQLi / PDO support in Coppermine? PHP7 / MySQLi / PDO support in Coppermine?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

PHP7 / MySQLi / PDO support in Coppermine?

Started by Johnson.Wang, December 07, 2015, 12:05:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Johnson.Wang

Now PHP7 has been released.

No more tranditional mysql_connect support in PHP7, cause Coppermine is not working in PHP7 environment.

Is there any plan to support mysqli or PDO in the futere Coppermine? If NO, I will leave Coppermine and try to find other photo gallery.

phill104

Much of the work has already been done in the CPG1.6 branch on our new Git repository where a huge amount of effort has been put in creating a @database abstraction layer'. So the answer is yes, the future will allow both MySqli and PDO. It will be a while until 1.6 is released* but I do not see many hosts adopting PHP7 for quite some time yet.

*This is because the development team is relatively small. We are always on the lookout for anyone wiling to join and assist.
It is a mistake to think you can solve any major problems just with potatoes.

cheigu

For the mysql_connect support in PHP7, there is a library on http://sourceforge.net/projects/mysqlwithmysqli/ (usefull also for other projects and temporarly solutions)

cpg1.5.x has other problems with PHP7 and should not be used with it, altough the galery itself runs with the above mysql solution there are issues to solve in the admin section.

phill104

CPG1.6 is currently a work in progress which should support later versions of PHP. Currently very few outside testing environments are using PHP7 so it is not really an urgent matter.
It is a mistake to think you can solve any major problems just with potatoes.

Daggers

Just been forced by my service provider to upgrade to PHP7.0 or they will start to charge me to continue with the administration of PHP 5x, any news on the CPG1.6 release.

This is what I am now presented with after the PHP upgrade.

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /homepages/18/d267387953/htdocs/include/functions.inc.php:183 Stack trace: #0 /homepages/18/d267387953/htdocs/include/init.inc.php(171): cpg_db_connect() #1 /homepages/18/d267387953/htdocs/index.php(26): require('/homepages/18/d...') #2 {main} thrown in /homepages/18/d267387953/htdocs/include/functions.inc.php on line 183

gmc

Its coming... but certainly not today... (or tomorrow...)

For the mysql functions - I would look at the post from cheigu as a workaround - translates the mysql function calls to mysqli. I see no reason why that won't work with CPG.
Quote from: cheigu on December 25, 2015, 12:08:33 PM
For the mysql_connect support in PHP7, there is a library on http://sourceforge.net/projects/mysqlwithmysqli/ (usefull also for other projects and temporarly solutions)

cpg1.5.x has other problems with PHP7 and should not be used with it, altough the galery itself runs with the above mysql solution there are issues to solve in the admin section.

Just need to add an include for this script - adding something like this to the beginning of include/functions.inc.php:

if (!function_exists('mysql_connect')) {
    require 'mysql_mysqli.inc.php';         //* adjust to correct path based on where you placed the file...
}

EDIT: actually the 'if' logic isn't required - as the included file already checks and bypasses:

if(!is_callable('mysql_query')) {

END EDIT

The plugin API isn't yet initialized when the database connection is made (it needs DB info to initialize) - so no opportunity to add this logic via a plugin..


As for other requirements of PHP7 - I don't believe we have addressed that at all as of yet.  CPG 1.6 will require PHP5 as a minimum. But I know I haven't done any testing beyond that as of yet - perhaps others here have.
I don't know the specific issues that cheigu referred to.

This is certainly first I've heard of an ISP requiring use of PHP7 - most don't even have it available as an option yet - at least in shared hosting packages. I expect CPG is far from the only package that will have an issue in a PHP7 environment today.
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

ron4mac

There are more issues with CPG 1.5.40 than just mysql when it comes to PHP7. So some sort of patch for mysql won't keep it from failing on PHP7.
If push-comes-to-shove (probably a US expression :) ), and you really need to have a PHP7 compatible version, I will provide you with a pre-release, developer version that I have tested with PHP7.

IvarSnaaijer

I'm not allowed to PM as a newby, but would still like to have access to the beta with PHP7 support. I just moved to Ubuntu 16.04 and it comes with PHP7. I was able to fix it up a bit with the include mentioned but there is room for improvement ;)

ron4mac

Quote from: IvarSnaaijer on May 03, 2016, 07:58:16 AM
I'm not allowed to PM as a newby, but would still like to have access to the beta with PHP7 support.

Do you want to upgrade over an existing install or do a fresh install?

IvarSnaaijer

I would like to upgrade from an existing installation. If this is impossible I should be able to recreate the new site from scratch, there are no real relevant comments on it, only images.

ron4mac

#10
Quote from: IvarSnaaijer on May 05, 2016, 07:12:52 PM
I would like to upgrade from an existing installation. If this is impossible I should be able to recreate the new site from scratch, there are no real relevant comments on it, only images.
If you want to do a new site from scratch, follow the link in this post to download a beta version of CPG 1.6.
http://forum.coppermine-gallery.net/index.php/topic,78708.msg381574/topicseen.html#msg381574

If you want to upgrade in place, download the file attached here and place it in the root of your current CPG install (as upgrader.php). Make sure you are logged in as admin, then access <yourCPGsite>/upgrader.php. Select "CPG Release 1.6.04" (or whatever may be newer) and perform the upgrade/update. Ignore any message about a newer version available, and complete the update. I have had success upgrading CPG 1.5.20 in place but, if you value your current installation, you may want to make sure it is backed up first.

Please be very aware that there may be compatibility issues between CPG 1.6 and a plugin or theme that you are using.

Good luck!

[ those of you using this upgrade in place method ... please let us know how it worked for you ]

Update: v2.2 additional checks made prior to install
Update: v2.3 better check for file placement errors

MarioKnight

I was preparing to do a manual update to 1.6.01 using the files in the Github repo this weekend, and came across this post when checking for any information I may have missed.  I'm very happy to have seen this updater script and figured I had time right now to give that a try where I could still go about my original plans if needed.  I made my backups and ran it as instructed (I did not get a message about a newer version available).  Everything appears to have completed successfully!  For reference, my server is CentOS 6.x with PHP 5.6.23 using suPHP.  I do not use any plugins or extensions so there was no worry about potential issues there.  I do use a one line modification within /include/functions.inc.php that someone here helped me with some time ago, and in applying it to the same query, this also works as it was meant to.

This makes an already smooth updating process even smoother and easier.  Thank you very much for this script and I look forward to the official release!  =D

sah62

I just updated my gallery to version 1.5.44. If you're using PHP 7.x (and some versions of PHP 5.x) and attempt to run update.php you will probably encounter an error on line 33:

set_magic_quotes_runtime(0);

This function has been deprecated: http://php.net/manual/en/function.set-magic-quotes-runtime.php

The fix? Just comment that line out and run update.php again.

jflash

Hello! My ISP changed PHP to 7... How to manual update to cpg16?

jflash

Quote from: jflash on October 18, 2016, 08:45:51 PM
Hello! My ISP changed PHP to 7... How to manual update to cpg16?
I made offline website and renewed to 1.6, but now i cant log in, i put username and password, after push button i get blank page and web browser address is http://www.mywebpagename.ee/login.php?referer=

phill104

Did you make sure you ran update.php after the update?

Is so, you will need to either check your servers logs to see what the actual error is, or enable the displaying of errors. A blank page is usually displayed when your server cannot process something but is set to not display errors.
It is a mistake to think you can solve any major problems just with potatoes.

jflash

Quote from: Phill Luckhurst on October 19, 2016, 05:45:31 PM
Did you make sure you ran update.php after the update?

Is so, you will need to either check your servers logs to see what the actual error is, or enable the displaying of errors. A blank page is usually displayed when your server cannot process something but is set to not display errors.
Ooo, update.php logs in, makes some changes and now all website has blank page :( But, then i renamed plugins directory and all works! So i have some incompatible plugins too.

jflash


phill104

A lot of the plugins are not yet ready for CPG1.6, but many are. Some will require minor modifications and others a little more extensive efforts to make them work. With such a small team things take longer than we would all like. We have been extremely lucky to have had ron4mac, Andre and gmc spend their valuable time making CPG1.6 ready for PHP7, particularly ron4mac in this case.
It is a mistake to think you can solve any major problems just with potatoes.

BillR

I know it's been a few months for this topic, but I just happened across while searching for a solution. I'm in the same boat, I need to run php7 for my store software. I do still have a working copy of my gallery in a folder running php5.6 but it's not going to be for much longer.

Anyway, when I try the upgrader.php, I get this error -

Error
Releases of CPG not found at Github

Any easy way to fix that or have things moved somewhere else now?

Thanks,
- Bill