Coppermine 1.5.10 and PHP 8.1 Coppermine 1.5.10 and PHP 8.1
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Coppermine 1.5.10 and PHP 8.1

Started by shortmort37, May 15, 2023, 06:47:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

shortmort37

I have Coppermine bridged to phpBB, which I've recently upgraded to 3.3.10 because it was using PHP 7.4, which is going to be deprecated.  I'm able to switch to PHP 8.1, but that breaks coppermine.

I had this experience once before, related to mysqli; the solution was to modify includes/functions.inc.php to include this code:

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


I also added the file mysql_mysqli.inc.php to the includes path, and that fixed the issue.  That time.

Is there a similar, easy fix to be able to use PHP 8.1 - or, do I need to do a wholesale upgrade of coppermine to 1.6.x?

Thanks
Dan

shortmort37

For what it's worth, my webserver reports a 500 Error when going to Coppermine via the bridge, after I've swapped PHP 8.1 in for PHP 7.4.

Dan

Joe Carver

Quote from: shortmort37 on May 15, 2023, 06:47:26 PM
Is there a similar, easy fix to be able to use PHP 8.1 - or, do I need to do a wholesale upgrade of coppermine to 1.6.x?
You'll need to upgrade. Review the docs before starting.

Quote from: shortmort37 on May 16, 2023, 03:08:02 AM
For what it's worth, my webserver reports a 500 Error when going to Coppermine via the bridge, after I've swapped PHP 8.1 in for PHP 7.4.

Dan
Could be caused by Coppermine itself, your theme or an incompatible plugin as examples.

shortmort37

Quote from: Joe Carver on May 16, 2023, 06:16:40 PM
You'll need to upgrade. Review the docs before starting.

OK, I will give that a shot.  I'll upgrade keeping PHP 7.4, and if that's successful attempt to switch to PHP 8.1.  I'll report my findings back here.

Do you know if the mysqli remediation I refer to at the beginning of this thread is addressed by 1.6.x - or, will I need to reapply it?

Dan

ron4mac

You should upgrade your 1.5.10 gallery to 1.5.48.  Then you can use the installer stub to upgrade to 1.6.x.  CPG 1.6.x will take care of all mysqli and PHP 8 issues with your gallery.  Be aware that some plugins or themes may not be compatible with 1.6.x. 

shortmort37

Quote from: ron4mac on May 17, 2023, 02:34:45 PM
CPG 1.6.x will take care of all mysqli and PHP 8 issues with your gallery.  Be aware that some plugins or themes may not be compatible with 1.6.x.

This is such good news - thanks!

Quote from: ron4mac on May 17, 2023, 02:34:45 PM
You should upgrade your 1.5.10 gallery to 1.5.48.  Then you can use the installer stub to upgrade to 1.6.x.

Is that because there will be issues if I do a single-shot upgrade to 1.6.x?  Someone commented that the installer stub script was just to make it easier for some people - but, how is a two stage process easier?

Thanks
Dan

ron4mac

#6
There are some changes that were made (some involving the db) between 1.5.10 and 1.5.48 that will need to be applied to your gallery before upgrading to 1.6.x.  If you had kept your gallery up to date it would have been a simple one shot upgrade that the installer stub does in a matter of seconds. With 1.6.x, future updates are done with a few simple clicks.

shortmort37


shortmort37

Oh, one last question:  I don't have any plugins, but I do have a bridge from phpBB.  Can I expect that it will continue to work after the upgrade?

Dan

phill104

Yes, but you might have to look at your plugins before you upgrade to make sure there are compatible versions available
It is a mistake to think you can solve any major problems just with potatoes.

shortmort37

OK, I'm starting down the path of upgrading Coppermine so it will be compatible with PHP 8.1...

Quote from: ron4mac on May 17, 2023, 02:34:45 PM
You should upgrade your 1.5.10 gallery to 1.5.48.  Then you can use the installer stub to upgrade to 1.6.x.  CPG 1.6.x will take care of all mysqli and PHP 8 issues with your gallery.  Be aware that some plugins or themes may not be compatible with 1.6.x.

