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

+12 -7
View File
@@ -11,7 +11,7 @@
namespace IPS\Data\Store;
/* 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;
@@ -63,15 +63,19 @@ class _Database extends \IPS\Data\Store
/* Otherwise, we also need a few more things depending on whether the user is logged in or not */
else
{
$this->initLoad[] = 'announcements';
$this->initLoad[] = 'loginMethods'; # Previously, this was only loaded for Guests, however both Guests and Logged In members interface with login handlers (ex. profile syncing).
$this->initLoad[] = 'widgets';
$this->initLoad[] = 'defaultStreamData';
$this->initLoad[] = 'acpNotifications';
$this->initLoad[] = 'emoticons';
if ( \IPS\Session\Front::loggedIn() )
{
$this->initLoad[] = 'administrators';
$this->initLoad[] = 'moderators';
$this->initLoad[] = 'emoticons';
}
else
{
$this->initLoad[] = 'loginHandlers';
$this->initLoad[] = 'group_promotions';
$this->initLoad[] = 'promoters';
}
}
}
@@ -99,7 +103,7 @@ class _Database extends \IPS\Data\Store
*/
public function get( $key )
{
if ( !$this->doneInitLoad and in_array( $key, $this->initLoad ) )
if ( !$this->doneInitLoad and \in_array( $key, $this->initLoad ) )
{
$this->loadIntoMemory( $this->initLoad );
$this->doneInitLoad = TRUE;
@@ -185,6 +189,7 @@ class _Database extends \IPS\Data\Store
/**
* Abstract Method: Clear All Caches
*
* @param NULL|string $exclude Key to exclude (keep)
* @return void
*/
public function clearAll( $exclude=NULL )
+26
View File
@@ -0,0 +1,26 @@
<?php
/**
* @brief Abstract Storage Class
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 07 May 2013
*/
namespace IPS\Data\Store;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Cache Exception Class
*/
class _Exception extends \RuntimeException
{
}
+5 -4
View File
@@ -11,7 +11,7 @@
namespace IPS\Data\Store;
/* 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;
@@ -151,7 +151,7 @@ CONTENTS;
static::$cache[ $key ] = $value;
/* Clear zend opcache if enabled */
if ( function_exists( 'opcache_invalidate' ) )
if ( \function_exists( 'opcache_invalidate' ) )
{
@opcache_invalidate( $this->_path . '/' . $key . '.' . \IPS\SUITE_UNIQUE_KEY . '.php' );
}
@@ -205,7 +205,7 @@ CONTENTS;
}
/* Clear zend opcache if enabled */
if ( function_exists( 'opcache_invalidate' ) )
if ( \function_exists( 'opcache_invalidate' ) )
{
@opcache_invalidate( $this->_path . '/' . $key . '.' . \IPS\SUITE_UNIQUE_KEY . '.php' );
}
@@ -216,6 +216,7 @@ CONTENTS;
/**
* Abstract Method: Clear All Caches
*
* @param NULL|string $exclude Key to exclude (keep)
* @return void
*/
public function clearAll( $exclude=NULL )
@@ -239,7 +240,7 @@ CONTENTS;
/* Clear zend opcache if enabled - we call reset here since we're wiping multiple files
and since this gets called as part of a general 'rebuild everything', a reset is
probably a good idea anyway */
if ( function_exists( 'opcache_reset' ) )
if ( \function_exists( 'opcache_reset' ) )
{
@opcache_reset();
}
+56 -8
View File
@@ -11,7 +11,7 @@
namespace IPS\Data\Store;
/* 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,24 +36,48 @@ class _Redis extends \IPS\Data\Store
* Redis key
*/
protected $_redisKey;
/**
* Constructor
*
* @param array $configuration Configuration to use
* @return void
*/
public function __construct( $configuration )
{
try
{
$connection = \IPS\Redis::i()->connection('write');
if( !$connection )
{
throw new \RedisException;
}
}
catch( \RedisException $e )
{
throw new \IPS\Data\Store\Exception;
}
}
/**
* Get random string used in the keys to identify this site compared to other sites
*
* @param string $key
* @return string|FALSE Value from the _datastore; FALSE if key doesn't exist
*/
protected function _getRedisKey()
{
if ( !$this->_redisKey )
{
if ( !( $this->_redisKey = \IPS\Redis::i()->get( 'redisKey_store' ) ) )
/* Last access ensures that the data is not stale if we fail back to MySQL and then go back to Redis later */
if ( !( $this->_redisKey = \IPS\Redis::i()->get( 'redisKey_store' ) ) OR ! \IPS\Redis::i()->get( 'redisStore_lastAccess' ) )
{
$this->_redisKey = md5( mt_rand() );
\IPS\Redis::i()->setex( 'redisKey_store', 604800, $this->_redisKey );
\IPS\Redis::i()->setex( 'redisStore_lastAccess', ( 3 * 3600 ), time() );
}
}
return $this->_redisKey . '_str_';
}
@@ -62,10 +86,15 @@ class _Redis extends \IPS\Data\Store
*/
protected static $cache = array();
/**
* @brief Already updated lastAccess?
*/
protected static $updatedLastAccess = FALSE;
/**
* Abstract Method: Get
*
* @param string $key
* @param string $key Key
* @return string|FALSE Value from the _datastore; FALSE if key doesn't exist
*/
public function get( $key )
@@ -77,11 +106,18 @@ class _Redis extends \IPS\Data\Store
try
{
/* Set the last access time */
if ( static::$updatedLastAccess === FALSE )
{
\IPS\Redis::i()->setex( 'redisStore_lastAccess', ( 3 * 3600 ), time() );
static::$updatedLastAccess = TRUE;
}
$return = \IPS\Redis::i()->get( $this->_getRedisKey() . '_' . $key );
if ( $return !== FALSE )
if ( $return !== FALSE AND $decoded = \IPS\Redis::i()->decode( $return ) )
{
static::$cache[ $key ] = \IPS\Redis::i()->decode( $return );
static::$cache[ $key ] = $decoded;
return static::$cache[ $key ];
}
else
@@ -152,7 +188,8 @@ class _Redis extends \IPS\Data\Store
{
try
{
return (bool) \IPS\Redis::i()->delete( $this->_getRedisKey() . '_' . $key );
unset( static::$cache[ $key ] );
return (bool) \IPS\Redis::i()->del( $this->_getRedisKey() . '_' . $key );
}
catch( \RedisException $e )
{
@@ -179,4 +216,15 @@ class _Redis extends \IPS\Data\Store
return FALSE;
}
}
/**
* Test the datastore engine to make sure it's working
* Overloaded here to ensure that if we're using a cluster, there isn't a false error because of the delay with RW
*
* @return bool
*/
public function test()
{
return \IPS\Redis::i()->test();
}
}