Permalink
Browse files

Updated for latest master

  • Loading branch information...
bakura10 committed Aug 29, 2012
2 parents 25b521a + de807ff commit 7e985d7655741a9051b9c45f551d45955e43f9eb
Showing with 1,293 additions and 709 deletions.
  1. +40 −0 README.md
  2. +2 −2 composer.json
  3. +7 −26 library/Zend/Db/Adapter/Adapter.php
  4. +11 −1 library/Zend/Db/Adapter/Driver/Mysqli/Result.php
  5. +10 −2 library/Zend/Db/Adapter/Driver/Pdo/Result.php
  6. +6 −2 library/Zend/Db/Adapter/Driver/Pgsql/Result.php
  7. +1 −1 library/Zend/Db/Adapter/Driver/Pgsql/Statement.php
  8. +1 −0 library/Zend/Db/Adapter/Driver/ResultInterface.php
  9. +8 −0 library/Zend/Db/Adapter/Driver/Sqlsrv/Result.php
  10. +67 −7 library/Zend/Db/ResultSet/AbstractResultSet.php
  11. +3 −0 library/Zend/Db/RowGateway/AbstractRowGateway.php
  12. +10 −1 library/Zend/Db/Sql/Select.php
  13. +44 −9 library/Zend/Form/Element/Csrf.php
  14. +69 −3 library/Zend/Form/Element/MultiCheckbox.php
  15. +1 −1 library/Zend/Form/Element/Radio.php
  16. +76 −11 library/Zend/Form/Element/Select.php
  17. +16 −10 library/Zend/Form/Factory.php
  18. +4 −0 library/Zend/Form/Form.php
  19. +4 −5 library/Zend/Form/View/Helper/FormElement.php
  20. +21 −18 library/Zend/Form/View/Helper/FormMultiCheckbox.php
  21. +36 −0 library/Zend/Form/View/Helper/FormReset.php
  22. +41 −6 library/Zend/Form/View/Helper/FormRow.php
  23. +13 −9 library/Zend/Form/View/Helper/FormSelect.php
  24. +36 −0 library/Zend/Form/View/Helper/FormSubmit.php
  25. +10 −0 library/Zend/Http/PhpEnvironment/Request.php
  26. +4 −4 library/Zend/I18n/Translator/Loader/{LoaderInterface.php → FileLoaderInterface.php}
  27. +5 −5 library/Zend/I18n/Translator/Loader/Gettext.php
  28. +5 −5 library/Zend/I18n/Translator/Loader/PhpArray.php
  29. +30 −0 library/Zend/I18n/Translator/Loader/RemoteLoaderInterface.php
  30. +9 −8 library/Zend/I18n/Translator/LoaderPluginManager.php
  31. +91 −15 library/Zend/I18n/Translator/Translator.php
  32. +4 −6 library/Zend/Log/Writer/Syslog.php
  33. +6 −2 library/Zend/Mvc/Controller/Plugin/PostRedirectGet.php
  34. +0 −67 library/Zend/Paginator/AdapterPluginManager.php
  35. +1 −87 library/Zend/Paginator/Paginator.php
  36. +11 −0 library/Zend/Stdlib/Hydrator/ClassMethods.php
  37. +7 −4 library/Zend/Validator/Csrf.php
  38. +7 −21 tests/ZendTest/Db/Adapter/AdapterTest.php
  39. +23 −0 tests/ZendTest/Db/ResultSet/ResultSetTest.php
  40. +35 −0 tests/ZendTest/Db/RowGateway/AbstractRowGatewayTest.php
  41. +13 −1 tests/ZendTest/Db/Sql/SelectTest.php
  42. +17 −0 tests/ZendTest/Form/Element/CsrfTest.php
  43. +23 −10 tests/ZendTest/Form/Element/SelectTest.php
  44. +12 −0 tests/ZendTest/Form/FactoryTest.php
  45. +2 −2 tests/ZendTest/Form/FormTest.php
  46. +12 −2 tests/ZendTest/Form/View/Helper/FormElementTest.php
  47. +14 −14 tests/ZendTest/Form/View/Helper/FormMultiCheckboxTest.php
  48. +8 −8 tests/ZendTest/Form/View/Helper/FormRadioTest.php
  49. +21 −0 tests/ZendTest/Form/View/Helper/FormResetTest.php
  50. +14 −1 tests/ZendTest/Form/View/Helper/FormRowTest.php
  51. +13 −13 tests/ZendTest/Form/View/Helper/FormSelectTest.php
  52. +20 −0 tests/ZendTest/Form/View/Helper/FormSubmitTest.php
  53. +31 −1 tests/ZendTest/Http/PhpEnvironment/RequestTest.php
  54. +6 −7 tests/ZendTest/I18n/Translator/Loader/GettextTest.php
  55. +5 −6 tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php
  56. +2 −2 tests/ZendTest/I18n/Translator/TestAsset/Loader.php
  57. +1 −1 tests/ZendTest/I18n/Validator/FloatTest.php
  58. +19 −0 tests/ZendTest/Mvc/Controller/Plugin/PostRedirectGetTest.php
  59. +8 −8 tests/ZendTest/Paginator/Adapter/ArrayTest.php
  60. +12 −11 tests/ZendTest/Paginator/Adapter/IteratorTest.php
  61. +11 −11 tests/ZendTest/Paginator/Adapter/NullTest.php
  62. +23 −114 tests/ZendTest/Paginator/PaginatorTest.php
  63. +21 −18 tests/ZendTest/Paginator/ScrollingStyle/AllTest.php
  64. +38 −35 tests/ZendTest/Paginator/ScrollingStyle/ElasticTest.php
  65. +34 −31 tests/ZendTest/Paginator/ScrollingStyle/JumpingTest.php
  66. +28 −25 tests/ZendTest/Paginator/ScrollingStyle/SlidingTest.php
  67. +0 −22 tests/ZendTest/Paginator/TestAsset/AdapterPluginManager.php
  68. +0 −19 tests/ZendTest/Paginator/TestAsset/TestTable.php
  69. +36 −2 tests/ZendTest/Stdlib/HydratorTest.php
  70. +26 −0 tests/ZendTest/Stdlib/TestAsset/ClassMethodsCamelCase.php
  71. +26 −0 tests/ZendTest/Stdlib/TestAsset/ClassMethodsUnderscore.php
  72. +17 −3 tests/ZendTest/Validator/CsrfTest.php
  73. +1 −1 tests/ZendTest/Validator/TestAsset/ArrayTranslator.php
  74. +3 −2 tests/ZendTest/View/Helper/PaginationControlTest.php
  75. +1 −1 tests/ZendTest/View/Helper/TestAsset/ArrayTranslator.php
