Advanced search  

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]

Pages: [1]   Go Down

Author Topic: Coppermine 1.5.10 and PHP 8.1  (Read 17248 times)

0 Members and 1 Guest are viewing this topic.

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Coppermine 1.5.10 and PHP 8.1
« on: May 15, 2023, 06:47:26 pm »

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:

Code: [Select]
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
Logged

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #1 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
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1545
  • aka 'i-imagine'
    • Home Page
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #2 on: May 16, 2023, 06:16:40 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.

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

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #3 on: May 17, 2023, 04:39:16 am »

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
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2027
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #4 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. 
Logged

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #5 on: May 17, 2023, 09:43:38 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!

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
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2027
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #6 on: May 17, 2023, 10:05:36 pm »

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.
« Last Edit: May 18, 2023, 03:19:27 am by ron4mac »
Logged

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #7 on: May 18, 2023, 04:15:49 am »

Fair enough.  Thank you!

Dan
Logged

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #8 on: May 18, 2023, 04:25:45 am »

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
Logged

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4886
    • Windsurf.me
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #9 on: May 19, 2023, 10:16:38 pm »

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

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #10 on: June 04, 2023, 09:43:31 pm »

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

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:

Quote
Fatal 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?
Logged

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #11 on: June 06, 2023, 02:37:09 am »

*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:

Code: [Select]
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:

Quote
Deprecated: 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
Logged

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #12 on: June 06, 2023, 03:06:56 am »

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:

Code: [Select]
    function CPGPlugin($properties) {
And I see that in the 1.5.10 version, I had to update this somewhere along the way to this:

Code: [Select]
    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?
Logged

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4886
    • Windsurf.me
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #13 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.
Logged
It is a mistake to think you can solve any major problems just with potatoes.

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #14 on: June 07, 2023, 04:02:02 am »

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):

Quote
Fatal 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
Logged

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #15 on: June 07, 2023, 02:05:57 pm »

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.
Logged

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #16 on: June 08, 2023, 01:14:09 am »

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?
Logged

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #17 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!
Logged

shortmort37

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 98
Re: Coppermine 1.5.10 and PHP 8.1
« Reply #18 on: June 08, 2023, 03:58:28 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!
Logged
Pages: [1]   Go Up
 

Page created in 0.028 seconds with 19 queries.