Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b412389
Reworked polyfill support for Zend\Stdlib\ArrayObject
weierophinney Mar 5, 2013
1e287e0
Reworked polyfill support for Zend\Session
weierophinney Mar 5, 2013
aaedc2a
Solved failing test in ArrayObject tests
weierophinney Mar 5, 2013
1232872
Fix failing Zend\Session test under 5.3.3
weierophinney Mar 5, 2013
3bf2855
Re-added autoload.php files
weierophinney Mar 5, 2013
843ac05
Fix typo
weierophinney Mar 5, 2013
05bc3b1
Fix polyfill support issue in CSRF validator
weierophinney Mar 5, 2013
41dbee9
Typehint on AbstractContainer, but instantiate Container
weierophinney Mar 5, 2013
d1e7d9d
Renamed compat autoload files and marked as deprecated
weierophinney Mar 5, 2013
010f534
Remove class_exists check
weierophinney Mar 5, 2013
a94f497
Fake scanners out
weierophinney Mar 5, 2013
5ead25d
Class stubs to force classmap generation
weierophinney Mar 5, 2013
e206193
Allow finding class definitions following halt_compiler
weierophinney Mar 5, 2013
00ee382
Added note in README about new polyfill support
weierophinney Mar 5, 2013
2af4f12
Updated README to detail full change for polyfills
weierophinney Mar 5, 2013
ee14182
Trigger E_USER_DEPRECATED in deprecated polyfill autoload files
weierophinney Mar 5, 2013
e6724fc
Simpler polyfill support
weierophinney Mar 6, 2013
7aededd
Revert changes to ClassFileLocator
weierophinney Mar 6, 2013
5761918
Revert changes to CSRF validator
weierophinney Mar 6, 2013
ecd744f
Added "build/" to gitignore
weierophinney Mar 6, 2013
9a6cde7
Updated README
weierophinney Mar 6, 2013
eb3f0cc
Mark all polyfill bases as abstract
weierophinney Mar 6, 2013
049d94c
Don't need an additional polyfill class for Container
weierophinney Mar 6, 2013
a1adc02
Do not need 5.3.3 polyfill for SessionArrayStorage
weierophinney Mar 6, 2013
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
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
nbproject
.idea
.buildpath
.DS_Store
.idea
.project
.settings/
tmp/
.DS_Store
composer.lock
.*.sw*
.*.un~
build/
composer.lock
nbproject
tmp/
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ DD MMM YYYY

### UPDATES IN 2.1.4

Better polyfill support in `Zend\Session` and `Zend\Stdlib`. Polyfills
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't this paragraph have some kind of caption or title? If we add more to this readme, it would ease on legibility. Although I'm not entirely sure this is merely hypothetical.

Also, this is part of the changelog for 2.1.4. Shouldn't we also add it to the change log for 2.2, so that people who upgrade from minor to minor release get to see the list of changes? (I'm not sure discussing this on this PR is the right place to do so though).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This will go into CHANGELOG.md when we release 2.1.4, and that always gets merged back to develop as well.

IF we have more updates we want to call out, we can add additional subheaders; with only one, there's no need yet.

(version-specific class replacements) have caused some issues in the 2.1 series.
In particular, users who were not using Composer were unaware/uncertain about
what extra files needed to be included to load polyfills, and those users who
were generating classmaps were running into issues since the same class was
being generated twice.

New polyfill support was created which does the following:

- New, uniquely named classes were created for each polyfill base.
- A stub class file was created for each class needing polyfill support. A
conditional is present in each that uses `class_alias` to alias the appropriate
polyfill base as an import. The stub class then extends the base.
- The `compatibility/autoload.php` files in each component affected was altered
to trigger an `E_USER_DEPRECATED` error asking the user to remove the require
statement for the file.

The functionality works with both Composer and ZF2's autoloading support, using
either PSR-0 or classmaps. All typehinting is preserved.

Please see [CHANGELOG.md](CHANGELOG.md).

