Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+46 -9
View File
@@ -11,7 +11,7 @@
namespace IPS\Data;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -36,8 +36,25 @@ abstract class _Store extends AbstractData
{
if( static::$instance === NULL )
{
$classname = 'IPS\Data\Store\\' . \IPS\STORE_METHOD;
static::$instance = new $classname( json_decode( \IPS\STORE_CONFIG, TRUE ) );
try
{
$classname = 'IPS\Data\Store\\' . \IPS\STORE_METHOD;
static::$instance = new $classname( json_decode( \IPS\STORE_CONFIG, TRUE ) );
}
catch( \IPS\Data\Store\Exception $e )
{
/* Fall back to MySQL (if not using it currently, and then FileSystem if we are) */
if ( \IPS\STORE_METHOD !== 'Database' )
{
$classname = 'IPS\Data\Store\Database';
}
else
{
$classname = 'IPS\Data\Store\FileSystem';
}
static::$instance = new $classname( json_decode( \IPS\STORE_CONFIG, TRUE ) );
}
}
return static::$instance;
@@ -58,6 +75,26 @@ abstract class _Store extends AbstractData
*/
public $log = array();
/**
* Test to see if this store works
*
* @return boolean
*/
public static function testStore()
{
try
{
$classname = 'IPS\Data\Store\\' . \IPS\STORE_METHOD;
$store = new $classname( json_decode( \IPS\STORE_CONFIG, TRUE ) );
return $store->test();
}
catch( \Exception $e )
{
return FALSE;
}
}
/**
* Load mutiple
* Used so if it is known that several are going to be needed, they can all be loaded into memory at the same time
@@ -125,7 +162,7 @@ abstract class _Store extends AbstractData
else
{
/* It exists in the caching engine, and we know the hash of the correct value... */
$cacheKeys = ( isset( $this->cacheKeys ) and is_array( $this->cacheKeys ) ) ? $this->cacheKeys : array();
$cacheKeys = ( isset( $this->cacheKeys ) and \is_array( $this->cacheKeys ) ) ? $this->cacheKeys : array();
if ( array_key_exists( $key, $cacheKeys ) and isset( \IPS\Data\Cache::i()->$key ) )
{
/* Get it... */
@@ -159,7 +196,7 @@ abstract class _Store extends AbstractData
if ( \IPS\Data\Cache::i()->checkKeys() === true )
{
/* And set the hash in the cacheKeys hash map */
$cacheKeys = ( isset( $this->cacheKeys ) and is_array( $this->cacheKeys ) ) ? $this->cacheKeys : array();
$cacheKeys = ( isset( $this->cacheKeys ) and \is_array( $this->cacheKeys ) ) ? $this->cacheKeys : array();
$cacheKeys[ $key ] = md5( json_encode( $value ) );
$this->cacheKeys = $cacheKeys;
}
@@ -190,9 +227,9 @@ abstract class _Store extends AbstractData
/* And set the hash in the cacheKeys hash map */
if ( \IPS\Data\Cache::i()->checkKeys() === true )
{
if ( ( isset( $this->cacheKeys ) and is_array( $this->cacheKeys ) ) )
if ( ( isset( $this->cacheKeys ) and \is_array( $this->cacheKeys ) ) )
{
$cacheKeys = is_array( $this->cacheKeys ) ? $this->cacheKeys : array();
$cacheKeys = \is_array( $this->cacheKeys ) ? $this->cacheKeys : array();
$cacheKeys[ $key ] = md5( json_encode( $value ) );
$this->cacheKeys = $cacheKeys;
}
@@ -228,7 +265,7 @@ abstract class _Store extends AbstractData
}
/* Only use it if the hash matches */
$cacheKeys = ( isset( $this->cacheKeys ) and is_array( $this->cacheKeys ) ) ? $this->cacheKeys : array();
$cacheKeys = ( isset( $this->cacheKeys ) and \is_array( $this->cacheKeys ) ) ? $this->cacheKeys : array();
if ( isset( $cacheKeys[ $key ] ) and $cacheKeys[ $key ] == md5( json_encode( $value ) ) )
{
return TRUE;
@@ -262,7 +299,7 @@ abstract class _Store extends AbstractData
/* And from the special map of hashes */
try
{
$cacheKeys = is_array( $this->cacheKeys ) ? $this->cacheKeys : array();
$cacheKeys = \is_array( $this->cacheKeys ) ? $this->cacheKeys : array();
}
/* If the cache doesn't exist we shouldn't error out with an uncaught OutOfRangeException */
catch( \OutOfRangeException $e )