mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 21:57:51 +02:00
Fix all PHP 8.0 test failures
This commit is contained in:
14
.github/workflows/test-unit.yml
vendored
14
.github/workflows/test-unit.yml
vendored
@@ -17,15 +17,23 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
interpreter:
|
interpreter:
|
||||||
- image: php:5.6
|
- image: php:5.6
|
||||||
|
- image: php:7.0
|
||||||
- image: php:7.1
|
- image: php:7.1
|
||||||
- image: php:7.2
|
- image: php:7.2
|
||||||
- image: php:7.3
|
- image: php:7.3
|
||||||
- image: php:7.4
|
- image: php:7.4
|
||||||
|
- image: php:8.0-rc
|
||||||
db:
|
db:
|
||||||
- image: mysql:5.5
|
- image: mysql:5.5
|
||||||
- image: mysql:5.6
|
- image: mysql:5.6
|
||||||
- image: mysql:5.7
|
- image: mysql:5.7
|
||||||
|
- image: bitnami/mysql:8.0
|
||||||
|
- image: mariadb:10.0
|
||||||
|
- image: mariadb:10.1
|
||||||
|
- image: mariadb:10.2
|
||||||
|
- image: mariadb:10.3
|
||||||
- image: mariadb:10.4
|
- image: mariadb:10.4
|
||||||
|
- image: mariadb:10.5
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ${{ matrix.interpreter.image }}
|
image: ${{ matrix.interpreter.image }}
|
||||||
@@ -35,6 +43,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
MYSQL_ROOT_PASSWORD: 'Database Password for Continuous Integration'
|
MYSQL_ROOT_PASSWORD: 'Database Password for Continuous Integration'
|
||||||
MYSQL_DATABASE: 'app'
|
MYSQL_DATABASE: 'app'
|
||||||
|
MYSQL_AUTHENTICATION_PLUGIN: 'mysql_native_password'
|
||||||
options: >-
|
options: >-
|
||||||
--health-cmd "mysqladmin ping"
|
--health-cmd "mysqladmin ping"
|
||||||
--health-interval 10s
|
--health-interval 10s
|
||||||
@@ -77,9 +86,12 @@ jobs:
|
|||||||
if [ $(php -r 'printf(version_compare(PHP_VERSION, "7.2.0", ">=") ? 1 : 0);') = '1' ]
|
if [ $(php -r 'printf(version_compare(PHP_VERSION, "7.2.0", ">=") ? 1 : 0);') = '1' ]
|
||||||
then
|
then
|
||||||
pecl install xdebug
|
pecl install xdebug
|
||||||
elif [ $(php -r 'printf(version_compare(PHP_VERSION, "7.0.0", ">=") ? 1 : 0);') = '1' ]
|
elif [ $(php -r 'printf(version_compare(PHP_VERSION, "7.1.0", ">=") ? 1 : 0);') = '1' ]
|
||||||
then
|
then
|
||||||
pecl install xdebug-2.9.8
|
pecl install xdebug-2.9.8
|
||||||
|
elif [ $(php -r 'printf(version_compare(PHP_VERSION, "7.0.0", ">=") ? 1 : 0);') = '1' ]
|
||||||
|
then
|
||||||
|
pecl install xdebug-2.7.2
|
||||||
else
|
else
|
||||||
pecl install xdebug-2.5.5
|
pecl install xdebug-2.5.5
|
||||||
fi
|
fi
|
||||||
|
@@ -2552,10 +2552,10 @@ class error_handler
|
|||||||
* @param $message
|
* @param $message
|
||||||
* @param $file
|
* @param $file
|
||||||
* @param $line
|
* @param $line
|
||||||
* @param $context
|
* @param $context (deprecated since PHP 7.2.0)
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function handle_error($type, $message, $file, $line, $context) {
|
function handle_error($type, $message, $file, $line, $context = null) {
|
||||||
$startup_error = (!defined('E107_DEBUG_LEVEL')); // Error before debug system initialized
|
$startup_error = (!defined('E107_DEBUG_LEVEL')); // Error before debug system initialized
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1414,7 +1414,7 @@ class lancheck
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function checkLog($type='error',$count)
|
function checkLog($type='error',$count=1)
|
||||||
{
|
{
|
||||||
$lan = $this->transLanguage;
|
$lan = $this->transLanguage;
|
||||||
$_SESSION['lancheck'][$lan][$type] += $count;
|
$_SESSION['lancheck'][$lan][$type] += $count;
|
||||||
@@ -1602,9 +1602,9 @@ class lancheck
|
|||||||
|
|
||||||
|
|
||||||
// for plugins and themes - checkes what kind of language files directory structure we have
|
// for plugins and themes - checkes what kind of language files directory structure we have
|
||||||
function check_lanfiles($mode,$comp_name,$base_lan="English",$target_lan)
|
function check_lanfiles($mode,$comp_name,$base_lan="English",$target_lan=null)
|
||||||
{
|
{
|
||||||
|
if (empty($target_lan)) throw new RuntimeException(__METHOD__ . ' requires non-empty $target_lan');
|
||||||
|
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
@@ -227,7 +227,7 @@ class news_shortcodes extends e_shortcode
|
|||||||
<li><a href="'.$url.'">'.e107::getParser()->toHTML($caption,false,'defs').'</a></li>
|
<li><a href="'.$url.'">'.e107::getParser()->toHTML($caption,false,'defs').'</a></li>
|
||||||
</ul>';
|
</ul>';
|
||||||
|
|
||||||
if(BOOTSTRAP === 4)
|
if(defined('BOOTSTRAP') && BOOTSTRAP === 4)
|
||||||
{
|
{
|
||||||
$text = '<a class="pager-button btn btn-primary hidden-print" href="'.$url.'">'.e107::getParser()->toHTML($caption,false,'defs').'</a>';
|
$text = '<a class="pager-button btn btn-primary hidden-print" href="'.$url.'">'.e107::getParser()->toHTML($caption,false,'defs').'</a>';
|
||||||
}
|
}
|
||||||
|
@@ -166,7 +166,7 @@ class cpage_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
if(e107::getPref('comments_disabled') == 0 && !$comflag)
|
if(e107::getPref('comments_disabled') == 0 && !$comflag)
|
||||||
{
|
{
|
||||||
if(BOOTSTRAP)
|
if(defined('BOOTSTRAP') && BOOTSTRAP)
|
||||||
{
|
{
|
||||||
return e107::getMessage()->addInfo(LAN_PAGE_17)->render();
|
return e107::getMessage()->addInfo(LAN_PAGE_17)->render();
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
class sitelinks_alt
|
class sitelinks_alt
|
||||||
{
|
{
|
||||||
function sitelinks_alt_shortcode($parm)
|
static function sitelinks_alt_shortcode($parm)
|
||||||
{
|
{
|
||||||
|
|
||||||
$params = explode('+', $parm);
|
$params = explode('+', $parm);
|
||||||
@@ -95,7 +95,7 @@ class sitelinks_alt
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function adnav_cat($cat_title, $cat_link, $cat_img, $cat_id = FALSE, $cat_open = FALSE)
|
static function adnav_cat($cat_title, $cat_link, $cat_img, $cat_id = FALSE, $cat_open = FALSE)
|
||||||
{
|
{
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ class sitelinks_alt
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
function adnav_main($cat_title, $cat_link, $cat_img, $cat_id = FALSE, $params, $cat_open = FALSE)
|
static function adnav_main($cat_title, $cat_link, $cat_img, $cat_id = FALSE, $params, $cat_open = FALSE)
|
||||||
{
|
{
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ class sitelinks_alt
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
function render_sub($linklist, $id, $params, $icon)
|
static function render_sub($linklist, $id, $params, $icon)
|
||||||
{
|
{
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
38
e107_handlers/Shims/Internal/GetParentClassTrait.php
Normal file
38
e107_handlers/Shims/Internal/GetParentClassTrait.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2020 e107 Inc (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace e107\Shims\Internal;
|
||||||
|
|
||||||
|
trait GetParentClassTrait
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Retrieves the parent class name for object or class
|
||||||
|
*
|
||||||
|
* Compatible replacement for PHP internal get_parent_class()
|
||||||
|
*
|
||||||
|
* Maintains compatibility with PHP 5.6 while suppressing the TypeError
|
||||||
|
* thrown by PHP 8.0 if the string provided does not resolve into an extant
|
||||||
|
* class
|
||||||
|
*
|
||||||
|
* @param string|object $object An object or a string that may be a class
|
||||||
|
* @return false|string The parent class as a string or FALSE otherwise
|
||||||
|
*/
|
||||||
|
public static function get_parent_class($object)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return \get_parent_class($object);
|
||||||
|
}
|
||||||
|
catch (\Throwable $_)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -13,6 +13,7 @@ namespace e107\Shims;
|
|||||||
|
|
||||||
trait InternalShimsTrait
|
trait InternalShimsTrait
|
||||||
{
|
{
|
||||||
|
use Internal\GetParentClassTrait;
|
||||||
use Internal\ReadfileTrait;
|
use Internal\ReadfileTrait;
|
||||||
use Internal\StrptimeTrait;
|
use Internal\StrptimeTrait;
|
||||||
}
|
}
|
@@ -3031,7 +3031,7 @@ class e107
|
|||||||
* @param boolean $merge
|
* @param boolean $merge
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getTemplateInfo($plug_name = null, $id, $key = null, $override = true, $merge = false)
|
public static function getTemplateInfo($plug_name, $id, $key = null, $override = true, $merge = false)
|
||||||
{
|
{
|
||||||
if($plug_name)
|
if($plug_name)
|
||||||
{
|
{
|
||||||
|
@@ -231,7 +231,7 @@ class e_marketplace
|
|||||||
* @param $data - e107.org plugin/theme feed data.
|
* @param $data - e107.org plugin/theme feed data.
|
||||||
* @return bool|string
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
public function getDownloadModal($type='plugin',$data)
|
public function getDownloadModal($type='plugin',$data=array())
|
||||||
{
|
{
|
||||||
|
|
||||||
$url = false;
|
$url = false;
|
||||||
|
@@ -3240,7 +3240,7 @@ var_dump($select_options);*/
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sel = is_array($selected) ? in_array($value, $selected) : ($value == $selected);
|
$sel = is_array($selected) ? in_array($value, $selected) : ($value === $selected);
|
||||||
|
|
||||||
if(!empty($options['optDisabled']) && is_array($options['optDisabled']))
|
if(!empty($options['optDisabled']) && is_array($options['optDisabled']))
|
||||||
{
|
{
|
||||||
|
@@ -2184,7 +2184,7 @@ class themeHandler
|
|||||||
mode = 1 :: selected site theme
|
mode = 1 :: selected site theme
|
||||||
mode = 2 :: selected admin theme
|
mode = 2 :: selected admin theme
|
||||||
*/
|
*/
|
||||||
function renderTheme($mode = 0, $theme)
|
function renderTheme($mode = 0, $theme = array())
|
||||||
{
|
{
|
||||||
$ns = e107::getRender();
|
$ns = e107::getRender();
|
||||||
$pref = e107::getPref();
|
$pref = e107::getPref();
|
||||||
|
@@ -1244,10 +1244,10 @@ class e_user_provider
|
|||||||
public static function getTypeOf($providerName)
|
public static function getTypeOf($providerName)
|
||||||
{
|
{
|
||||||
$class_name = "Hybridauth\Provider\\{$providerName}";
|
$class_name = "Hybridauth\Provider\\{$providerName}";
|
||||||
$parent_class = get_parent_class($class_name);
|
$parent_class = eShims::get_parent_class($class_name);
|
||||||
if (!$parent_class) return false;
|
if (!$parent_class) return false;
|
||||||
|
|
||||||
$parent_class_split = explode("\\", get_parent_class($class_name));
|
$parent_class_split = explode("\\", eShims::get_parent_class($class_name));
|
||||||
$type = end($parent_class_split);
|
$type = end($parent_class_split);
|
||||||
if ($type == "AbstractAdapter") return $providerName;
|
if ($type == "AbstractAdapter") return $providerName;
|
||||||
if (!in_array($type, ['OAuth1', 'OAuth2', 'OpenID'])) return self::getTypeOf($type);
|
if (!in_array($type, ['OAuth1', 'OAuth2', 'OpenID'])) return self::getTypeOf($type);
|
||||||
|
@@ -918,6 +918,7 @@ class user_class
|
|||||||
*/
|
*/
|
||||||
public function getName($id)
|
public function getName($id)
|
||||||
{
|
{
|
||||||
|
$id = (int) $id;
|
||||||
$cn = abs($id);
|
$cn = abs($id);
|
||||||
$ucString = 'Class:'.$id; // Debugging aid - this should be overridden
|
$ucString = 'Class:'.$id; // Debugging aid - this should be overridden
|
||||||
|
|
||||||
|
@@ -2271,7 +2271,7 @@ class e107forum
|
|||||||
* $forum_href override ONLY applies when template is missing FORUM_CRUMB
|
* $forum_href override ONLY applies when template is missing FORUM_CRUMB
|
||||||
* $thread_title is needed for post-related breadcrumbs
|
* $thread_title is needed for post-related breadcrumbs
|
||||||
*/
|
*/
|
||||||
function set_crumb($forum_href=false, $thread_title='', &$templateVar)
|
function set_crumb($forum_href=false, $thread_title='', &$templateVar=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
@@ -857,7 +857,7 @@ class siteStats
|
|||||||
if ($do_errors XOR !$found)
|
if ($do_errors XOR !$found)
|
||||||
{
|
{
|
||||||
$totalArray[$k] = $v;
|
$totalArray[$k] = $v;
|
||||||
$total += vartrue($v['ttlv']);
|
$total += (int) vartrue($v['ttlv']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$totalArray = $this -> arraySort($totalArray, "ttl");
|
$totalArray = $this -> arraySort($totalArray, "ttl");
|
||||||
@@ -2037,7 +2037,7 @@ class siteStats
|
|||||||
|
|
||||||
$text .= "
|
$text .= "
|
||||||
</td>
|
</td>
|
||||||
<td style='width:10%; text-align:right' class='forumheader3'>".number_format($val);
|
<td style='width:10%; text-align:right' class='forumheader3'>".number_format((float) $val);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
@@ -36,11 +36,11 @@ class PriorityCallbacks
|
|||||||
$this->shutdown_functions[] = $callable;
|
$this->shutdown_functions[] = $callable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function __clone() {}
|
public function __clone() {}
|
||||||
|
|
||||||
private function __sleep() {}
|
public function __sleep() {}
|
||||||
|
|
||||||
private function __wakeup() {}
|
public function __wakeup() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
PriorityCallbacks::instance();
|
PriorityCallbacks::instance();
|
@@ -660,11 +660,6 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
|||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
public function testDb_Close()
|
|
||||||
{
|
|
||||||
$this->db->db_Close();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDelete()
|
public function testDelete()
|
||||||
{
|
{
|
||||||
@@ -1147,8 +1142,6 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
|||||||
$xql->truncate($table);
|
$xql->truncate($table);
|
||||||
$empty = $xql->isEmpty($table);
|
$empty = $xql->isEmpty($table);
|
||||||
$this->assertTrue($empty,"isEmpty() or truncate() failed");
|
$this->assertTrue($empty,"isEmpty() or truncate() failed");
|
||||||
|
|
||||||
$xql->close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,14 @@ class e_db_mysqlTest extends e_db_abstractTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function _after()
|
||||||
|
{
|
||||||
|
$db_impl = $this->getDbImplementation();
|
||||||
|
if (@empty($db_impl->server_info)) return;
|
||||||
|
|
||||||
|
parent::_after();
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetPDO()
|
public function testGetPDO()
|
||||||
{
|
{
|
||||||
$result = $this->db->getPDO();
|
$result = $this->db->getPDO();
|
||||||
@@ -71,4 +79,20 @@ class e_db_mysqlTest extends e_db_abstractTest
|
|||||||
$result = $this->db->escape("Can't", true);
|
$result = $this->db->escape("Can't", true);
|
||||||
$this->assertEquals("Can\'t", $result);
|
$this->assertEquals("Can\'t", $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDb_Close()
|
||||||
|
{
|
||||||
|
$db_impl = $this->getDbImplementation();
|
||||||
|
$this->assertFalse(@empty($db_impl->server_info));
|
||||||
|
$this->db->db_Close();
|
||||||
|
$this->assertTrue(@empty($db_impl->server_info));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDbImplementation()
|
||||||
|
{
|
||||||
|
$reflection_object = new ReflectionObject($this->db);
|
||||||
|
$db_property = $reflection_object->getProperty('mySQLaccess');
|
||||||
|
$db_property->setAccessible(true);
|
||||||
|
return $db_property->getValue($this->db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -161,6 +161,7 @@ class e_formTest extends \Codeception\Test\Unit
|
|||||||
}
|
}
|
||||||
|
|
||||||
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_admin.php');
|
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_admin.php');
|
||||||
|
e107::includeLan(e_PLUGIN.'forum/languages/English/English_front.php');
|
||||||
include_once(e_CORE."templates/admin_icons_template.php");
|
include_once(e_CORE."templates/admin_icons_template.php");
|
||||||
include_once(e_PLUGIN.'forum/forum_class.php');
|
include_once(e_PLUGIN.'forum/forum_class.php');
|
||||||
include_once(e_PLUGIN.'forum/templates/forum_icons_template.php');
|
include_once(e_PLUGIN.'forum/templates/forum_icons_template.php');
|
||||||
@@ -925,7 +926,7 @@ class e_formTest extends \Codeception\Test\Unit
|
|||||||
|
|
||||||
|
|
||||||
'dropdown_001' => "<select name='dropdown_001' id='dropdown-001' class='tbox select form-control' tabindex='3'><option value='opt_value_1'>Label 1</option><option value='opt_value_2' selected='selected'>Label 2</option></select>",
|
'dropdown_001' => "<select name='dropdown_001' id='dropdown-001' class='tbox select form-control' tabindex='3'><option value='opt_value_1'>Label 1</option><option value='opt_value_2' selected='selected'>Label 2</option></select>",
|
||||||
'dropdown_002' => "<select name='dropdown_002' id='dropdown-002' class='tbox select form-control' tabindex='4'><option value='0'>Option 0</option><option value='1' selected='selected'>Option 1</option><option value='2'>Option 2</option></select>",
|
'dropdown_002' => "<select name='dropdown_002' id='dropdown-002' class='tbox select form-control' tabindex='4'><option value='0'>Option 0</option><option value='1'>Option 1</option><option value='2'>Option 2</option></select>",
|
||||||
|
|
||||||
|
|
||||||
'textarea_001' => "<textarea name='textarea_001' rows='5' cols='40' id='textarea-001' class='form-control input-xlarge' tabindex='5'>the quick brown fox jumps over the lazy dog</textarea>",
|
'textarea_001' => "<textarea name='textarea_001' rows='5' cols='40' id='textarea-001' class='form-control input-xlarge' tabindex='5'>the quick brown fox jumps over the lazy dog</textarea>",
|
||||||
|
3
user.php
3
user.php
@@ -104,7 +104,7 @@ if (isset($_POST['delp']))
|
|||||||
$qs = explode(".", e_QUERY);
|
$qs = explode(".", e_QUERY);
|
||||||
$self_page =($qs[0] == 'id' && intval($qs[1]) == USERID);
|
$self_page =($qs[0] == 'id' && intval($qs[1]) == USERID);
|
||||||
|
|
||||||
|
if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:95%"); }
|
||||||
|
|
||||||
if(THEME_LEGACY === true) // v1.x BC Fix for loading old templates.
|
if(THEME_LEGACY === true) // v1.x BC Fix for loading old templates.
|
||||||
{
|
{
|
||||||
@@ -132,7 +132,6 @@ $user_shortcodes->wrapper('user/view');
|
|||||||
|
|
||||||
$user_frm = new form;
|
$user_frm = new form;
|
||||||
require_once(HEADERF);
|
require_once(HEADERF);
|
||||||
if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:95%"); }
|
|
||||||
|
|
||||||
$full_perms = getperms("0") || check_class(varset($pref['memberlist_access'], 253)); // Controls display of info from other users
|
$full_perms = getperms("0") || check_class(varset($pref['memberlist_access'], 253)); // Controls display of info from other users
|
||||||
if (!$full_perms && !$self_page)
|
if (!$full_perms && !$self_page)
|
||||||
|
Reference in New Issue
Block a user