mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-04 09:32:15 +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(!$this->_orderByString)
|
||||||
{
|
{
|
||||||
if(count($this->orderby) === 0)
|
if(countobj($this->orderby) === 0)
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
@ -587,7 +587,7 @@ class Query extends BaseObject
|
||||||
function getLimitString()
|
function getLimitString()
|
||||||
{
|
{
|
||||||
$limit = '';
|
$limit = '';
|
||||||
if(count($this->limit) > 0)
|
if(countobj($this->limit) > 0)
|
||||||
{
|
{
|
||||||
$limit = '';
|
$limit = '';
|
||||||
$limit .= $this->limit->toString();
|
$limit .= $this->limit->toString();
|
||||||
|
|
@ -611,7 +611,7 @@ class Query extends BaseObject
|
||||||
$this->arguments = array();
|
$this->arguments = array();
|
||||||
|
|
||||||
// Join table arguments
|
// Join table arguments
|
||||||
if(count($this->tables) > 0)
|
if(countobj($this->tables) > 0)
|
||||||
{
|
{
|
||||||
foreach($this->tables as $table)
|
foreach($this->tables as $table)
|
||||||
{
|
{
|
||||||
|
|
@ -628,7 +628,7 @@ class Query extends BaseObject
|
||||||
|
|
||||||
// Column arguments
|
// Column arguments
|
||||||
// The if is for delete statements, all others must have columns
|
// 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)
|
foreach($this->columns as $column)
|
||||||
{
|
{
|
||||||
|
|
@ -644,12 +644,12 @@ class Query extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// Condition arguments
|
// Condition arguments
|
||||||
if(count($this->conditions) > 0)
|
if(countobj($this->conditions) > 0)
|
||||||
{
|
{
|
||||||
foreach($this->conditions as $conditionGroup)
|
foreach($this->conditions as $conditionGroup)
|
||||||
{
|
{
|
||||||
$args = $conditionGroup->getArguments();
|
$args = $conditionGroup->getArguments();
|
||||||
if(count($args) > 0)
|
if(countobj($args) > 0)
|
||||||
{
|
{
|
||||||
$this->arguments = array_merge($this->arguments, $args);
|
$this->arguments = array_merge($this->arguments, $args);
|
||||||
}
|
}
|
||||||
|
|
@ -657,12 +657,12 @@ class Query extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// Navigation arguments
|
// Navigation arguments
|
||||||
if(count($this->orderby) > 0)
|
if(countobj($this->orderby) > 0)
|
||||||
{
|
{
|
||||||
foreach($this->orderby as $order)
|
foreach($this->orderby as $order)
|
||||||
{
|
{
|
||||||
$args = $order->getArguments();
|
$args = $order->getArguments();
|
||||||
if(count($args) > 0)
|
if(countobj($args) > 0)
|
||||||
{
|
{
|
||||||
$this->arguments = array_merge($this->arguments, $args);
|
$this->arguments = array_merge($this->arguments, $args);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -858,7 +858,7 @@ class ModuleHandler extends Handler
|
||||||
{
|
{
|
||||||
Context::set('XE_VALIDATOR_ID', $_SESSION['XE_VALIDATOR_ID']);
|
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']);
|
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__ . '/constants.php';
|
||||||
require_once __DIR__ . '/functions.php';
|
require_once __DIR__ . '/functions.php';
|
||||||
require_once __DIR__ . '/legacy.php';
|
require_once __DIR__ . '/legacy.php';
|
||||||
|
require_once RX_BASEDIR . 'classes/object/Object.class.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load user configuration.
|
* Load user configuration.
|
||||||
|
|
@ -98,8 +99,6 @@ $GLOBALS['RX_AUTOLOAD_FILE_MAP'] = array_change_key_case(array(
|
||||||
'Mobile' => 'classes/mobile/Mobile.class.php',
|
'Mobile' => 'classes/mobile/Mobile.class.php',
|
||||||
'ModuleHandler' => 'classes/module/ModuleHandler.class.php',
|
'ModuleHandler' => 'classes/module/ModuleHandler.class.php',
|
||||||
'ModuleObject' => 'classes/module/ModuleObject.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',
|
'PageHandler' => 'classes/page/PageHandler.class.php',
|
||||||
'EmbedFilter' => 'classes/security/EmbedFilter.class.php',
|
'EmbedFilter' => 'classes/security/EmbedFilter.class.php',
|
||||||
'IpFilter' => 'classes/security/IpFilter.class.php',
|
'IpFilter' => 'classes/security/IpFilter.class.php',
|
||||||
|
|
@ -193,7 +192,7 @@ spl_autoload_register(function($class_name)
|
||||||
/**
|
/**
|
||||||
* Also include the Composer autoloader.
|
* Also include the Composer autoloader.
|
||||||
*/
|
*/
|
||||||
require_once RX_BASEDIR . 'vendor/autoload.php';
|
require_once RX_BASEDIR . 'vendor/autoload.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load system configuration.
|
* Load system configuration.
|
||||||
|
|
|
||||||
|
|
@ -517,6 +517,28 @@ function tobool($input)
|
||||||
return (bool)$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.
|
* Checks if the given string contains valid UTF-8.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -467,7 +467,7 @@ class moduleModel extends module
|
||||||
|
|
||||||
foreach($target_module_info as $key => $val)
|
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)
|
foreach($extra_vars[$val->module_srl] as $k => $v)
|
||||||
{
|
{
|
||||||
if($target_module_info[$key]->{$k}) continue;
|
if($target_module_info[$key]->{$k}) continue;
|
||||||
|
|
@ -1828,10 +1828,9 @@ class moduleModel extends module
|
||||||
$args = new stdClass();
|
$args = new stdClass();
|
||||||
$args->module_srl = implode(',', $get_module_srls);
|
$args->module_srl = implode(',', $get_module_srls);
|
||||||
$output = executeQueryArray('module.getModuleExtraVars', $args);
|
$output = executeQueryArray('module.getModuleExtraVars', $args);
|
||||||
|
|
||||||
if(!$output->toBool())
|
if(!$output->toBool())
|
||||||
{
|
{
|
||||||
return;
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$output->data)
|
if(!$output->data)
|
||||||
|
|
|
||||||
|
|
@ -707,7 +707,7 @@ class widgetController extends widget
|
||||||
|
|
||||||
$widgetstyle_extra_var = new stdClass();
|
$widgetstyle_extra_var = new stdClass();
|
||||||
$widgetstyle_extra_var_key = get_object_vars($widgetstyle_info);
|
$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)
|
foreach($widgetstyle_extra_var_key['extra_var'] as $key => $val)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,13 @@ class FunctionsTest extends \Codeception\TestCase\Test
|
||||||
$this->assertFalse(tobool(array()));
|
$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()
|
public function testUTF8Functions()
|
||||||
{
|
{
|
||||||
$this->assertTrue(utf8_check('Hello, world!'));
|
$this->assertTrue(utf8_check('Hello, world!'));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue