Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

+28 -7
View File
@@ -1,6 +1,6 @@
<?php
/**
* @brief Magic Template Class for advanced theme (designers) mode
* @brief Magic Template Class for cachable templates
* @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/
@@ -43,7 +43,7 @@ class _Template extends \IPS\Theme\Template
protected static $className = NULL;
/**
* Contructor
* Constructor
*
* @param string $app Application Key
* @param string $templateLocation Template location (admin/public/etc.)
@@ -77,8 +77,14 @@ class _Template extends \IPS\Theme\Template
public function exists()
{
if ( file_exists( static::$file ) )
{
{
/* For FLOCK to work when setting, we need to flock when reading https://bugs.php.net/bug.php?id=52895 */
$f = fopen( static::$file, 'r' );
flock( $f, LOCK_SH );
include_once( static::$file );
flock( $f, LOCK_UN );
fclose( $f );
$class = "\\IPS\\Theme\\Cache\\" . \IPS\Theme::overloadHooks( static::$className, "IPS\\Theme\\Cache" );
if ( class_exists( $class ) )
@@ -110,7 +116,7 @@ class _Template extends \IPS\Theme\Template
/**
* Return the template object
*
* @throws UnderflowException if the template bit does not exist
* @throws \UnderflowException if the template bit does not exist
* @return boolean
*/
public function get()
@@ -127,7 +133,7 @@ class _Template extends \IPS\Theme\Template
* Write the template object
* @param string $template PHP $template data to write
*
* @throws RuntimeException If the template bit cannot be written
* @throws \RuntimeException If the template bit cannot be written
* @return void
*/
public function set( $template )
@@ -137,6 +143,21 @@ class _Template extends \IPS\Theme\Template
throw new \RuntimeException;
}
@file_put_contents( static::$file, "<?php\n" . $template );
}
$template = "<?php\n" . $template;
$result = (bool) @\file_put_contents( static::$file, $template, LOCK_EX );
/* Sometimes LOCK_EX is unavailable and throws file_put_contents(): Exclusive locks are not supported for this stream.
While we would prefer an exclusive lock, it would be better to write the file if possible. */
if( ! $result )
{
@unlink( static::$file );
$result = (bool) @\file_put_contents( static::$file, $template );
}
/* Clear zend opcache if enabled */
if ( function_exists( 'opcache_invalidate' ) )
{
@opcache_invalidate( static::$file );
}
}
}