### SYSTEM REQUIREMENTS
Expand Down
6 changes: 1 addition & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
"psr-0": {
"Zend\\": "library/",
"ZendTest\\": "tests/"
},
"files": [
"library/Zend/Stdlib/compatibility/autoload.php",
"library/Zend/Session/compatibility/autoload.php"
]
}
},
"bin": [
"bin/classmap_generator.php"
Expand Down
26 changes: 7 additions & 19 deletions library/Zend/Session/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

namespace Zend\Session;

if (version_compare(PHP_VERSION, '5.3.4', 'lt')) {
class_alias('Zend\Session\AbstractContainer', 'Zend\Session\AbstractBaseContainer');
} else {
class_alias('Zend\Session\Container\PhpReferenceCompatibility', 'Zend\Session\AbstractBaseContainer');
}

/**
* Session storage container
*
Expand All @@ -17,24 +23,6 @@
* Additionally, expiries may be absolute TTLs or measured in "hops", which
* are based on how many times the key or container were accessed.
*/
class Container extends AbstractContainer
class Container extends AbstractBaseContainer
{
/**
* Retrieve a specific key in the container
*
* @param string $key
* @return mixed
*/
public function &offsetGet($key)
{
$ret = null;
if (!$this->offsetExists($key)) {
return $ret;
}
$storage = $this->getStorage();
$name = $this->getName();
$ret =& $storage[$name][$key];

return $ret;
}
}
37 changes: 37 additions & 0 deletions library/Zend/Session/Container/PhpReferenceCompatibility.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Session\Container;

use Zend\Session\AbstractContainer;

/**
* Session storage container for PHP 5.3.4 and above.
*/
abstract class PhpReferenceCompatibility extends AbstractContainer
{
/**
* Retrieve a specific key in the container
*
* @param string $key
* @return mixed
*/
public function &offsetGet($key)
{
$ret = null;
if (!$this->offsetExists($key)) {
return $ret;
}
$storage = $this->getStorage();
$name = $this->getName();
$ret =& $storage[$name][$key];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Indentation

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

What's the change needed? (This is the original formatting from @mwillbanks -- just moved to a new file.)


return $ret;
}
}
29 changes: 7 additions & 22 deletions library/Zend/Session/Storage/SessionArrayStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,15 @@

namespace Zend\Session\Storage;

if (version_compare(PHP_VERSION, '5.3.4', 'lt')) {
class_alias('Zend\Session\Storage\AbstractSessionArrayStorage', 'Zend\Session\Storage\AbstractBaseSessionArrayStorage');
} else {
class_alias('Zend\Session\Storage\SessionArrayStorage\PhpReferenceCompatibility', 'Zend\Session\Storage\AbstractBaseSessionArrayStorage');
}

/**
* Session storage in $_SESSION
*/
class SessionArrayStorage extends AbstractSessionArrayStorage
class SessionArrayStorage extends AbstractBaseSessionArrayStorage
{
/**
* Get Offset
*
* @param mixed $key
* @return mixed
*/
public function &__get($key)
{
return $_SESSION[$key];
}

/**
* Offset Get
*
* @param mixed $key
* @return mixed
*/
public function &offsetGet($key)
{
return $_SESSION[$key];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Session\Storage\SessionArrayStorage;

use Zend\Session\Storage\AbstractSessionArrayStorage;

/**
* PHP 5.3.4 and greater variant of SessionArrayStorage
*/
abstract class PhpReferenceCompatibility extends AbstractSessionArrayStorage
{
/**
* Get Offset
*
* @param mixed $key
* @return mixed
*/
public function &__get($key)
{
return $_SESSION[$key];
}

/**
* Offset Get
*
* @param mixed $key
* @return mixed
*/
public function &offsetGet($key)
{
return $_SESSION[$key];
}
}
17 changes: 0 additions & 17 deletions library/Zend/Session/compatibility/Container.php

This file was deleted.

17 changes: 0 additions & 17 deletions library/Zend/Session/compatibility/Storage/SessionArrayStorage.php

This file was deleted.

21 changes: 12 additions & 9 deletions library/Zend/Session/compatibility/autoload.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php
if (version_compare(PHP_VERSION, '5.3.4', 'lt')) {
if (!class_exists('Zend\Stdlib\ArrayObject', false)
&& file_exists(__DIR__ . '/../../Stdlib/compatibility/autoload.php')
) {
require __DIR__ . '/../../Stdlib/compatibility/autoload.php';
}
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @deprecated
*/

require_once __DIR__ . '/Container.php';
require_once __DIR__ . '/Storage/SessionArrayStorage.php';
}
/**
* Legacy purposes only, to prevent code that references it from breaking.
*/
trigger_error('Polyfill autoload support (file library/Zend/Session/compatibility/autoload.php) is no longer necessary; please remove your require statement referencing this file', E_USER_DEPRECATED);
5 changes: 1 addition & 4 deletions library/Zend/Session/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
"autoload": {
"psr-0": {
"Zend\\Session\\": ""
},
"files": [
"Zend/Session/compatibility/autoload.php"
]
}
},
"target-dir": "Zend/Session",
"require": {
Expand Down
Loading