forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: Johnson.Wang on December 07, 2015, 12:05:33 pm

Title: PHP7 / MySQLi / PDO support in Coppermine?
Post by: Johnson.Wang on December 07, 2015, 12:05:33 pm
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.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: phill104 on December 08, 2015, 10:49:16 am
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.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: 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/ (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.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: phill104 on December 25, 2015, 09:14:59 pm
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.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: Daggers on January 27, 2016, 07:54:28 am
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
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: gmc on January 27, 2016, 01:13:18 pm
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.
For the mysql_connect support in PHP7, there is a library on http://sourceforge.net/projects/mysqlwithmysqli/ (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:
Code: [Select]
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:
Code: [Select]
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.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: ron4mac on January 27, 2016, 02:36:38 pm
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.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: 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. 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 ;)
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: ron4mac on May 03, 2016, 12:43:22 pm
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?
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: 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.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: ron4mac on May 05, 2016, 09:50:09 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
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: MarioKnight on July 07, 2016, 05:41:43 pm
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
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: sah62 on October 06, 2016, 03:40:51 pm
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:

Code: [Select]
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.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: jflash on October 18, 2016, 08:45:51 pm
Hello! My ISP changed PHP to 7... How to manual update to cpg16?
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: jflash on October 19, 2016, 12:59:54 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=
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: phill104 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.
Title: Re: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: jflash on October 19, 2016, 09:02:13 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.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: jflash on October 19, 2016, 09:03:18 pm
Thank you Phill!  ;)
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: phill104 on October 20, 2016, 11:11:51 am
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.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: BillR on December 10, 2016, 03:04:33 am
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
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: ron4mac on December 10, 2016, 05:01:21 am
Error
Releases of CPG not found at Github

Any easy way to fix that or have things moved somewhere else now?
It is still in place and works okay in my test. Your setup may not have allow_url_fopen enabled in your PHP and the extension libcurl is also not loaded. One of these is required for the upgrader to be able to access the 1.6.01 release on Github.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: BillR on December 10, 2016, 05:22:53 am
It's ok, It didn't take long to do it manually anyway - I dont use any modifications, so 1.6 works just fine. I guess tommorow I'll copy it into a php7 folder and see how that works.
  I can't thank you guys enough for all the work, coppermine has been my preferred gallery for as long as I can remember...10-12 years maybe?
- Bill
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: BillR on December 10, 2016, 06:48:32 am
Just a last little comment, works great on php7, I'm a happy camper :)
 Thanks again for the gallery work.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: maxhasher on January 11, 2017, 09:57:24 pm
I managed to get 1.6 in upgraded and running. On first choice for login I made the mistake of selecting pdo:mysql and this added pdomysql in the onit as database option. This is not one of the paths. So I edited back yo mysqli and then everything was happy.
The cookie still registered as 1.5x though.. Excellent work there. But I should be OK with updating on the ISP. Which is recommending php7 for the longer term support.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: Dale M. on July 14, 2017, 09:59:51 pm
New here and don't know squat about PHP... But got my gallery killed with  server updating to PHP 7..

It appears  as same error  as DAGGERS  posted on 1-27-16 and it appears there is a FIX in very next posting, but I don't know how to go about it (yes I am php ignorant) but is there a  simple set of step by step procedure  to get the fix to work?. I know its to copy "this" to "that"  in the "whatsit" file but its sort of greek as I am not php programmer or even familiar.. I know it has to be simple, but not for me?.... Thank to anyone who can walk me through it...

Dale M.
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: phill104 on July 14, 2017, 11:11:44 pm
That fix was a temporary workaround. Best bet now is to upgrade to version 1.6.x, but you may run into a few problems if you were not up to date. Do a search on the forums regarding upgrading to 1.6 and you will find plenty of instruction. Here is one such thread - http://forum.coppermine-gallery.net/index.php/topic,79013.0.html
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: Dale M. on July 14, 2017, 11:55:31 pm
Been there done that, all I get is error when I try to run "upgrader.php"...

This is error, sort of puts me back to square 1...

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/maripos1/public_html/gallery/include/functions.inc.php:183 Stack trace: #0 /home/maripos1/public_html/gallery/include/init.inc.php(171): cpg_db_connect() #1 /home/maripos1/public_html/gallery/upgrader.php(21): require('/home/maripos1/...') #2 {main} thrown in /home/maripos1/public_html/gallery/include/functions.inc.php on line 183

So far "cpg_install_stub.php" and "upgrader.php" are no go.... And yes I did remove the "txt"  in file name and I did verify I was using proper URL to run file.. Just frustrated...

Dale
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: phill104 on July 15, 2017, 01:41:26 pm
What version of cpg were you running?
Title: Re: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: Dale M. on July 15, 2017, 03:20:13 pm
What version of cpg were you running?

Version 1.5.42 according to change log in CPG root directory...

Dale


Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: phill104 on July 15, 2017, 03:40:18 pm
I will leave this in the other thread you have as this appears to be a duplicate of the same issue
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: donsenilo on August 17, 2017, 11:24:30 pm
For the mysql_connect support in PHP7, there is a library on http://sourceforge.net/projects/mysqlwithmysqli/ (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.
Hi

I had (!) to use PHP7.
I've downloaded the library but what now ? How can I use it ?
Title: Re: PHP7 / MySQLi / PDO support in Coppermine?
Post by: gmc on August 18, 2017, 03:30:54 am
As stated in the post you quoted - it won't fix all the errors under PHP7.. Likely best to upgrade to CPG 1.6.

But to use the file you downloaded - you would need to place it in the CPG directory on your server - I would suggest in yourcpgfolder/include directory...
Then open yourcpgfolder/include/init.inc.php and find:
Code: [Select]
require 'include/functions.inc.php';
and insert before it:
Code: [Select]
require 'include/mysql_mysqli.inc.php';
(substitute the file name you saved/uploaded as if different...)

When a mysql_ function is called - it will be defined by this addition - and will call the equivalent (assuming the library is coded correctly - I haven't used or tested it) mysqli function for you and return the result.

Again - there will be other issues with CPG 1.5 and PHP7... These are all resolved in CPG 1.6.