I followed the instructions - copied the source for 1.5.48, and invoked update.php - but, I'm getting this:

QuoteFatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/faulkner/public_html/59gallery/include/functions.inc.php:183 Stack trace: #0 /home/faulkner/public_html/59gallery/include/init.inc.php(171): cpg_db_connect() #1 /home/faulkner/public_html/59gallery/update.php(27): include_once('/home/faulkner/...') #2 {main} thrown in /home/faulkner/public_html/59gallery/include/functions.inc.php on line 183

What are my next steps?

shortmort37

*BUMP*.  Any advice for me?

On the assumption that mysqli was implicated (my bridged phpBB board is running PHP 7.4), I edited the 1.5.48 version of includes/functions.inc.php to include this, as I had with the 1.5.10 version:

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


Still no love.  Now I'm getting this error message:

QuoteDeprecated: Methods with the same name as their class will not be constructors in a future version of PHP; CPGPlugin has a deprecated constructor in /home/faulkner/public_html/59gallery/include/plugin_api.inc.php on line 530

shortmort37

Looking in the 1.5.48 version of include/plugin_api.inc.php at line 530, where the deprecated constructor was reported, I find this:

    function CPGPlugin($properties) {

And I see that in the 1.5.10 version, I had to update this somewhere along the way to this:

    function __construct($properties) {

So I did the same to the 1.5.48 version.  And now, I get 500 errors.

I don't have the option of enabling an earlier version of PHP that 7.4, just to perform the upgrade.  Short of enabling PHP error logging in Apache, do I have any recourse?

phill104

Best bet is to use WAMP and do the work on your local machine. You can then test and work, changing PHP versions as required, to get your site fully tested and running. It is then a simple task to restore the now working site to your hosting.
It is a mistake to think you can solve any major problems just with potatoes.

shortmort37

Quote from: phill104 on June 06, 2023, 08:17:41 PM
Best bet is to use WAMP and do the work on your local machine. You can then test and work, changing PHP versions as required, to get your site fully tested and running. It is then a simple task to restore the now working site to your hosting.

Hmmm... One way, perhaps.  But I don't currently have WAMP installed on my desktop (I have a server-side test env), and it seems like a lot of work to get there.  And, how do I port the updated db to my db bridged to phpBB?  Too many variables.

Instead, I've enabled PHP error logging on my site, and I've found the culprit - at least, the first culprit (and hopefully the last):

QuoteFatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime() in /home/faulkner/public_html/59gallery/update.php:33 Stack trace: #0 {main} thrown in /home/faulkner/public_html/59gallery/update.php on line 33

I see that set_magic_quotes_runtime has been deprecated in PHP 7.4, the earliest version I can use on my server.  Can I safely comment out this line and proceed, or should I do something else?

Thanks
Dan

shortmort37

Quote from: shortmort37 on June 07, 2023, 04:02:02 AM
I see that set_magic_quotes_runtime has been deprecated in PHP 7.4, the earliest version I can use on my server...

It turns out, I *can* install earlier versions of PHP.  So I will give that a try (when I have time, this evening) and report back.

shortmort37

Quote from: shortmort37 on June 07, 2023, 02:05:57 PM
It turns out, I *can* install earlier versions of PHP.  So I will give that a try (when I have time, this evening) and report back.

Good news, bad news; good news - yes, I can install earlier versions of PHP. Bad news - PHP 7.0 is not early enough for 1.5.48.

What version of PHP do I need to revert to, in order for the 1.5.48 update package to work?

shortmort37

Nevermind.  I reverted to PHP 5.4 - the earliest version available on my server - and Coppermine successfully updated!

Now to try the installer stub for 1.6.x!

shortmort37

Quote from: shortmort37 on June 08, 2023, 01:21:41 AM
Nevermind.  I reverted to PHP 5.4 - the earliest version available on my server - and Coppermine successfully updated!

Now to try the installer stub for 1.6.x!

...and that worked!  Upgrade complete.  Thanks all!