Skip to content

Commit

Permalink
Fix APC for when internal key name is entry_name (#10600)
Browse files Browse the repository at this point in the history
* Fix APC for when internal key name is entry_name

// Some APC modules changed the internal key name from key to entry_name, HHMV is one such case

* Fix comment typo

* Fix APCu for when internal key name is entry_name

Some APCu modules may have changed the internal key name from `key` or `info` to `entry_name`
  • Loading branch information
photodude authored and roland-d committed Jul 16, 2016
1 parent bb28dc9 commit 7756c18
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 12 deletions.
52 changes: 46 additions & 6 deletions libraries/joomla/cache/storage/apc.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,22 @@ public function getAll()

foreach ($keys as $key)
{
// If APCu is being used for this adapter, the internal key name changed with APCu 4.0.7 from key to info
$name = isset($key['info']) ? $key['info'] : $key['key'];
if (isset($key['info']))
{
// If APCu is being used for this adapter, the internal key name changed with APCu 4.0.7 from key to info
$name = $key['info'];
}
elseif (isset($key['entry_name']))
{
// Some APC modules changed the internal key name from key to entry_name, HHVM is one such case
$name = $key['entry_name'];
}
else
{
// A fall back for the old internal key name
$name = $key['key'];
}

$namearr = explode('-', $name);

if ($namearr !== false && $namearr[0] == $secret && $namearr[1] == 'cache')
Expand Down Expand Up @@ -128,8 +142,21 @@ public function clean($group, $mode = null)

foreach ($keys as $key)
{
// If APCu is being used for this adapter, the internal key name changed with APCu 4.0.7 from key to info
$internalKey = isset($key['info']) ? $key['info'] : $key['key'];
if (isset($key['info']))
{
// If APCu is being used for this adapter, the internal key name changed with APCu 4.0.7 from key to info
$internalKey = $key['info'];
}
elseif (isset($key['entry_name']))
{
// Some APC modules changed the internal key name from key to entry_name, HHVM is one such case
$internalKey = $key['entry_name'];
}
else
{
// A fall back for the old internal key name
$internalKey = $key['key'];
}

if (strpos($internalKey, $secret . '-cache-' . $group . '-') === 0 xor $mode != 'group')
{
Expand All @@ -155,8 +182,21 @@ public function gc()

foreach ($keys as $key)
{
// If APCu is being used for this adapter, the internal key name changed with APCu 4.0.7 from key to info
$internalKey = isset($key['info']) ? $key['info'] : $key['key'];
if (isset($key['info']))
{
// If APCu is being used for this adapter, the internal key name changed with APCu 4.0.7 from key to info
$internalKey = $key['info'];
}
elseif (isset($key['entry_name']))
{
// Some APC modules changed the internal key name from key to entry_name, HHVM is one such case
$internalKey = $key['entry_name'];
}
else
{
// A fall back for the old internal key name
$internalKey = $key['key'];
}

if (strpos($internalKey, $secret . '-cache-'))
{
Expand Down
52 changes: 46 additions & 6 deletions libraries/joomla/cache/storage/apcu.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,22 @@ public function getAll()

foreach ($keys as $key)
{
// The internal key name changed with APCu 4.0.7 from key to info
$name = isset($key['info']) ? $key['info'] : $key['key'];
if (isset($key['info']))
{
// The internal key name changed with APCu 4.0.7 from key to info
$name = $key['info'];
}
elseif (isset($key['entry_name']))
{
// Some APCu modules changed the internal key name from key to entry_name
$name = $key['entry_name'];
}
else
{
// A fall back for the old internal key name
$name = $key['key'];
}

$namearr = explode('-', $name);

if ($namearr !== false && $namearr[0] == $secret && $namearr[1] == 'cache')
Expand Down Expand Up @@ -136,8 +150,21 @@ public function clean($group, $mode = null)

foreach ($keys as $key)
{
// The internal key name changed with APCu 4.0.7 from key to info
$internalKey = isset($key['info']) ? $key['info'] : $key['key'];
if (isset($key['info']))
{
// The internal key name changed with APCu 4.0.7 from key to info
$internalKey = $key['info'];
}
elseif (isset($key['entry_name']))
{
// Some APCu modules changed the internal key name from key to entry_name
$internalKey = $key['entry_name'];
}
else
{
// A fall back for the old internal key name
$internalKey = $key['key'];
}

if (strpos($internalKey, $secret . '-cache-' . $group . '-') === 0 xor $mode != 'group')
{
Expand All @@ -163,8 +190,21 @@ public function gc()

foreach ($keys as $key)
{
// The internal key name changed with APCu 4.0.7 from key to info
$internalKey = isset($key['info']) ? $key['info'] : $key['key'];
if (isset($key['info']))
{
// The internal key name changed with APCu 4.0.7 from key to info
$internalKey = $key['info'];
}
elseif (isset($key['entry_name']))
{
// Some APCu modules changed the internal key name from key to entry_name
$internalKey = $key['entry_name'];
}
else
{
// A fall back for the old internal key name
$internalKey = $key['key'];
}

if (strpos($internalKey, $secret . '-cache-'))
{
Expand Down

0 comments on commit 7756c18

Please sign in to comment.