Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] v1.0.0 / v0.14.0 #253

Merged
merged 106 commits into from
Feb 1, 2016
Merged
Show file tree
Hide file tree
Changes from 93 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
8104fdd
getExpiration returns CurrentTime for empty record
tedivm Aug 3, 2015
3b169d1
Created stand alone "save" function that uses the data and ttl proper…
tedivm Aug 3, 2015
d7be6c8
Formatting
tedivm Aug 3, 2015
fc59507
Decoupled "set" function from persisting values
tedivm Aug 3, 2015
94735f2
Removed expiration time for `set` function
tedivm Aug 3, 2015
1c7f102
Split invalidation method from get function.
tedivm Aug 3, 2015
6a8f49e
Fixed formatting
tedivm Aug 3, 2015
56633a3
Fixed more "save" related changes
tedivm Aug 3, 2015
719d597
Typo/syntax error
tedivm Aug 3, 2015
de27992
Added save function to ItemInterface
tedivm Aug 3, 2015
2c5b04e
Changed `getItemIterator` to `getItems`
tedivm Aug 3, 2015
7c573de
Added commit, saveDeferred, save, and deleteItems to the Pool Interface
tedivm Aug 3, 2015
10b18d8
Fixed formatting
tedivm Aug 3, 2015
1ec6126
Merge branch 'master' into psr6
tedivm Aug 9, 2015
84e2638
Extend from RuntimeException
tedivm Aug 9, 2015
5f50f70
Stopped "collecting" deleted items
tedivm Aug 9, 2015
cbf4723
Added isHit function
tedivm Aug 9, 2015
3087701
Added "exists" function
tedivm Aug 9, 2015
44fd506
Made expiresAt throw InvalidArgumentException on non-datetime arguments
tedivm Aug 9, 2015
ee777fa
Formatting
tedivm Aug 9, 2015
072bae1
Added PSR-6 additions to changelog
tedivm Aug 9, 2015
f8f7e5a
Rejiggered the exists function
tedivm Aug 9, 2015
5d24d2b
Documented Interfaces
tedivm Aug 9, 2015
ad8bf39
Added DateTime php5.4 compatibility fix
tedivm Aug 9, 2015
e95926f
Fixed formatting and exists signature
tedivm Aug 9, 2015
373420f
Removed unused method "setDriver"
tedivm Aug 9, 2015
0ccae48
Added additional expiration tests
tedivm Aug 9, 2015
b35808a
formatting
tedivm Aug 9, 2015
3aef95a
Switched datetime test for compatibility with <php5.5
tedivm Aug 9, 2015
d912ae0
Changed exception test to handle php7 TypeError
tedivm Aug 9, 2015
94ee353
Formatting
tedivm Aug 9, 2015
6268499
Added php5.4 datetime compatibility
tedivm Aug 9, 2015
0471deb
Removed dead code path
tedivm Aug 9, 2015
e901c39
Added additional testing of the pool class.
tedivm Aug 9, 2015
ca7ee3f
Merge pull request #252 from tedious/psr6
tedivm Aug 9, 2015
1f410e3
Removed SQLite2
tedivm Aug 9, 2015
711f5d9
Fixed SqlitePDO class
tedivm Aug 9, 2015
3a63888
Updated changelog- removed sqlite3
tedivm Aug 9, 2015
975fbae
Merge pull request #255 from tedious/sqlite_upgrades
tedivm Aug 9, 2015
58e716f
Install apcu-beta for apc testing
tedivm Aug 9, 2015
3a2bd4d
Fixed comparison format
tedivm Aug 9, 2015
dacc1b9
Replaced check for apc extension with check for apc_fetch function
tedivm Aug 9, 2015
1de9efa
Removed pac extension as the pecl command adds it to php.ini
tedivm Aug 9, 2015
f03ec63
Manually adding apache extension to php.ini
tedivm Aug 9, 2015
4687cb6
Added apc.so back to php5.4 build
tedivm Aug 9, 2015
140f841
Another attempt to make travis use the apcu and apc extensions
tedivm Aug 9, 2015
d8d2867
Removed useless addition of apcu extension
tedivm Aug 9, 2015
e9131f6
Split travis-ci php config by version
tedivm Aug 9, 2015
57b14eb
Added "isPersistent" test
tedivm Aug 9, 2015
5ae98e8
Merge pull request #256 from tedious/apc_travis
tedivm Aug 9, 2015
a5a8a20
Testing changes to apcu extension for travis ci
tedivm Aug 9, 2015
cfa2b05
Removed apache extension (again), since pecl also adds it
tedivm Aug 9, 2015
cac1f2d
Upgraded phpunit to 4.8
tedivm Aug 9, 2015
4967814
Test Redit Socket
tedivm Aug 9, 2015
e1bfa34
fixed syntax, yelled at editor
tedivm Aug 9, 2015
d266c03
Changed redis socket permissions
tedivm Aug 9, 2015
26b9bb8
Added check for throwable in test suite - php7 compatibility
tedivm Aug 9, 2015
9dc90ad
Formatting
tedivm Aug 9, 2015
a1ae6c9
Test invalid encoder
tedivm Aug 9, 2015
3694988
Improved Filesystem Encoder testing.
tedivm Aug 10, 2015
d927983
Additional Utilities class testing
tedivm Aug 10, 2015
bce7ac9
Tightened up code paths
tedivm Aug 10, 2015
fff6b59
Tested driver filtering
tedivm Aug 10, 2015
d56e636
Test UnavailableDriver exception in AbstractDriver
tedivm Aug 10, 2015
768d30a
Improved composite driver testing.
tedivm Aug 10, 2015
0b85b73
Formatting
tedivm Aug 10, 2015
29262c3
Removed dead code
tedivm Aug 10, 2015
bd717b5
Introduced numeric encoding return to streamline filesystem driver
tedivm Aug 10, 2015
2c103fd
Preset the expiration variable
tedivm Aug 10, 2015
5244e31
Set SQLite driver to throw errors on failed driver creation
tedivm Aug 10, 2015
6e0dda6
Improved testing of invalid memcache options
tedivm Aug 10, 2015
1cc6313
Added "use" statement for Memcache driver
tedivm Aug 10, 2015
292f78d
Fixed option name
tedivm Aug 10, 2015
503a3a5
Merge pull request #257 from tedious/testing
tedivm Aug 10, 2015
1d615c9
Removed deprecated constants
tedivm Aug 10, 2015
4e17819
Removed deprecated DriverList::getDrivers function.
tedivm Aug 10, 2015
284e8a3
Merge pull request #258 from tedious/deprecation
tedivm Aug 10, 2015
04441c4
Added deprecation notices to changelog
tedivm Aug 11, 2015
d4b0d3c
Merge branch 'master' into v1.0.0-dev
tedivm Oct 18, 2015
18f1912
Brought Stash up to date with the latest PSR-6 draft
tedivm Oct 18, 2015
44400d7
Merge pull request #264 from tedious/psr6-update
tedivm Oct 18, 2015
9e98a36
Fixed documentation and signatures
tedivm Oct 18, 2015
07a6a82
Fixed signature.
tedivm Oct 18, 2015
ad873c2
simplified options check
tedivm Oct 18, 2015
a4e8306
Merge branch 'master' into v1.0.0-dev
tedivm Oct 18, 2015
080bdf0
Merge branch 'master' into v1.0.0-dev
tedivm Oct 18, 2015
bedb7d1
Merge branch 'master' into v1.0.0-dev
tedivm Dec 8, 2015
5ebe4bc
Updated with PSR-6 changes
tedivm Dec 8, 2015
874a8e4
Added pecl support for php7 testing
tedivm Dec 8, 2015
05586c6
Lock apache version for php < 7
tedivm Dec 8, 2015
5b59455
Removed "beta" preference for apcu
tedivm Dec 8, 2015
555b410
Removed "beta" label from apcu install
tedivm Dec 8, 2015
8935d3f
Merge branch 'testing_php7' into v1.0.0-dev
tedivm Dec 8, 2015
40ee61f
Removed legacy key styles (array, arbitrary arguments)
tedivm Dec 14, 2015
6b8c33d
Implimented from PSR-6 interfaces
tedivm Dec 14, 2015
00bcc6b
Added APCU support.
tedivm Dec 14, 2015
0976fab
Fixed iterator class
tedivm Dec 14, 2015
1a9c755
Removed `Driver::setOptions($options)` in favor of `Driver::construct…
tedivm Dec 14, 2015
238658d
Removed more setOptions calls
tedivm Dec 14, 2015
6a51789
fix issue with different constructor for APCu
limenet Dec 14, 2015
616b48c
Merge pull request #276 from limenet/v1.0.0-dev
tedivm Dec 14, 2015
1a4d650
Add apcu extension to testing ini files
tedivm Dec 15, 2015
209c213
Fixed apcu function parameters
tedivm Dec 15, 2015
5b4ecaa
Removed sqlite2 support
tedivm Dec 16, 2015
6415e06
Moved filesystem checks to parent driver
tedivm Dec 16, 2015
b10e2f5
Merge branch 'master' into v1.0.0-dev, resolving conflicts
tedivm Feb 1, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ services:

matrix:
fast_finish: true
allow_failures:
- php: 7.0
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
## Stash v1.0.0 Changelog

### v1.0.0

* Removed deprecated DriverList::getDrivers function.

* Removed deprecated invalidation constants in the Item class.

* Removed SQLite Extension support (SQLite3 is still available).

* The `set` function no longer persists data.

* Removed expiration time for `set` function

* Added `expiresAt` and `expiresAfter` functions to the Item class.

* `getExpiration` to return current datetime when no record exists.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sound strange, I wouldn't expect a unset expiry to mean it has expired (now). As this is currently not part of the PSR interface, maybe rather return null if none is set.
Otherwise expiry should probably have been on the pool->save( $item, $ttl ) method

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a problem making this return null- it originally returned false, but when getExpiration was added to the PSR they had their version return the current datetime. Now that it's been removed from the standard we can handle it however we want, so I'll put it back to null.


* Added `save` function to PoolInterface.

* Changed `getItemIterator` to `getItems`

* RuntimeException now extends from \RuntimeException

* Added `isHit` function to ItemInterface.

* Added the `hasItem` function to the Pool, which should mostly be avoided.

* Renamed `Pool::purge` to `Pool::clear`.

* Added `Pool::deleteItem` and `Pool::deleteItems`.



## Stash v0.13 Changelog


Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"sessions",
"memcached",
"redis",
"apc"
"apc",
"psr-6",
"psr6"
],
"homepage": "http://github.com/tedious/Stash",
"type": "library",
Expand All @@ -27,7 +29,7 @@
},
"require-dev": {
"fabpot/php-cs-fixer": "^1.9",
"phpunit/phpunit": "4.7.*",
"phpunit/phpunit": "4.8.*",
"satooshi/php-coveralls": "dev-master"
},
"autoload": {
Expand Down
4 changes: 3 additions & 1 deletion src/Stash/Driver/AbstractDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public function __construct(array $options = array())
throw new RuntimeException(get_class($this) . ' is not available.');
}

$this->setOptions($options);
if (!empty($options)) {
$this->setOptions($options);
}
}

/**
Expand Down
12 changes: 10 additions & 2 deletions src/Stash/Driver/Apc.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ public static function isAvailable()
return false;
}

return (extension_loaded('apc') && ini_get('apc.enabled'))
&& ((php_sapi_name() !== 'cli') || ini_get('apc.enable_cli'));
return function_exists('apc_fetch');
}

/**
Expand Down Expand Up @@ -187,4 +186,13 @@ protected function getCacheTime($expiration)

return $this->ttl < $life ? $this->ttl : $life;
}


/**
* {@inheritdoc}
*/
public function isPersistent()
{
return true;
}
}
29 changes: 16 additions & 13 deletions src/Stash/Driver/Composite.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Stash;
use Stash\Exception\RuntimeException;
use Stash\Exception\InvalidArgumentException;
use Stash\Interfaces\DriverInterface;

/**
Expand Down Expand Up @@ -43,22 +44,24 @@ public function setOptions(array $options = array())
{
$options += $this->getDefaultOptions();

if (isset($options['drivers'])) {
if (count($options['drivers']) < 1) {
throw new RuntimeException('One or more secondary drivers are required.');
}
$this->drivers = array();
if (!isset($options['drivers']) || (count($options['drivers']) < 1)) {
throw new RuntimeException('One or more secondary drivers are required.');
}

foreach ($options['drivers'] as $driver) {
if (!(is_object($driver) && $driver instanceof DriverInterface)) {
continue;
}
$this->drivers[] = $driver;
}
if (!is_array($options['drivers'])) {
throw new InvalidArgumentException('Drivers option requires an array.');
}

if (count($this->drivers) < 1) {
throw new RuntimeException('None of the secondary drivers can be enabled.');
$this->drivers = array();
foreach ($options['drivers'] as $driver) {
if (!(is_object($driver) && $driver instanceof DriverInterface)) {
continue;
}
$this->drivers[] = $driver;
}

if (count($this->drivers) < 1) {
throw new RuntimeException('None of the secondary drivers can be enabled.');
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/Stash/Driver/FileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ public function setOptions(array $options = array())
}
$this->encoder = new $encoder;
} else {
$encoderInterface = 'Stash\Driver\FileSystem\EncoderInterface';
$encoderClass = 'Stash\Driver\FileSystem\\' . $encoder . 'Encoder';
if (class_exists($encoder)) {
if (class_exists($encoder) && in_array($encoderInterface, class_implements($encoder))) {
$this->encoder = new $encoder();
} elseif (class_exists($encoderClass)) {
} elseif (class_exists($encoderClass) && in_array($encoderInterface, class_implements($encoderClass))) {
$this->encoder = new $encoderClass();
} else {
throw new RuntimeException('Invalid Encoder: ' . $encoder);
Expand Down
23 changes: 8 additions & 15 deletions src/Stash/Driver/FileSystem/NativeEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ public function deserialize($path)
return false;
}

$expiration = null;
include($path);

if (!isset($loaded)) {
return false;
}

if (!isset($expiration)) {
$expiration = null;
}

if (!isset($data)) {
$data = null;
}
Expand Down Expand Up @@ -92,22 +89,18 @@ protected function encode($data)
$dataString = (bool) $data ? 'true' : 'false';
break;

case 'serialize':
$dataString = 'unserialize(base64_decode(\'' . base64_encode(serialize($data)) . '\'))';
break;

case 'string':
$dataString = sprintf('"%s"', addcslashes($data, "\t\"\$\\"));
break;

case 'none':
default :
if (is_numeric($data)) {
$dataString = (string) $data;
} else {
$dataString = 'base64_decode(\'' . base64_encode($data) . '\')';
}
case 'numeric':
$dataString = (string) $data;
break;

default :
case 'serialize':
$dataString = 'unserialize(base64_decode(\'' . base64_encode(serialize($data)) . '\'))';
break;
}

return $dataString;
Expand Down
7 changes: 1 addition & 6 deletions src/Stash/Driver/Sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,12 @@ public function setOptions(array $options = array())
if (Sub\SqlitePdo::isAvailable()) {
$subdrivers['pdo'] = '\Stash\Driver\Sub\SqlitePdo';
}
if (Sub\Sqlite::isAvailable()) {
$subdrivers['sqlite'] = '\Stash\Driver\Sub\Sqlite';
}
if (Sub\SqlitePdo2::isAvailable()) {
$subdrivers['pdo2'] = '\Stash\Driver\Sub\SqlitePdo2';
}

if ($extension == 'pdo' && $version != '2' && isset($subdrivers['pdo'])) {
$driver = $subdrivers['pdo'];
} elseif ($extension == 'sqlite' && isset($subdrivers['sqlite'])) {
$driver = $subdrivers['sqlite'];
} elseif ($extension == 'pdo' && $version != '3' && isset($subdrivers['pdo2'])) {
$driver = $subdrivers['pdo2'];
} elseif (count($subdrivers) > 0 && $extension == 'any') {
Expand Down Expand Up @@ -281,7 +276,7 @@ protected function checkStatus()
*/
public static function isAvailable()
{
return (Sub\SqlitePdo::isAvailable()) || (Sub\Sqlite::isAvailable()) || (Sub\SqlitePdo2::isAvailable());
return (Sub\SqlitePdo::isAvailable()) || (Sub\SqlitePdo2::isAvailable());
}

/**
Expand Down
Loading