View
@@ -15,13 +15,53 @@ XX August 2012
### UPDATES IN RC6
+- Zend\Db
+ - ResultInterface adds isBuffered() method for checking if the resultset is
+ buffered or not. Allows for more fine grained control of result set
+ buffering, including using the database engine's native buffering.
+- Zend\Form
+ - You can now omit error messages on elements when rendering via formRow(), by
+ passing a boolean false as the third argument of the helper.
+ - You can now use concrete hydrator instances with the factory.
+ - You may now set the CSRF validator class and/or options to use on the Csrf
+ element
+ - The Select, Radio, and MultiCheckbox elements and view helpers were
+ refactored to move value options into properties, instead of attributes.
+ This makes them more consistent with other elements, and simplifies the
+ interfaces.
+ - Forms now lazy-load an input filter if none has been specified; this should
+ simplify usage for many, and remove the "no input filter attached"
+ exception.
+ - All form helpers for buttons (button, submit, reset) now allow translation.
+- Zend\Http
+ - Some browser/web server combingations set SERVER_NAME to the IPv6 address,
+ and enclose it in brackets. The PhpEnvironment\Request object now correctly
+ detects such situations.
+- Zend\I18n\Translator
+ - Loader\LoaderInterface was splitted into Loader\FileLoaderInterface and
+ Loader\RemoteLoaderInterface. The latter one will be used in ZF 2.1 for
+ a database loader.
+ - Translator::addTranslationPattern() and the option "translation_patterns"
+ were renamed to Translator::addTranslationFilePattern and
+ "translation_file_patterns".
+ - A new method Translator::addRemoteTranslations() was added.
- Zend\Mvc
- Application no longer defines the "application" identifier for its composed
EventManager instance. If you had listeners listening on that context,
update them to use "Zend\Mvc\Application". See this thread for more details:
http://zend-framework-community.634137.n4.nabble.com/Change-to-Zend-Mvc-Application-s-event-identifiers-tp4656517.html
+ - The PRG plugin now allows passing no arguments; if you do so, the currently
+ matched route will be used for the redirect.
+- Zend\Paginator
+ - Removes the factory() and related methods. This was done to be more
+ consistent with other components, and also because the utility was not
+ terribly useful; in most cases, developers needed to configure the adapter
+ up-front anyways.
+- Zend\Stdlib
+ - ClassMethods Hydrator now supports boolean getters prefixed with "is"
+
More than XX pull requests for a variety of features and bugfixes were handled
since RC5, as well as around XX documentation changes!
View
@@ -23,8 +23,8 @@
},
"autoload": {
"psr-0": {
- "Zend": "library/",
- "ZendTest": "tests/"
+ "Zend\\": "library/",
+ "ZendTest\\": "tests/"
}
},
"config": {
@@ -51,15 +51,10 @@ class Adapter
protected $platform = null;
/**
- * @var \Zend\Db\ResultSet\ResultSet
+ * @var ResultSet\ResultSetInterface
*/
protected $queryResultSetPrototype = null;
- /**
- * @var string
- */
- protected $queryMode = self::QUERY_MODE_PREPARE;
-
/**
* @var Driver\StatementInterface
*/
@@ -106,33 +101,19 @@ public function getDriver()
}
/**
- * @param string $queryMode
- * @return Adapter
- * @throws \InvalidArgumentException
+ * @return Platform\PlatformInterface
*/
- public function setQueryMode($queryMode)
- {
- if (!in_array($queryMode, array(self::QUERY_MODE_EXECUTE, self::QUERY_MODE_PREPARE))) {
- throw new Exception\InvalidArgumentException(
- sprintf('Query Mode must be one of "%s" or "%s"', self::QUERY_MODE_EXECUTE, self::QUERY_MODE_PREPARE)
- );
- }
-
- $this->queryMode = $queryMode;
- return $this;
- }
-
- public function getQueryMode()
+ public function getPlatform()
{
- return $this->queryMode;
+ return $this->platform;
}
/**
- * @return Platform\PlatformInterface
+ * @return ResultSet\ResultSetInterface
*/
- public function getPlatform()
+ public function getQueryResultSetPrototype()
{
- return $this->platform;
+ return $this->queryResultSetPrototype;
}
public function getCurrentSchema()
@@ -112,6 +112,14 @@ public function buffer()
}
}
+ /**
+ * @return bool|null
+ */
+ public function isBuffered()
+ {
+ return $this->isBuffered;
+ }
+
/**
* Return the resource
* @return mixed
@@ -192,7 +200,9 @@ protected function loadDataFromMysqliStatement()
}
if (($r = $this->resource->fetch()) === null) {
- $this->resource->close();
+ if (!$this->isBuffered) {
+ $this->resource->close();
+ }
return false;
} elseif ($r === false) {
throw new Exception\RuntimeException($this->resource->error);
@@ -53,7 +53,7 @@ class Result implements Iterator, ResultInterface
* Track current item in recordset
* @var mixed
*/
- protected $currentData;
+ protected $currentData = null;
/**
* Current position of scrollable statement
@@ -95,6 +95,14 @@ public function buffer()
return null;
}
+ /**
+ * @return bool|null
+ */
+ public function isBuffered()
+ {
+ return false;
+ }
+
/**
* Get resource
*
@@ -164,7 +172,7 @@ public function rewind()
*/
public function valid()
{
- return ($this->currentData != false);
+ return ($this->currentData !== false);
}
/**
@@ -34,7 +34,6 @@ class Result implements ResultInterface
public function initialize($resource, $generatedValue)
{
if (!is_resource($resource) || get_resource_type($resource) != 'pgsql result') {
- var_dump($resource); debug_print_backtrace();
throw new \Exception('Resource not of the correct type.');
}
@@ -73,7 +72,12 @@ public function rewind()
public function buffer()
{
- // @todo
+ return null;
+ }
+
+ public function isBuffered()
+ {
+ return false;
}
public function isQueryResult()
@@ -180,7 +180,7 @@ public function execute($parameters = null)
}
/** END Standard ParameterContainer Merging Block */
- $resultResource = pg_execute($this->pgsql, $this->statementName, $parameters);
+ $resultResource = pg_execute($this->pgsql, $this->statementName, (array) $parameters);
if ($resultResource === false) {
throw new Exception\InvalidQueryException(pg_last_error());
@@ -18,6 +18,7 @@
interface ResultInterface extends \Countable, \Iterator
{
public function buffer();
+ public function isBuffered();
public function isQueryResult();
public function getAffectedRows();
public function getGeneratedValue();
@@ -69,6 +69,14 @@ public function buffer()
return null;
}
+ /**
+ * @return bool
+ */
+ public function isBuffered()
+ {
+ return false;
+ }
+
/**
* Get resource
*
@@ -24,13 +24,24 @@
*/
abstract class AbstractResultSet implements Iterator, ResultSetInterface
{
+
+ /**
+ * if -1, datasource is already buffered
+ * if -2, implicitly disabling buffering in ResultSet
+ * if false, explicitly disabled
+ * if null, default state - nothing, but can buffer until iteration started
+ * if array, already buffering
+ * @var mixed
+ */
+ protected $buffer = null;
+
/**
* @var null|int
*/
protected $count = null;
/**
- * @var Iterator|IteratorAggregate
+ * @var Iterator|IteratorAggregate|ResultInterface
*/
protected $dataSource = null;
@@ -39,6 +50,7 @@
*/
protected $fieldCount = null;
+ protected $position = null;
/**
* Set the data source for the result set
@@ -53,6 +65,9 @@ public function initialize($dataSource)
$this->count = $dataSource->count();
$this->fieldCount = $dataSource->getFieldCount();
$this->dataSource = $dataSource;
+ if ($dataSource->isBuffered()) {
+ $this->buffer = -1;
+ }
return $this;
}
@@ -63,6 +78,7 @@ public function initialize($dataSource)
$this->count = count($dataSource);
$this->fieldCount = count($first);
$this->dataSource = new ArrayIterator($dataSource);
+ $this->buffer = -1; // array's are a natural buffer
} elseif ($dataSource instanceof IteratorAggregate) {
$this->dataSource = $dataSource->getIterator();
} elseif ($dataSource instanceof Iterator) {
@@ -78,6 +94,23 @@ public function initialize($dataSource)
return $this;
}
+ public function buffer()
+ {
+ if ($this->buffer === -2) {
+ throw new Exception\RuntimeException('Buffering must be enabled before iteration is started');
+ } elseif ($this->buffer === null) {
+ $this->buffer = array();
+ }
+ }
+
+ public function isBuffered()
+ {
+ if ($this->buffer === -1 || is_array($this->buffer)) {
+ return true;
+ }
+ return false;
+ }
+
/**
* Get the data source used to create the result set
*
@@ -128,7 +161,11 @@ public function getFieldCount()
*/
public function next()
{
+ if ($this->buffer === null) {
+ $this->buffer = -2; // implicitly disable buffering from here on
+ }
$this->dataSource->next();
+ $this->position++;
}
/**
@@ -138,7 +175,7 @@ public function next()
*/
public function key()
{
- return $this->dataSource->key();
+ return $this->position;
}
/**
@@ -148,7 +185,16 @@ public function key()
*/
public function current()
{
- return $this->dataSource->current();
+ if ($this->buffer === null) {
+ $this->buffer = -2; // implicitly disable buffering from here on
+ } elseif (is_array($this->buffer) && isset($this->buffer[$this->position])) {
+ return $this->buffer[$this->position];
+ }
+ $data = $this->dataSource->current();
+ if (is_array($this->buffer)) {
+ $this->buffer[$this->position] = $data;
+ }
+ return $data;
}
/**
@@ -158,7 +204,16 @@ public function current()
*/
public function valid()
{
- return $this->dataSource->valid();
+ if (is_array($this->buffer) && isset($this->buffer[$this->position])) {
+ return true;
+ }
+ if ($this->dataSource instanceof Iterator) {
+ return $this->dataSource->valid();
+ } else {
+ $key = key($this->dataSource);
+ return ($key !== null);
+ }
+
}
/**
@@ -168,8 +223,14 @@ public function valid()
*/
public function rewind()
{
- $this->dataSource->rewind();
- // return void
+ if (!is_array($this->buffer)) {
+ if ($this->dataSource instanceof Iterator) {
+ $this->dataSource->rewind();
+ } else {
+ reset($this->dataSource);
+ }
+ }
+ $this->position = 0;
}
/**
@@ -195,7 +256,6 @@ public function count()
public function toArray()
{
$return = array();
- // @todo determine if its necessary to cast rows, shouldn't they all be arrays? speed counts.
foreach ($this as $row) {
if (is_array($row)) {
$return[] = $row;
Oops, something went wrong.

0 comments on commit 7e985d7

Please sign in to comment.