From 7e202234f3ba4fae46928852e81bf20c43cffe3f Mon Sep 17 00:00:00 2001 From: Adam Zammit Date: Wed, 26 Apr 2023 16:28:14 +1000 Subject: [PATCH] More php8 compat fixes --- admin/new.php | 2 +- admin/samplelist.php | 4 ++-- admin/set_outcomes.php | 6 +++--- include/pear/Calendar/Calendar.php | 17 +++++++++++++++-- include/pear/Calendar/Day.php | 6 +++--- include/pear/Calendar/Decorator.php | 4 ++-- include/pear/Calendar/Decorator/Textual.php | 6 +++--- include/pear/Calendar/Decorator/Uri.php | 6 +++--- include/pear/Calendar/Decorator/Weekday.php | 6 +++--- include/pear/Calendar/Decorator/Wrapper.php | 6 +++--- include/pear/Calendar/Hour.php | 6 +++--- include/pear/Calendar/Minute.php | 6 +++--- include/pear/Calendar/Month.php | 6 +++--- include/pear/Calendar/Month/Weekdays.php | 6 +++--- include/pear/Calendar/Month/Weeks.php | 6 +++--- include/pear/Calendar/Second.php | 6 +++--- include/pear/Calendar/Table/Helper.php | 4 ++-- include/pear/Calendar/Util/Uri.php | 4 ++-- include/pear/Calendar/Validator.php | 21 +++++++++++++++++---- include/pear/Calendar/Week.php | 4 ++-- include/pear/Calendar/Year.php | 6 +++--- include/pear/Date.php | 4 ++-- include/pear/Date/Span.php | 4 ++-- include/pear/Date/TimeZone.php | 4 ++-- 24 files changed, 88 insertions(+), 62 deletions(-) diff --git a/admin/new.php b/admin/new.php index e9708a7d..e32cd8eb 100644 --- a/admin/new.php +++ b/admin/new.php @@ -94,7 +94,7 @@ if (isset($_POST['import_file'])) } } - $do = implode($do,","); + $do = implode(",",$do); //** - end diff --git a/admin/samplelist.php b/admin/samplelist.php index 41fecc9a..79dfe357 100644 --- a/admin/samplelist.php +++ b/admin/samplelist.php @@ -272,8 +272,8 @@ if (isset($_GET['delete_sample'])){ $db->CompleteTrans(); - if (mysql_errno() == 0){echo "
", T_("Sample $sample_import_id was deleted."), "
"; } - else {echo "
ERROR ".mysql_errno()." ".mysql_error()."\n
";} + if (mysqli_errno() == 0){echo "
", T_("Sample $sample_import_id was deleted."), "
"; } + else {echo "
ERROR ".mysqli_errno()." ".mysqli_error()."\n
";} } unset($_GET['delete_sample']); diff --git a/admin/set_outcomes.php b/admin/set_outcomes.php index d87ea68f..8325aff1 100644 --- a/admin/set_outcomes.php +++ b/admin/set_outcomes.php @@ -60,7 +60,7 @@ if (isset($_POST['default']) && isset($_POST['save'])){ { $sel[] = $val; } - $sel=implode($sel,","); + $sel=implode(",",$sel); $sql = "UPDATE `outcome` as o SET `default` = 1 @@ -108,7 +108,7 @@ if (isset($_POST['qid']) && $_POST['qid'] > 0 && isset($_POST['save'])){ } } - $sel=implode($sel,","); + $sel=implode(",",$sel); $qid = intval($_POST['qid']); $sql = "UPDATE questionnaire @@ -225,7 +225,7 @@ if (isset($_GET['qid'])) { $do[] = $val; } } - $qoutc = implode($do,","); + $qoutc = implode(",",$do); $sql = "UPDATE questionnaire SET outcomes = '$qoutc' diff --git a/include/pear/Calendar/Calendar.php b/include/pear/Calendar/Calendar.php index a3b4aaf2..3d5be737 100644 --- a/include/pear/Calendar/Calendar.php +++ b/include/pear/Calendar/Calendar.php @@ -203,7 +203,7 @@ class Calendar * * @access protected */ - function Calendar($y = 2000, $m = 1, $d = 1, $h = 0, $i = 0, $s = 0) + function __construct($y = 2000, $m = 1, $d = 1, $h = 0, $i = 0, $s = 0) { static $cE = null; if (!isset($cE)) { @@ -392,6 +392,19 @@ class Calendar return false; } + function legacy_each($array){ + $key = key($array); + $value = current($array); + $each = is_null($key) ? false : [ + 1 => $value, + 'value' => $value, + 0 => $key, + 'key' => $key, + ]; + next($array); + return $each; + } + /** * Iterator method for fetching child Calendar subclass objects * (e.g. a minute from an hour object). On reaching the end of @@ -403,7 +416,7 @@ class Calendar */ function fetch() { - $child = each($this->children); + $child = $this->legacy_each($this->children); if ($child) { return $child['value']; } else { diff --git a/include/pear/Calendar/Day.php b/include/pear/Calendar/Day.php index 3ef48538..083a2f12 100644 --- a/include/pear/Calendar/Day.php +++ b/include/pear/Calendar/Day.php @@ -100,9 +100,9 @@ class Calendar_Day extends Calendar * * @access public */ - function Calendar_Day($y, $m, $d) + function __construct($y, $m, $d) { - parent::Calendar($y, $m, $d); + parent::__construct($y, $m, $d); } /** @@ -229,4 +229,4 @@ class Calendar_Day extends Calendar return $this->empty; } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Decorator.php b/include/pear/Calendar/Decorator.php index e4e27663..f7d90723 100644 --- a/include/pear/Calendar/Decorator.php +++ b/include/pear/Calendar/Decorator.php @@ -76,7 +76,7 @@ class Calendar_Decorator * * @param object &$calendar subclass to Calendar to decorate */ - function Calendar_Decorator(&$calendar) + function __construct(&$calendar) { $this->calendar = & $calendar; } @@ -647,4 +647,4 @@ class Calendar_Decorator return $this->calendar->nextSecond($format); } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Decorator/Textual.php b/include/pear/Calendar/Decorator/Textual.php index 72986201..29d1bfe3 100644 --- a/include/pear/Calendar/Decorator/Textual.php +++ b/include/pear/Calendar/Decorator/Textual.php @@ -79,9 +79,9 @@ class Calendar_Decorator_Textual extends Calendar_Decorator * * @access public */ - function Calendar_Decorator_Textual(&$Calendar) + function __construct(&$Calendar) { - parent::Calendar_Decorator($Calendar); + parent::__construct($Calendar); } /** @@ -205,4 +205,4 @@ class Calendar_Decorator_Textual extends Calendar_Decorator return Calendar_Util_Textual::orderedWeekdays($this->calendar, $format); } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Decorator/Uri.php b/include/pear/Calendar/Decorator/Uri.php index 08e4deb6..a2fb5ded 100644 --- a/include/pear/Calendar/Decorator/Uri.php +++ b/include/pear/Calendar/Decorator/Uri.php @@ -92,9 +92,9 @@ class Calendar_Decorator_Uri extends Calendar_Decorator * * @access public */ - function Calendar_Decorator_Uri(&$Calendar) + function __construct(&$Calendar) { - parent::Calendar_Decorator($Calendar); + parent::__construct($Calendar); } /** @@ -180,4 +180,4 @@ class Calendar_Decorator_Uri extends Calendar_Decorator return $this->Uri->next($this, $method); } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Decorator/Weekday.php b/include/pear/Calendar/Decorator/Weekday.php index d02c87dc..096e089f 100644 --- a/include/pear/Calendar/Decorator/Weekday.php +++ b/include/pear/Calendar/Decorator/Weekday.php @@ -88,9 +88,9 @@ class Calendar_Decorator_Weekday extends Calendar_Decorator * * @access public */ - function Calendar_Decorator_Weekday(&$Calendar) + function __construct(&$Calendar) { - parent::Calendar_Decorator($Calendar); + parent::__construct($Calendar); } /** @@ -192,4 +192,4 @@ class Calendar_Decorator_Weekday extends Calendar_Decorator } } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Decorator/Wrapper.php b/include/pear/Calendar/Decorator/Wrapper.php index 4ed2f84a..c5baf2ea 100644 --- a/include/pear/Calendar/Decorator/Wrapper.php +++ b/include/pear/Calendar/Decorator/Wrapper.php @@ -71,9 +71,9 @@ class Calendar_Decorator_Wrapper extends Calendar_Decorator * * @access public */ - function Calendar_Decorator_Wrapper(&$Calendar) + function __construct(&$Calendar) { - parent::Calendar_Decorator($Calendar); + parent::__construct($Calendar); } /** @@ -112,4 +112,4 @@ class Calendar_Decorator_Wrapper extends Calendar_Decorator return $children; } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Hour.php b/include/pear/Calendar/Hour.php index fe05024b..38f19f9b 100644 --- a/include/pear/Calendar/Hour.php +++ b/include/pear/Calendar/Hour.php @@ -80,9 +80,9 @@ class Calendar_Hour extends Calendar * * @access public */ - function Calendar_Hour($y, $m, $d, $h) + function __construct($y, $m, $d, $h) { - parent::Calendar($y, $m, $d, $h); + parent::__construct($y, $m, $d, $h); } /** @@ -134,4 +134,4 @@ class Calendar_Hour extends Calendar } } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Minute.php b/include/pear/Calendar/Minute.php index 7c0b014f..a6b72757 100644 --- a/include/pear/Calendar/Minute.php +++ b/include/pear/Calendar/Minute.php @@ -81,9 +81,9 @@ class Calendar_Minute extends Calendar * * @access public */ - function Calendar_Minute($y, $m, $d, $h, $i) + function __construct($y, $m, $d, $h, $i) { - parent::Calendar($y, $m, $d, $h, $i); + parent::__construct($y, $m, $d, $h, $i); } /** @@ -135,4 +135,4 @@ class Calendar_Minute extends Calendar } } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Month.php b/include/pear/Calendar/Month.php index afd01727..bf2bcb66 100644 --- a/include/pear/Calendar/Month.php +++ b/include/pear/Calendar/Month.php @@ -79,9 +79,9 @@ class Calendar_Month extends Calendar * * @access public */ - function Calendar_Month($y, $m, $firstDay=null) + function __construct($y, $m, $firstDay=null) { - parent::Calendar($y, $m); + parent::__construct($y, $m); $this->firstDay = $this->defineFirstDayOfWeek($firstDay); } @@ -135,4 +135,4 @@ class Calendar_Month extends Calendar } } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Month/Weekdays.php b/include/pear/Calendar/Month/Weekdays.php index a2a4cf19..5c56e5f7 100644 --- a/include/pear/Calendar/Month/Weekdays.php +++ b/include/pear/Calendar/Month/Weekdays.php @@ -108,9 +108,9 @@ class Calendar_Month_Weekdays extends Calendar_Month * * @access public */ - function Calendar_Month_Weekdays($y, $m, $firstDay=null) + function __construct($y, $m, $firstDay=null) { - parent::Calendar_Month($y, $m, $firstDay); + parent::__construct($y, $m, $firstDay); } /** @@ -212,4 +212,4 @@ class Calendar_Month_Weekdays extends Calendar_Month } } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Month/Weeks.php b/include/pear/Calendar/Month/Weeks.php index aab65139..d42656f9 100644 --- a/include/pear/Calendar/Month/Weeks.php +++ b/include/pear/Calendar/Month/Weeks.php @@ -100,9 +100,9 @@ class Calendar_Month_Weeks extends Calendar_Month * * @access public */ - function Calendar_Month_Weeks($y, $m, $firstDay=null) + function __construct($y, $m, $firstDay=null) { - parent::Calendar_Month($y, $m, $firstDay); + parent::__construct($y, $m, $firstDay); } /** @@ -163,4 +163,4 @@ class Calendar_Month_Weeks extends Calendar_Month } } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Second.php b/include/pear/Calendar/Second.php index b1b962b8..2b59505b 100644 --- a/include/pear/Calendar/Second.php +++ b/include/pear/Calendar/Second.php @@ -74,9 +74,9 @@ class Calendar_Second extends Calendar * @param int $i minute e.g. 31 * @param int $s second e.g. 45 */ - function Calendar_Second($y, $m, $d, $h, $i, $s) + function __construct($y, $m, $d, $h, $i, $s) { - parent::Calendar($y, $m, $d, $h, $i, $s); + parent::__construct($y, $m, $d, $h, $i, $s); } /** @@ -119,4 +119,4 @@ class Calendar_Second extends Calendar return null; } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Table/Helper.php b/include/pear/Calendar/Table/Helper.php index c852dc08..15a44e8b 100644 --- a/include/pear/Calendar/Table/Helper.php +++ b/include/pear/Calendar/Table/Helper.php @@ -114,7 +114,7 @@ class Calendar_Table_Helper * * @access protected */ - function Calendar_Table_Helper(& $calendar, $firstDay=null) + function __construct(& $calendar, $firstDay=null) { $this->calendar = & $calendar; $this->cE = & $calendar->getEngine(); @@ -313,4 +313,4 @@ class Calendar_Table_Helper return $this->cE->dateToStamp($y, $m, $d); } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Util/Uri.php b/include/pear/Calendar/Util/Uri.php index 1490501f..0c566caa 100644 --- a/include/pear/Calendar/Util/Uri.php +++ b/include/pear/Calendar/Util/Uri.php @@ -98,7 +98,7 @@ class Calendar_Util_Uri * * @access public */ - function Calendar_Util_Uri($y, $m=null, $d=null, $h=null, $i=null, $s=null) + function __construct($y, $m=null, $d=null, $h=null, $i=null, $s=null) { $this->setFragments($y, $m, $d, $h, $i, $s); } @@ -201,4 +201,4 @@ class Calendar_Util_Uri return $uriString; } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Validator.php b/include/pear/Calendar/Validator.php index a96c8e22..461adbfa 100644 --- a/include/pear/Calendar/Validator.php +++ b/include/pear/Calendar/Validator.php @@ -89,7 +89,7 @@ class Calendar_Validator * * @access public */ - function Calendar_Validator(&$calendar) + function __construct(&$calendar) { $this->calendar = & $calendar; $this->cE = & $calendar->getEngine(); @@ -261,6 +261,19 @@ class Calendar_Validator return true; } + function legacy_each($array){ + $key = key($array); + $value = current($array); + $each = is_null($key) ? false : [ + 1 => $value, + 'value' => $value, + 0 => $key, + 'key' => $key, + ]; + next($array); + return $each; + } + /** * Iterates over any validation errors * @@ -269,7 +282,7 @@ class Calendar_Validator */ function fetch() { - $error = each($this->errors); + $error = $this->legacy_each($this->errors); if ($error) { return $error['value']; } else { @@ -323,7 +336,7 @@ class Calendar_Validation_Error * * @access protected */ - function Calendar_Validation_Error($unit, $value, $message) + function __construct($unit, $value, $message) { $this->unit = $unit; $this->value = $value; @@ -374,4 +387,4 @@ class Calendar_Validation_Error return $this->unit.' = '.$this->value.' ['.$this->message.']'; } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Week.php b/include/pear/Calendar/Week.php index 966128f2..efb717e2 100644 --- a/include/pear/Calendar/Week.php +++ b/include/pear/Calendar/Week.php @@ -135,7 +135,7 @@ class Calendar_Week extends Calendar * * @access public */ - function Calendar_Week($y, $m, $d, $firstDay = null) + function __construct($y, $m, $d, $firstDay = null) { include_once CALENDAR_ROOT.'Table/Helper.php'; parent::Calendar($y, $m, $d); @@ -467,4 +467,4 @@ class Calendar_Week extends Calendar } } } -?> \ No newline at end of file +?> diff --git a/include/pear/Calendar/Year.php b/include/pear/Calendar/Year.php index a52f8dd2..c4c2c3d7 100644 --- a/include/pear/Calendar/Year.php +++ b/include/pear/Calendar/Year.php @@ -77,9 +77,9 @@ class Calendar_Year extends Calendar * * @access public */ - function Calendar_Year($y) + function __construct($y) { - parent::Calendar($y); + parent::__construct($y); } /** @@ -137,4 +137,4 @@ class Calendar_Year extends Calendar } } } -?> \ No newline at end of file +?> diff --git a/include/pear/Date.php b/include/pear/Date.php index 99e42c28..3957d699 100644 --- a/include/pear/Date.php +++ b/include/pear/Date.php @@ -196,7 +196,7 @@ class Date * @param mixed $date optional - date/time to initialize * @return object Date the new Date object */ - function Date($date = null) + function __construct($date = null) { $this->tz = Date_TimeZone::getDefault(); if (is_null($date)) { @@ -1462,4 +1462,4 @@ class Date * c-hanging-comment-ender-p: nil * End: */ -?> \ No newline at end of file +?> diff --git a/include/pear/Date/Span.php b/include/pear/Date/Span.php index ca989bfd..79f9f9b8 100644 --- a/include/pear/Date/Span.php +++ b/include/pear/Date/Span.php @@ -150,7 +150,7 @@ class Date_Span * @see set() * @access public */ - function Date_Span($time = 0, $format = null) + function __construct($time = 0, $format = null) { $this->set($time, $format); } @@ -1080,4 +1080,4 @@ class Date_Span * c-hanging-comment-ender-p: nil * End: */ -?> \ No newline at end of file +?> diff --git a/include/pear/Date/TimeZone.php b/include/pear/Date/TimeZone.php index 78c9d3ff..a0c67609 100644 --- a/include/pear/Date/TimeZone.php +++ b/include/pear/Date/TimeZone.php @@ -133,7 +133,7 @@ class Date_TimeZone * @param string $id the time zone id * @return object Date_TimeZone the new Date_TimeZone object */ - function Date_TimeZone($id) + function __construct($id) { $_DATE_TIMEZONE_DATA =& $GLOBALS['_DATE_TIMEZONE_DATA']; if(Date_TimeZone::isValidID($id)) { @@ -4728,4 +4728,4 @@ if(isset($GLOBALS['_DATE_TIMEZONE_DEFAULT']) * c-hanging-comment-ender-p: nil * End: */ -?> \ No newline at end of file +?>