mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Fix strict count() behavior in PHP 7.2
This commit is contained in:
parent
6f7f92f3e2
commit
6f35f5bafc
7 changed files with 43 additions and 16 deletions
|
|
@ -560,7 +560,7 @@ class Query extends BaseObject
|
|||
{
|
||||
if(!$this->_orderByString)
|
||||
{
|
||||
if(count($this->orderby) === 0)
|
||||
if(countobj($this->orderby) === 0)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
|
@ -587,7 +587,7 @@ class Query extends BaseObject
|
|||
function getLimitString()
|
||||
{
|
||||
$limit = '';
|
||||
if(count($this->limit) > 0)
|
||||
if(countobj($this->limit) > 0)
|
||||
{
|
||||
$limit = '';
|
||||
$limit .= $this->limit->toString();
|
||||
|
|
@ -611,7 +611,7 @@ class Query extends BaseObject
|
|||
$this->arguments = array();
|
||||
|
||||
// Join table arguments
|
||||
if(count($this->tables) > 0)
|
||||
if(countobj($this->tables) > 0)
|
||||
{
|
||||
foreach($this->tables as $table)
|
||||
{
|
||||
|
|
@ -628,7 +628,7 @@ class Query extends BaseObject
|
|||
|
||||
// Column arguments
|
||||
// The if is for delete statements, all others must have columns
|
||||
if(count($this->columns) > 0)
|
||||
if(countobj($this->columns) > 0)
|
||||
{
|
||||
foreach($this->columns as $column)
|
||||
{
|
||||
|
|
@ -644,12 +644,12 @@ class Query extends BaseObject
|
|||
}
|
||||
|
||||
// Condition arguments
|
||||
if(count($this->conditions) > 0)
|
||||
if(countobj($this->conditions) > 0)
|
||||
{
|
||||
foreach($this->conditions as $conditionGroup)
|
||||
{
|
||||
$args = $conditionGroup->getArguments();
|
||||
if(count($args) > 0)
|
||||
if(countobj($args) > 0)
|
||||
{
|
||||
$this->arguments = array_merge($this->arguments, $args);
|
||||
}
|
||||
|
|
@ -657,12 +657,12 @@ class Query extends BaseObject
|
|||
}
|
||||
|
||||
// Navigation arguments
|
||||
if(count($this->orderby) > 0)
|
||||
if(countobj($this->orderby) > 0)
|
||||
{
|
||||
foreach($this->orderby as $order)
|
||||
{
|
||||
$args = $order->getArguments();
|
||||
if(count($args) > 0)
|
||||
if(countobj($args) > 0)
|
||||
{
|
||||
$this->arguments = array_merge($this->arguments, $args);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -858,7 +858,7 @@ class ModuleHandler extends Handler
|
|||
{
|
||||
Context::set('XE_VALIDATOR_ID', $_SESSION['XE_VALIDATOR_ID']);
|
||||
}
|
||||
if(count($_SESSION['INPUT_ERROR']))
|
||||
if(countobj($_SESSION['INPUT_ERROR']))
|
||||
{
|
||||
Context::set('INPUT_ERROR', $_SESSION['INPUT_ERROR']);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ if (function_exists('mb_regex_encoding'))
|
|||
require_once __DIR__ . '/constants.php';
|
||||
require_once __DIR__ . '/functions.php';
|
||||
require_once __DIR__ . '/legacy.php';
|
||||
require_once RX_BASEDIR . 'classes/object/Object.class.php';
|
||||
|
||||
/**
|
||||
* Load user configuration.
|
||||
|
|
@ -98,8 +99,6 @@ $GLOBALS['RX_AUTOLOAD_FILE_MAP'] = array_change_key_case(array(
|
|||
'Mobile' => 'classes/mobile/Mobile.class.php',
|
||||
'ModuleHandler' => 'classes/module/ModuleHandler.class.php',
|
||||
'ModuleObject' => 'classes/module/ModuleObject.class.php',
|
||||
'BaseObject' => 'classes/object/Object.class.php',
|
||||
'Object' => 'classes/object/Object.class.php',
|
||||
'PageHandler' => 'classes/page/PageHandler.class.php',
|
||||
'EmbedFilter' => 'classes/security/EmbedFilter.class.php',
|
||||
'IpFilter' => 'classes/security/IpFilter.class.php',
|
||||
|
|
@ -193,7 +192,7 @@ spl_autoload_register(function($class_name)
|
|||
/**
|
||||
* Also include the Composer autoloader.
|
||||
*/
|
||||
require_once RX_BASEDIR . 'vendor/autoload.php';
|
||||
require_once RX_BASEDIR . 'vendor/autoload.php';
|
||||
|
||||
/**
|
||||
* Load system configuration.
|
||||
|
|
|
|||
|
|
@ -517,6 +517,28 @@ function tobool($input)
|
|||
return (bool)$input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts members of an array or an object.
|
||||
*
|
||||
* @param mixed $array_or_object
|
||||
* @return int
|
||||
*/
|
||||
function countobj($array_or_object)
|
||||
{
|
||||
if (is_array($array_or_object))
|
||||
{
|
||||
return count($array_or_object);
|
||||
}
|
||||
elseif (is_object($array_or_object))
|
||||
{
|
||||
return count(get_object_vars($array_or_object));
|
||||
}
|
||||
else
|
||||
{
|
||||
return @count($array_or_object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given string contains valid UTF-8.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -467,7 +467,7 @@ class moduleModel extends module
|
|||
|
||||
foreach($target_module_info as $key => $val)
|
||||
{
|
||||
if(!$extra_vars[$val->module_srl] || !count($extra_vars[$val->module_srl])) continue;
|
||||
if(!$extra_vars[$val->module_srl] || !count(get_object_vars($extra_vars[$val->module_srl]))) continue;
|
||||
foreach($extra_vars[$val->module_srl] as $k => $v)
|
||||
{
|
||||
if($target_module_info[$key]->{$k}) continue;
|
||||
|
|
@ -1828,10 +1828,9 @@ class moduleModel extends module
|
|||
$args = new stdClass();
|
||||
$args->module_srl = implode(',', $get_module_srls);
|
||||
$output = executeQueryArray('module.getModuleExtraVars', $args);
|
||||
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return;
|
||||
return array();
|
||||
}
|
||||
|
||||
if(!$output->data)
|
||||
|
|
|
|||
|
|
@ -707,7 +707,7 @@ class widgetController extends widget
|
|||
|
||||
$widgetstyle_extra_var = new stdClass();
|
||||
$widgetstyle_extra_var_key = get_object_vars($widgetstyle_info);
|
||||
if(count($widgetstyle_extra_var_key['extra_var']))
|
||||
if(countobj($widgetstyle_extra_var_key['extra_var']))
|
||||
{
|
||||
foreach($widgetstyle_extra_var_key['extra_var'] as $key => $val)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -149,6 +149,13 @@ class FunctionsTest extends \Codeception\TestCase\Test
|
|||
$this->assertFalse(tobool(array()));
|
||||
}
|
||||
|
||||
public function testCountObj()
|
||||
{
|
||||
$this->assertEquals(3, countobj(array('foo' => 1, 'bar' => 2, 'baz' => 3)));
|
||||
$this->assertEquals(3, countobj((object)array('foo' => 1, 'bar' => 2, 'baz' => 3)));
|
||||
$this->assertEquals(1, countobj('foobar'));
|
||||
}
|
||||
|
||||
public function testUTF8Functions()
|
||||
{
|
||||
$this->assertTrue(utf8_check('Hello, world!'));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue