mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2026-04-23 15:16:18 +05:30
ensure PHP opcache gets invalidated, when storing data in file parsed via PHP require
This commit is contained in:
parent
9b7daf5d0a
commit
6054e99849
3 changed files with 7 additions and 10 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
* FIXED: Allow pasting a password for decrypting a paste (#1620)
|
* FIXED: Allow pasting a password for decrypting a paste (#1620)
|
||||||
* FIXED: Allow copying the shortened link after using a URL shortener (#1624)
|
* FIXED: Allow copying the shortened link after using a URL shortener (#1624)
|
||||||
* FIXED: URL extraction fails when frame-ancestors is set in CSP (#1644)
|
* FIXED: URL extraction fails when frame-ancestors is set in CSP (#1644)
|
||||||
|
* FIXED: traffic limiter not working when using Filesystem storage and PHP opcache
|
||||||
|
|
||||||
## 2.0.0 (2025-07-28)
|
## 2.0.0 (2025-07-28)
|
||||||
* ADDED: Error logging in database and filesystem backend (#1554)
|
* ADDED: Error logging in database and filesystem backend (#1554)
|
||||||
|
|
|
||||||
|
|
@ -269,6 +269,7 @@ class Filesystem extends AbstractData
|
||||||
{
|
{
|
||||||
switch ($namespace) {
|
switch ($namespace) {
|
||||||
case 'purge_limiter':
|
case 'purge_limiter':
|
||||||
|
opcache_invalidate($this->_path . DIRECTORY_SEPARATOR . 'purge_limiter.php');
|
||||||
return $this->_storeString(
|
return $this->_storeString(
|
||||||
$this->_path . DIRECTORY_SEPARATOR . 'purge_limiter.php',
|
$this->_path . DIRECTORY_SEPARATOR . 'purge_limiter.php',
|
||||||
'<?php' . PHP_EOL . '$GLOBALS[\'purge_limiter\'] = ' . var_export($value, true) . ';'
|
'<?php' . PHP_EOL . '$GLOBALS[\'purge_limiter\'] = ' . var_export($value, true) . ';'
|
||||||
|
|
@ -280,6 +281,7 @@ class Filesystem extends AbstractData
|
||||||
);
|
);
|
||||||
case 'traffic_limiter':
|
case 'traffic_limiter':
|
||||||
$this->_last_cache[$key] = $value;
|
$this->_last_cache[$key] = $value;
|
||||||
|
opcache_invalidate($this->_path . DIRECTORY_SEPARATOR . 'traffic_limiter.php');
|
||||||
return $this->_storeString(
|
return $this->_storeString(
|
||||||
$this->_path . DIRECTORY_SEPARATOR . 'traffic_limiter.php',
|
$this->_path . DIRECTORY_SEPARATOR . 'traffic_limiter.php',
|
||||||
'<?php' . PHP_EOL . '$GLOBALS[\'traffic_limiter\'] = ' . var_export($this->_last_cache, true) . ';'
|
'<?php' . PHP_EOL . '$GLOBALS[\'traffic_limiter\'] = ' . var_export($this->_last_cache, true) . ';'
|
||||||
|
|
|
||||||
|
|
@ -204,16 +204,10 @@ class TrafficLimiter extends AbstractPersistence
|
||||||
$now = time();
|
$now = time();
|
||||||
$tl = (int) self::$_store->getValue('traffic_limiter', $hash);
|
$tl = (int) self::$_store->getValue('traffic_limiter', $hash);
|
||||||
self::$_store->purgeValues('traffic_limiter', $now - self::$_limit);
|
self::$_store->purgeValues('traffic_limiter', $now - self::$_limit);
|
||||||
if ($tl > 0 && ($tl + self::$_limit >= $now)) {
|
if ($tl === 0 || ($tl + self::$_limit) < $now) {
|
||||||
$result = false;
|
if (!self::$_store->setValue((string) $now, 'traffic_limiter', $hash)) {
|
||||||
} else {
|
error_log('failed to store the traffic limiter, it probably contains outdated information');
|
||||||
$tl = time();
|
}
|
||||||
$result = true;
|
|
||||||
}
|
|
||||||
if (!self::$_store->setValue((string) $tl, 'traffic_limiter', $hash)) {
|
|
||||||
error_log('failed to store the traffic limiter, it probably contains outdated information');
|
|
||||||
}
|
|
||||||
if ($result) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
throw new Exception(I18n::_(
|
throw new Exception(I18n::_(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue