View Issue Details

IDProjectCategoryView StatusLast Update
0000286Adventure PHP FrameworkBugpublic2016-03-04 10:20
ReporterdarkstarAssigned ToChristianAchatz 
PriorityhighSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.1 
Target Version3.2Fixed in Version3.2 
Summary0000286: SessionSingleton cache serialization
DescriptionThe class APF\core\singleton\SessionSingleton uses the self::$CACHE array to cache its instantiated objects. SessionSingleton inherits from Session, but doesn't declare its own caching array.

The method SessionSingleton::saveObjects() iterates over all entries in self::$CACHE and tries to serialize them. Therefore: as soon as SessionSingleton is used at least once to create an instance of an object, all objects that have been instantiated by either Session or SessionSingleton will be serialized.

SessionSingleton should have its own caching array.
Steps To ReproduceThe following code will throw an exception, which should not be the case.

<?php
use APF\core\singleton\Singleton;
use APF\core\singleton\SessionSingleton;
 
$dir = dirname($_SERVER['SCRIPT_FILENAME']);
$apfClassLoaderRootPath = $dir . '/APF';
$apfClassLoaderConfigurationRootPath = $dir . '/config/APF';
include_once('./APF/core/bootstrap.php');
 
class Foo {
    public function __sleep() {
        throw new Exception();
    }
}
 
class Bar {}
 
Singleton::getInstance(Foo::class);
SessionSingleton::getInstance(Bar::class);
TagsNo tags attached.
Codereferenz: ([Datei]:[Zeile])singleton\SessionSingleton.php:137
Namespacecore

Activities

ChristianAchatz

2016-03-03 19:34

administrator   ~0000678

Hey darkstar,

thanks a lot for your bug report! There is definitely an issue with declaration of the cache container!

I´ll provide a fix for this issue by tomorrow latest.

Question: is there a need for a back port to 3.1? If yes, please let mehr know and I´ll provide a 3.1 fix pack.

darkstar

2016-03-03 20:01

reporter   ~0000679

ok, thanks! A fix in the git repo would be enough for me, I just noticed it in the 3.1 release.

ChristianAchatz

2016-03-03 22:00

administrator   ~0000680

* Cache interference between Singleton, SessionSingleton, and ApplicationSingleton resolved.
* Unit Test added.

Updated version can be downloaded under https://github.com/AdventurePHP/code/archive/master.zip or http://files.adventure-php-framework.org/snapshot/apf-3.2-snapshot-php5.tar.gz.

Issue History

Date Modified Username Field Change
2016-03-03 17:57 darkstar New Issue
2016-03-03 19:34 ChristianAchatz Note Added: 0000678
2016-03-03 20:01 darkstar Note Added: 0000679
2016-03-03 22:00 ChristianAchatz Note Added: 0000680
2016-03-03 22:00 ChristianAchatz Status new => resolved
2016-03-03 22:00 ChristianAchatz Fixed in Version => 3.2
2016-03-03 22:00 ChristianAchatz Resolution open => fixed
2016-03-03 22:00 ChristianAchatz Assigned To => ChristianAchatz
2016-03-04 10:20 ChristianAchatz Target Version => 3.2