
Welcome to all phpBB2 Refugees! This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area. |
|
Author |
Message |
s1eelra1 Board Member

Joined: 08 Apr 2015
     Posts: 7

|
Posted: Wed Nov 18, 2020 2:34 pm Post subject: Topic Calendar 1.2.2 php7.x constructors |
|
|
Let me start by saying I have a working 2.0.24 board, on php7.4.x and it works just fine. The host switched us to php7.x in spring so there was a scramble to make the php7 adjustments.
I'm now working through the updating of the "notice/deprecated/warning", so hopefully there will be more time, and less to fix the next time the host requires a php upgrade.
The current problem is the class/function/constructors for the topic calendar mod. I've been doing searches via google, stackoverflow, here etc. Unfortunately, I've only been able to replace some of class/functions. At one point I had the calendar page it self stop reporting errors, but also had the portions of the page stop working.
Here's one of the original sections of code:
Code: |
function calendar_api()
{
$this->days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$this->elapsed_days = array(0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365);
$this->monthes_list = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$this->days_list = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$this->format_short = '';
$this->format_medium = '';
$this->format_long = '';
$this->timezone = 0;
$this->set = false;
}
|
Which I've been able to hack into this:
Code: |
/*
//-- php7.2/7.4 fixes
//-- phpbb 2.0.25
//-- code replace
function calendar_api()
*/
function __construct()
//-- fin replace
{
$this->days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$this->elapsed_days = array(0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365);
$this->monthes_list = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$this->days_list = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$this->format_short = '';
$this->format_medium = '';
$this->format_long = '';
$this->timezone = 0;
$this->set = false;
}
/*
//-- php7.2/7.4 fixes
//-- phpbb 2.0.25
//-- code add to pair with the replace in the function name
*/
function calendar_api()
{
self::__construct();
}
|
And it seems to work. But I've found more trouble when I do similar changes to function -> that has extends parent::. Also there's at least one file which has 3 classes in it. I'm not sure if that then means it needs to be a multi constructor format or not.
Does anybody have some good examples of "how" to do a better constructor format?
I've attached the original mod download, just in case it's helpful. Currently I'm having the most trouble with the class_calendar_handler.php.
TIA
Description: |
topic calendar 1.2.2 build version |
|
 Download |
Filename: |
TC122p0.zip |
Filesize: |
83.48 KB |
Downloaded: |
157 Time(s) |
|
|
Back to top |
|
 |
StarWolf3000 Board Member

Joined: 10 Jun 2010
          Posts: 162 Location: Germany

|
Posted: Thu Nov 26, 2020 10:19 am Post subject: Re: Topic Calendar 1.2.2 php7.x constructors |
|
|
There should be no need to use classic-style constructors in recent PHP versions, so this snippet is obsolete (it might even be ignored by PHP by now):
Code: | /*
//-- php7.2/7.4 fixes
//-- phpbb 2.0.25
//-- code add to pair with the replace in the function name
*/
function calendar_api()
{
self::__construct();
} |
For classes that extend from a parent class, you have to replace the constructor of both the parent and inheriting class(es).
Example:
Code: | class Mysqli {
function Mysqli(...) {
}
} |
Code: | class sql_db extends Mysqli {
function sql_db(...) {
parent::Mysqli(...);
}
} |
Change the parent constructor:
Code: | class Mysqli {
function __construct(...) {
}
} |
Change the inheriting class constructor:
Code: | class sql_db extends Mysqli {
function __construct(...) {
parent::__construct(...);
}
} |
Quote: | Currently I'm having the most trouble with the class_calendar_handler.php. |
Replace:
Code: | function calendar_root($requester='', $parms='')
{
$this->requester = $requester;
$this->parms = empty($parms) ? array() : $parms;
$this->id_prefix = 'item_';
} |
with:
Code: | function __construct($requester='', $parms='')
{
$this->requester = $requester;
$this->parms = empty($parms) ? array() : $parms;
$this->id_prefix = 'item_';
} |
Replace:
Code: | function calendar_event($requester, $parms, &$handler, $module_id)
{
parent::calendar_root($requester, $parms);
$this->handler = &$handler;
$this->module_id = $module_id;
$this->data = array();
} |
with:
Code: | function __construct($requester, $parms, &$handler, $module_id)
{
parent::__construct($requester, $parms);
$this->handler = &$handler; // <- I'm unsure if the & is needed here, might throw a Fatal Error
$this->module_id = $module_id;
$this->data = array();
} |
Replace:
Code: | function calendar_handler($requester='', $parms='')
{
global $calendar_api, $calendar_modules;
parent::calendar_root($requester, $parms);
$this->queues = array();
$this->map = array();
$this->modules = &$calendar_modules;
$this->txt_overview = array();
$this->selection_form = array();
$this->settings = $this->retrieve_settings();
$this->selection_def();
$calendar_api->set();
} |
with:
Code: | function __construct($requester='', $parms='')
{
global $calendar_api, $calendar_modules;
parent::__construct($requester, $parms);
$this->queues = array();
$this->map = array();
$this->modules = &$calendar_modules; // <- I'm unsure if the & is needed here, might throw a Fatal Error
$this->txt_overview = array();
$this->selection_form = array();
$this->settings = $this->retrieve_settings();
$this->selection_def();
$calendar_api->set();
} |
|
|
Back to top |
|
 |
s1eelra1 Board Member

Joined: 08 Apr 2015
     Posts: 7

|
Posted: Thu Nov 26, 2020 2:47 pm Post subject: Re: Topic Calendar 1.2.2 php7.x constructors |
|
|
thank you sir. I'll give it a whirl.
So far I made progress with the __construct, and a call to "self::old function name", but it did break one thing on the calendar page.
I also found that quite possibly I did a blanket removal of &$ variables for php5.4 possibly. For most of the pages from the original phpbb code, they got re-added. Once I realized that, I've been going through older backup revisions to see if I can find where else I stupidly removed $&. With the full download of the original topic calendar, I have put all those back in already.
|
|
Back to top |
|
 |
Vendethiel Board Member

Joined: 26 Oct 2014
      Posts: 210

|
Posted: Tue Dec 08, 2020 1:19 pm Post subject: Re: Topic Calendar 1.2.2 php7.x constructors |
|
|
The &$ should only be removed when calling the function, not when declaring it.
_________________ Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs). |
|
Back to top |
|
 |
s1eelra1 Board Member

Joined: 08 Apr 2015
     Posts: 7

|
Posted: Wed Dec 09, 2020 4:36 pm Post subject: Re: Topic Calendar 1.2.2 php7.x constructors |
|
|
Thanks. I realized my mistake, and even noticed, where I had put old lines of code back in before; Probably when doing that change the first time for php5. The &$ fixed a part of the page that I did not know was broken on php7 -- it fixed how the birthday are placed over the month.
Also the __construct is presently working.
I still have a whole bunch of "notice: undefined index," and other things like that with the calendar. But at least the "deprecated/warnings" seem to be dealt with.
|
|
Back to top |
|
 |
|
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0287 seconds using 17 queries. (SQL 0.0018 Parse 0.0023 Other 0.0245) |
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com
|
|