diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c864e957bb..f76f6b2975 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,13 +1,9 @@
# CONTRIBUTING
-> ## End-of-Life occurs 28 Sep 2016
+> ## End-of-Life occurred 28 Sep 2016
>
-> Between now and 28 Sep 2016, we will only be accepting security patches to
-> this repository; after that date, we will issue no more releases.
->
-> For more information:
->
-> - https://framework.zend.com/blog/2016-06-28-zf1-eol.html
+> This project is no longer maintained, and reached its end of life on 28 Sep
+> 2016; the last public release was 1.12.20.
---
diff --git a/DEVELOPMENT_README.md b/DEVELOPMENT_README.md
index 24195b52fc..074d741dcb 100644
--- a/DEVELOPMENT_README.md
+++ b/DEVELOPMENT_README.md
@@ -1,5 +1,12 @@
# Development using a virtual machine
+> ## End-of-Life occurred 28 Sep 2016
+>
+> This project is no longer maintained, and reached its end of life on 28 Sep
+> 2016; the last public release was 1.12.20.
+>
+> At this time, the repository has been archived, and is read-only.
+
You can set up a development virtual machine for ZF1 unit testing and library
development following these simple instructions.
@@ -60,4 +67,4 @@ To stop the VM do one of the following:
Also, when any of of the Puppet manifests change (.pp files), it is a good idea to rerun them:
- vagrant provision
\ No newline at end of file
+ vagrant provision
diff --git a/README-GIT.md b/README-GIT.md
index 892565a4ca..879bc4143c 100755
--- a/README-GIT.md
+++ b/README-GIT.md
@@ -1,5 +1,12 @@
# USING THE GIT REPOSITORY
+> ## End-of-Life occurred 28 Sep 2016
+>
+> This project is no longer maintained, and reached its end of life on 28 Sep
+> 2016; the last public release was 1.12.20.
+>
+> At this time, the repository has been archived, and is read-only.
+
## Setup your own public repository
Your first step is to establish a public repository from which we can
diff --git a/README.md b/README.md
index b6f5aa0a09..f2dedb62cf 100644
--- a/README.md
+++ b/README.md
@@ -1,185 +1,7 @@
-![Logo](http://framework.zend.com/images/logos/ZendFramework-logo.png)
+Post end of life changes for zf1 to allow compatibility with the latest PHP versions.
-> ## End-of-Life occurs 28 Sep 2016
->
-> Between now and 28 Sep 2016, we will only be accepting security patches to
-> this repository; after that date, we will issue no more releases.
->
-> For more information:
->
-> - https://framework.zend.com/blog/2016-06-28-zf1-eol.html
+If you have any requests for tags, releases, or anything else. Feel free to raise an issue and I'll get it sorted.
----
+Installable through git clone or through `composer require shardj/zf1-future` https://packagist.org/packages/shardj/zf1-future
-Welcome to the Zend Framework 1.12 Release!
-
-Master: [![Build Status](https://api.travis-ci.org/zendframework/zf1.png?branch=master)](https://travis-ci.org/zendframework/zf1)
-
-RELEASE INFORMATION
-===================
-
-Zend Framework 1.12.21dev Release.
-Released on MMM DD, YYYY.
-
-IMPORTANT FIXES FOR 1.12.21
----------------------------
-
-See http://framework.zend.com/changelog for full details.
-
-NEW FEATURES
-============
-
-Zend_Loader changes
--------------------
-
-A number of autoloaders and autoloader facilities were back ported from
-ZF2 to provide performant alternatives to those already available in the
-1.X releases. These include: Zend_Loader_StandardAutoloader, which
-improves on Zend_Loader_Autoloader by allowing the ability to specify a
-specific path to associate with a vendor prefix or namespace;
-Zend_Loader_ClassMapAutoloader, which provides the ability to use lookup
-tables for autoloading (which are typically the fastest possible way to
-autoload); and Zend_Loader_AutoloaderFactory, which can both create and
-update autoloaders for you, as well as register them with
-spl_autoload_register().
-
-The Zend_Loader changes were back ported from ZF2 by Matthew Weier
-O’Phinney
-
-Zend_EventManager
------------------
-
-Zend_EventManager is a component that allows you to attach and detach
-listeners to named events, both on a per-instance basis as well as via
-shared collections; trigger events; and interrupt execution of
-listeners.
-
-Zend_EventManager was back ported from ZF2 by Matthew Weier O’Phinney
-
-Zend_Http_UserAgent_Features_Adapter_Browscap
----------------------------------------------
-
-This class provides a features adapter that calls get_browser() in order
-to discover mobile device capabilities to inject into UserAgent device
-instances.
-
-Browscap (http://browsers.garykeith.com/) is an open project dedicated
-to collecting an disseminating a “database” of browser capabilities. PHP
-has built-in support for using these files via the get_browser()
-function. This function requires that your php.ini provides a browscap
-entry pointing to the PHP-specific php_browscap.ini file which is
-available at http://browsers.garykeith.com/stream.asp?PHP_BrowsCapINI.
-
-Zend_Http_UserAgent_Features_Adapter_Browscap was created by Matthew
-Weier O’Phinney
-
-Zend_Mobile_Push
-----------------
-
-Zend_Mobile_Push is a component for implementing push notifications for
-the 3 major push notification platforms (Apple (Apns), Google (C2dm) and
-Microsoft (Mpns).
-
-Zend_Mobile_Push was contributed by Mike Willbanks.
-
-Zend_Gdata_Analytics
---------------------
-
-Zend_Gdata_Analytics is an extension to Zend_Gdata to allow interaction
-with Google’s Analytics Data Export API. This extension does not
-encompass any major changes in the overall operation of Zend_Gdata
-components.
-
-Zend_Gdata_Analytics was contributed by Daniel Hartmann.
-
-Removed features
-================
-
-Zend_Http_UserAgent_Features_Adapter_WurflApi
----------------------------------------------
-
-Due to the changes in licensing of WURFL, we have removed the WurflApi
-adapter. We will be providing the WurflApi adapter to ScientiaMobile so
-that users of WURFL will still have that option.
-
-Bug Fixes
-=========
-
-In addition, over 200 reported issues in the tracker have been fixed.
-We’d like to particularly thank Adam Lundrigan, Frank Brückner and
-Martin Hujer for their efforts in making this happen. Thanks also to the
-many people who ran the ZF1 unit tests and reported their results!
-
-For a complete list of closed issues beginning with 1.12.3, visit:
-
- * https://github.com/zendframework/zf1/issues?labels=&milestone=&page=1&state=closed
- * http://framework.zend.com/changelog/
-
-MIGRATION NOTES
-===============
-
-A detailed list of migration notes may be found at:
-
-http://framework.zend.com/manual/en/migration.html
-
-SYSTEM REQUIREMENTS
-===================
-
-Zend Framework requires PHP 5.2.11 or later. Please see our reference
-guide for more detailed system requirements:
-
-http://framework.zend.com/manual/en/requirements.html
-
-INSTALLATION
-============
-
-Please see [INSTALL.md](INSTALL.md).
-
-REPOSITORY HISTORY
-==================
-
-This repository was created based on the release-1.12 branch of a Subversion
-repository, http://framework.zend.com/svn/framework/standard/. It contains a
-subset of the project history, dating from between the 1.5.0 and 1.6.0 releases,
-and only contains the tags for the 1.12 series. If you would like an older
-version, you may access the subversion repository linked above, or download an
-older version from http://framework.zend.com/downloads/archives.
-
-CONTRIBUTING
-============
-
-Please see [README-GIT.md](README-GIT.md) and
-[DEVELOPMENT_README.md](DEVELOPMENT_README.md).
-
-QUESTIONS AND FEEDBACK
-======================
-
-Online documentation can be found at http://framework.zend.com/manual.
-Questions that are not addressed in the manual should be directed to the
-appropriate mailing list:
-
-- http://framework.zend.com/wiki/display/ZFDEV/Mailing+Lists
-
-If you find code in this release behaving in an unexpected manner or
-contrary to its documented behavior, please create an issue in the Zend
-Framework issue tracker at:
-
-- https://github.com/zendframework/zf1/issues
-
-If you would like to be notified of new releases, you can subscribe to
-the fw-announce mailing list by sending a blank message to:
-
-- fw-announce-subscribe@lists.zend.com.
-
-LICENSE
-=======
-
-The files in this archive are released under the Zend Framework license.
-You can find a copy of this license in [LICENSE.txt](LICENSE.txt).
-
-ACKNOWLEDGEMENTS
-================
-
-The Zend Framework team would like to thank all the contributors to the Zend
-Framework project, our corporate sponsor, and you, the Zend Framework user.
-Please visit us sometime soon at http://framework.zend.com.
+Recently https://github.com/Shardj/zf1-extras-future has been created for those who need it.
diff --git a/composer.json b/composer.json
index eb84b09649..3d09685608 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
- "name": "zendframework/zendframework1",
- "description": "Zend Framework 1",
+ "name": "shardj/zf1-future",
+ "description": "Zend Framework 1 PHP 5.4+ compatible. The aim is to keep ZF1 working with the latest PHP versions",
"type": "library",
"keywords": [
"framework",
@@ -9,7 +9,7 @@
"homepage": "http://framework.zend.com/",
"license": "BSD-3-Clause",
"require": {
- "php": ">=5.2.11"
+ "php": ">=5.4"
},
"autoload": {
"psr-0": {
@@ -33,5 +33,8 @@
},
"archive": {
"exclude": ["/demos", "/documentation", "/tests"]
+ },
+ "replace": {
+ "zendframework/zendframework1": "1.*"
}
}
diff --git a/demos/Zend/Mobile/Push/ApnsFeedback.php b/demos/Zend/Mobile/Push/ApnsFeedback.php
index e2b5489eb0..79c07622e0 100644
--- a/demos/Zend/Mobile/Push/ApnsFeedback.php
+++ b/demos/Zend/Mobile/Push/ApnsFeedback.php
@@ -3,7 +3,7 @@
$apns = new Zend_Mobile_Push_Apns();
$apns->setCertificate('/path/to/provisioning-certificate.pem');
-
+
try {
$apns->connect(Zend_Mobile_Push_Apns::SERVER_FEEDBACK_SANDBOX_URI);
} catch (Zend_Mobile_Push_Exception_ServerUnavailable $e) {
@@ -13,9 +13,9 @@
echo 'APNS Connection Error:' . $e->getMessage();
exit(1);
}
-
+
$tokens = $apns->feedback();
-while(list($token, $time) = each($tokens)) {
+foreach ($tokens as $token => $time) {
echo $time . "\t" . $token . PHP_EOL;
}
$apns->close();
diff --git a/demos/Zend/Service/LiveDocx/MailMerge/license-agreement/generate-document-concat.php b/demos/Zend/Service/LiveDocx/MailMerge/license-agreement/generate-document-concat.php
index 5f33ba2152..50afd1f08e 100755
--- a/demos/Zend/Service/LiveDocx/MailMerge/license-agreement/generate-document-concat.php
+++ b/demos/Zend/Service/LiveDocx/MailMerge/license-agreement/generate-document-concat.php
@@ -162,7 +162,7 @@ function randomString()
for ($i = 0; $i < $stringLen; $i ++) {
$pos = (rand() % $poolLen);
- $ret .= $pool{$pos};
+ $ret .= $pool[$pos];
}
return $ret;
diff --git a/documentation/manual/de/module_specs/Zend_View-Helpers-Navigation.xml b/documentation/manual/de/module_specs/Zend_View-Helpers-Navigation.xml
index 61d94ff27e..a272ba2c4b 100644
--- a/documentation/manual/de/module_specs/Zend_View-Helpers-Navigation.xml
+++ b/documentation/manual/de/module_specs/Zend_View-Helpers-Navigation.xml
@@ -756,7 +756,7 @@ echo $this->navigation()->breadcrumbs()
getLabel();'),
+ function ($a) { return $a->getLabel(); },
$this->pages));
]]>
diff --git a/documentation/manual/en/module_specs/Zend_Mobile_Push-Apns.xml b/documentation/manual/en/module_specs/Zend_Mobile_Push-Apns.xml
index 7aa51c29be..f21f15d992 100644
--- a/documentation/manual/en/module_specs/Zend_Mobile_Push-Apns.xml
+++ b/documentation/manual/en/module_specs/Zend_Mobile_Push-Apns.xml
@@ -152,12 +152,12 @@ try {
}
$tokens = $apns->feedback();
-while(list($token, $time) = each($tokens)) {
+foreach ($tokens as $token => $time) {
echo $time . "\t" . $token . PHP_EOL;
}
$apns->close();
]]>
-
+
diff --git a/documentation/manual/en/module_specs/Zend_View-Helpers-Navigation.xml b/documentation/manual/en/module_specs/Zend_View-Helpers-Navigation.xml
index a10299bfaa..b3c032b309 100644
--- a/documentation/manual/en/module_specs/Zend_View-Helpers-Navigation.xml
+++ b/documentation/manual/en/module_specs/Zend_View-Helpers-Navigation.xml
@@ -762,7 +762,7 @@ echo $this->navigation()->breadcrumbs()
getLabel();'),
+ function ($a) { return $a->getLabel(); },
$this->pages));
]]>
@@ -1261,10 +1261,10 @@ Output:
should be rendered.
-
+
- {get|set}ExpandSiblingNodesOfActiveBranch()
+ {get|set}ExpandSiblingNodesOfActiveBranch()
gets/sets a flag specifying whether the sibling nodes of all
nodes in the active branch should also be expanded and rendered.
@@ -1380,8 +1380,8 @@ Output:
- expandSiblingNodesOfActiveBranch
;
- whether the sibling nodes of nodes in the active
+ expandSiblingNodesOfActiveBranch
;
+ whether the sibling nodes of nodes in the active
branch should be expanded and rendered. Expects
a Boolean value.
@@ -1823,7 +1823,7 @@ Output:
]]>
-
+
-
+
+
diff --git a/library/Zend/Amf/Util/BinaryStream.php b/library/Zend/Amf/Util/BinaryStream.php
index b56820a62f..2f5037a9cc 100644
--- a/library/Zend/Amf/Util/BinaryStream.php
+++ b/library/Zend/Amf/Util/BinaryStream.php
@@ -140,7 +140,7 @@ public function readByte()
);
}
- return ord($this->_stream{$this->_needle++});
+ return ord($this->_stream[$this->_needle++]);
}
/**
diff --git a/library/Zend/Barcode/Object/Code25.php b/library/Zend/Barcode/Object/Code25.php
index 5ef4053eae..c55a4c5c04 100644
--- a/library/Zend/Barcode/Object/Code25.php
+++ b/library/Zend/Barcode/Object/Code25.php
@@ -132,7 +132,7 @@ public function getChecksum($text)
$checksum = 0;
for ($i = strlen($text); $i > 0; $i --) {
- $checksum += intval($text{$i - 1}) * $factor;
+ $checksum += intval($text[$i - 1]) * $factor;
$factor = 4 - $factor;
}
diff --git a/library/Zend/Barcode/Object/Ean13.php b/library/Zend/Barcode/Object/Ean13.php
index 55a483b521..dfeb6782e7 100644
--- a/library/Zend/Barcode/Object/Ean13.php
+++ b/library/Zend/Barcode/Object/Ean13.php
@@ -166,7 +166,7 @@ public function getChecksum($text)
$checksum = 0;
for ($i = strlen($text); $i > 0; $i --) {
- $checksum += intval($text{$i - 1}) * $factor;
+ $checksum += intval($text[$i - 1]) * $factor;
$factor = 4 - $factor;
}
@@ -196,7 +196,7 @@ protected function _drawEan13Text()
$leftPosition = $this->getQuietZone() - $characterWidth;
for ($i = 0; $i < $this->_barcodeLength; $i ++) {
$this->_addText(
- $text{$i},
+ $text[$i],
$this->_fontSize * $this->_factor,
$this->_rotate(
$leftPosition,
diff --git a/library/Zend/Barcode/Object/Ean5.php b/library/Zend/Barcode/Object/Ean5.php
index e0a93e0a23..1f074ba077 100644
--- a/library/Zend/Barcode/Object/Ean5.php
+++ b/library/Zend/Barcode/Object/Ean5.php
@@ -124,7 +124,7 @@ public function getChecksum($text)
$checksum = 0;
for ($i = 0 ; $i < $this->_barcodeLength; $i ++) {
- $checksum += intval($text{$i}) * ($i % 2 ? 9 : 3);
+ $checksum += intval($text[$i]) * ($i % 2 ? 9 : 3);
}
return ($checksum % 10);
diff --git a/library/Zend/Barcode/Object/Ean8.php b/library/Zend/Barcode/Object/Ean8.php
index 53965d4c23..a3f9e4510c 100644
--- a/library/Zend/Barcode/Object/Ean8.php
+++ b/library/Zend/Barcode/Object/Ean8.php
@@ -123,7 +123,7 @@ protected function _drawText()
$leftPosition = $this->getQuietZone() + (3 * $this->_barThinWidth) * $this->_factor;
for ($i = 0; $i < $this->_barcodeLength; $i ++) {
$this->_addText(
- $text{$i},
+ $text[$i],
$this->_fontSize * $this->_factor,
$this->_rotate(
$leftPosition,
diff --git a/library/Zend/Barcode/Object/Identcode.php b/library/Zend/Barcode/Object/Identcode.php
index a6f0081c05..69c1e126af 100644
--- a/library/Zend/Barcode/Object/Identcode.php
+++ b/library/Zend/Barcode/Object/Identcode.php
@@ -85,7 +85,7 @@ public function getChecksum($text)
$checksum = 0;
for ($i = strlen($text); $i > 0; $i --) {
- $checksum += intval($text{$i - 1}) * (($i % 2) ? 4 : 9);
+ $checksum += intval($text[$i - 1]) * (($i % 2) ? 4 : 9);
}
$checksum = (10 - ($checksum % 10)) % 10;
diff --git a/library/Zend/Barcode/Object/ObjectAbstract.php b/library/Zend/Barcode/Object/ObjectAbstract.php
index e942a4ad1a..b40a5a8c6e 100644
--- a/library/Zend/Barcode/Object/ObjectAbstract.php
+++ b/library/Zend/Barcode/Object/ObjectAbstract.php
@@ -1322,7 +1322,7 @@ protected function _drawText()
for ($i = 0; $i < $textLength; $i ++) {
$leftPosition = $this->getQuietZone() + $space * ($i + 0.5);
$this->_addText(
- $text{$i},
+ $text[$i],
$this->_fontSize * $this->_factor,
$this->_rotate(
$leftPosition,
diff --git a/library/Zend/Barcode/Object/Upca.php b/library/Zend/Barcode/Object/Upca.php
index b9eaae73fa..dd06705c5a 100644
--- a/library/Zend/Barcode/Object/Upca.php
+++ b/library/Zend/Barcode/Object/Upca.php
@@ -140,7 +140,7 @@ protected function _drawText()
$fontSize *= 0.8;
}
$this->_addText(
- $text{$i},
+ $text[$i],
$fontSize * $this->_factor,
$this->_rotate(
$leftPosition,
diff --git a/library/Zend/Barcode/Object/Upce.php b/library/Zend/Barcode/Object/Upce.php
index cbb5b9bd3e..5cccee53e3 100644
--- a/library/Zend/Barcode/Object/Upce.php
+++ b/library/Zend/Barcode/Object/Upce.php
@@ -84,8 +84,8 @@ protected function _getDefaultOptions()
public function getText()
{
$text = parent::getText();
- if ($text{0} != 1) {
- $text{0} = 0;
+ if ($text[0] != 1) {
+ $text[0] = 0;
}
return $text;
}
@@ -158,7 +158,7 @@ protected function _drawText()
$fontSize *= 0.8;
}
$this->_addText(
- $text{$i},
+ $text[$i],
$fontSize * $this->_factor,
$this->_rotate(
$leftPosition,
@@ -222,8 +222,8 @@ protected function _validateText($value, $options = array())
public function getChecksum($text)
{
$text = $this->_addLeadingZeros($text, true);
- if ($text{0} != 1) {
- $text{0} = 0;
+ if ($text[0] != 1) {
+ $text[0] = 0;
}
return parent::getChecksum($text);
}
diff --git a/library/Zend/Cache/Backend.php b/library/Zend/Cache/Backend.php
index 83f1af5f12..3d99e0939c 100644
--- a/library/Zend/Cache/Backend.php
+++ b/library/Zend/Cache/Backend.php
@@ -76,7 +76,7 @@ public function __construct(array $options = array())
public function setDirectives($directives)
{
if (!is_array($directives)) Zend_Cache::throwException('Directives parameter must be an array');
- while (list($name, $value) = each($directives)) {
+ foreach ($directives as $name => $value) {
if (!is_string($name)) {
Zend_Cache::throwException("Incorrect option name : $name");
}
diff --git a/library/Zend/Config/Yaml.php b/library/Zend/Config/Yaml.php
index 0d107033eb..be69d1c5f2 100755
--- a/library/Zend/Config/Yaml.php
+++ b/library/Zend/Config/Yaml.php
@@ -202,7 +202,7 @@ public function __construct($yaml, $section = null, $options = false)
if (!isset($config[$sectionName])) {
require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception(sprintf(
- 'Section "%s" cannot be found',
+ 'Section "%s" cannot be found',
implode(' ', (array)$section)
));
}
@@ -214,7 +214,7 @@ public function __construct($yaml, $section = null, $options = false)
if (!isset($config[$section])) {
require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception(sprintf(
- 'Section "%s" cannot be found',
+ 'Section "%s" cannot be found',
implode(' ', (array)$section)
));
}
@@ -274,7 +274,6 @@ protected function _processExtends(array $data, $section, array $config = array(
public static function decode($yaml)
{
$lines = explode("\n", $yaml);
- reset($lines);
return self::_decodeYaml(0, $lines);
}
@@ -283,31 +282,32 @@ public static function decode($yaml)
*
* @param int $currentIndent Current indent level
* @param array $lines YAML lines
+ * @param int $pointer The current line being parsed
* @return array|string
*/
- protected static function _decodeYaml($currentIndent, &$lines)
+ protected static function _decodeYaml($currentIndent, $lines, &$pointer = -1)
{
- $config = array();
+ $config = array();
$inIndent = false;
- while (list($n, $line) = each($lines)) {
- $lineno = $n + 1;
+ while (++$pointer < count($lines)) {
+ $lineno = $pointer + 1;
- $line = rtrim(preg_replace("/#.*$/", "", $line));
- if (strlen($line) == 0) {
+ $lines[$pointer] = rtrim(preg_replace("/#.*$/", "", $lines[$pointer]));
+ if (strlen($lines[$pointer]) == 0) {
continue;
}
- $indent = strspn($line, " ");
+ $indent = strspn($lines[$pointer], " ");
// line without the spaces
- $line = trim($line);
- if (strlen($line) == 0) {
+ $lines[$pointer] = trim($lines[$pointer]);
+ if (strlen($lines[$pointer]) == 0) {
continue;
}
if ($indent < $currentIndent) {
// this level is done
- prev($lines);
+ $pointer--;
return $config;
}
@@ -316,7 +316,7 @@ protected static function _decodeYaml($currentIndent, &$lines)
$inIndent = true;
}
- if (preg_match("/(?!-)([\w\-]+):\s*(.*)/", $line, $m)) {
+ if (preg_match("/(?!-)([\w\-]+):\s*(.*)/", $lines[$pointer], $m)) {
// key: value
if (strlen($m[2])) {
// simple key: value
@@ -324,27 +324,27 @@ protected static function _decodeYaml($currentIndent, &$lines)
$value = self::_parseValue($value);
} else {
// key: and then values on new lines
- $value = self::_decodeYaml($currentIndent + 1, $lines);
+ $value = self::_decodeYaml($currentIndent + 1, $lines, $pointer);
if (is_array($value) && !count($value)) {
$value = "";
}
}
$config[$m[1]] = $value;
- } elseif ($line[0] == "-") {
+ } elseif ($lines[$pointer][0] == "-") {
// item in the list:
// - FOO
- if (strlen($line) > 2) {
- $value = substr($line, 2);
+ if (strlen($lines[$pointer]) > 2) {
+ $value = substr($lines[$pointer], 2);
$config[] = self::_parseValue($value);
} else {
- $config[] = self::_decodeYaml($currentIndent + 1, $lines);
+ $config[] = self::_decodeYaml($currentIndent + 1, $lines, $pointer);
}
} else {
require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception(sprintf(
'Error parsing YAML at line %d - unsupported syntax: "%s"',
- $lineno, $line
+ $lineno, $lines[$pointer]
));
}
}
@@ -362,11 +362,11 @@ protected static function _parseValue($value)
$value = trim($value);
// remove quotes from string.
- if ('"' == $value['0']) {
- if ('"' == $value[count($value) -1]) {
+ if ('"' == substr($value, 0, 1)) {
+ if ('"' == substr($value, -1)) {
$value = substr($value, 1, -1);
}
- } elseif ('\'' == $value['0'] && '\'' == $value[count($value) -1]) {
+ } elseif ('\'' == substr($value, 0, 1) && '\'' == substr($value, -1)) {
$value = strtr($value, array("''" => "'", "'" => ''));
}
diff --git a/library/Zend/Controller/Action/Helper/Redirector.php b/library/Zend/Controller/Action/Helper/Redirector.php
index 8c81646224..5bd727c634 100644
--- a/library/Zend/Controller/Action/Helper/Redirector.php
+++ b/library/Zend/Controller/Action/Helper/Redirector.php
@@ -363,7 +363,7 @@ public function setGotoUrl($url, array $options = array())
}
// If relative URL, decide if we should prepend base URL
- if (!preg_match('|^[a-z]+://|', $url)) {
+ if (!preg_match('|^[a-z]+://|i', $url)) {
$url = $this->_prependBase($url);
}
diff --git a/library/Zend/Date.php b/library/Zend/Date.php
index 48bc906f9b..756107b225 100644
--- a/library/Zend/Date.php
+++ b/library/Zend/Date.php
@@ -233,7 +233,7 @@ public function __construct($date = null, $part = null, $locale = null)
*
* @param array $options Options to set
* @throws Zend_Date_Exception
- * @return Options array if no option was given
+ * @return array|void if no option was given
*/
public static function setOptions(array $options = array())
{
diff --git a/library/Zend/Db/Adapter/Abstract.php b/library/Zend/Db/Adapter/Abstract.php
index 9f857c6a54..728bbbba52 100644
--- a/library/Zend/Db/Adapter/Abstract.php
+++ b/library/Zend/Db/Adapter/Abstract.php
@@ -727,7 +727,7 @@ public function getFetchMode()
* @param string|Zend_Db_Select $sql An SQL SELECT statement.
* @param mixed $bind Data to bind into SELECT placeholders.
* @param mixed $fetchMode Override current fetch mode.
- * @return array
+ * @return array|null
*/
public function fetchAll($sql, $bind = array(), $fetchMode = null)
{
diff --git a/library/Zend/Db/Adapter/Pdo/Pgsql.php b/library/Zend/Db/Adapter/Pdo/Pgsql.php
index abd5e637b0..efb74cd145 100644
--- a/library/Zend/Db/Adapter/Pdo/Pgsql.php
+++ b/library/Zend/Db/Adapter/Pdo/Pgsql.php
@@ -156,7 +156,7 @@ public function describeTable($tableName, $schemaName = null)
t.typname AS type,
a.atttypmod,
FORMAT_TYPE(a.atttypid, a.atttypmod) AS complete_type,
- d.adsrc AS default_value,
+ pg_get_expr(d.adbin, d.adrelid) AS default_value,
a.attnotnull AS notnull,
a.attlen AS length,
co.contype,
diff --git a/library/Zend/Db/Adapter/Pdo/Sqlsrv.php b/library/Zend/Db/Adapter/Pdo/Sqlsrv.php
new file mode 100644
index 0000000000..ec507256f5
--- /dev/null
+++ b/library/Zend/Db/Adapter/Pdo/Sqlsrv.php
@@ -0,0 +1,382 @@
+ Zend_Db::INT_TYPE,
+ Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
+ Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
+ 'INT' => Zend_Db::INT_TYPE,
+ 'SMALLINT' => Zend_Db::INT_TYPE,
+ 'TINYINT' => Zend_Db::INT_TYPE,
+ 'BIGINT' => Zend_Db::BIGINT_TYPE,
+ 'DECIMAL' => Zend_Db::FLOAT_TYPE,
+ 'FLOAT' => Zend_Db::FLOAT_TYPE,
+ 'MONEY' => Zend_Db::FLOAT_TYPE,
+ 'NUMERIC' => Zend_Db::FLOAT_TYPE,
+ 'REAL' => Zend_Db::FLOAT_TYPE,
+ 'SMALLMONEY' => Zend_Db::FLOAT_TYPE
+ );
+
+ /**
+ * Creates a PDO DSN for the adapter from $this->_config settings.
+ *
+ * @return string
+ */
+ protected function _dsn()
+ {
+ // baseline of DSN parts
+ $dsn = $this->_config;
+
+ if (isset($dsn['name'])) {
+ $dsn = $this->_pdoType . ':' . $dsn['name'];
+ } else {
+
+ if(isset($dsn['dbname'])) {
+ $dsn['Database'] = $dsn['dbname'];
+ unset($dsn['dbname']);
+ }
+
+ if(isset($dsn['host'])) {
+ if($dsn['host'] == '127.0.0.1') {
+ $dsn['host'] = '(local)';
+ }
+ $dsn['Server'] = $dsn['host'];
+ unset($dsn['host']);
+ }
+
+ unset($dsn['username']);
+ unset($dsn['password']);
+ unset($dsn['options']);
+ unset($dsn['charset']);
+ unset($dsn['persistent']);
+ unset($dsn['driver_options']);
+ if (isset($dsn['ReturnDatesAsStrings'])) {
+ // common sqlsrv setting but not supported by pdo_sqlsrv
+ unset($dsn['ReturnDatesAsStrings']);
+ }
+
+
+ foreach ($dsn as $key => $val) {
+ $dsn[$key] = "$key=$val";
+ }
+
+ $dsn = $this->_pdoType . ':' . implode(';', $dsn);
+ }
+
+ return $dsn;
+ }
+
+ /**
+ * @return void
+ */
+ protected function _connect()
+ {
+ if ($this->_connection) {
+ return;
+ }
+ parent::_connect();
+ $this->_connection->exec('SET QUOTED_IDENTIFIER ON');
+ }
+
+ /**
+ * Set the transaction isoltion level.
+ *
+ * @param integer|null $level A fetch mode from SQLSRV_TXN_*.
+ * @return true
+ * @throws Zend_Db_Adapter_Sqlsrv_Exception
+ */
+ public function setTransactionIsolationLevel($level = null)
+ {
+ $this->_connect();
+ $sql = null;
+
+ // Default transaction level in sql server
+ if ($level === null)
+ {
+ $level = SQLSRV_TXN_READ_COMMITTED;
+ }
+
+ switch ($level) {
+ case SQLSRV_TXN_READ_UNCOMMITTED:
+ $sql = "READ UNCOMMITTED";
+ break;
+ case SQLSRV_TXN_READ_COMMITTED:
+ $sql = "READ COMMITTED";
+ break;
+ case SQLSRV_TXN_REPEATABLE_READ:
+ $sql = "REPEATABLE READ";
+ break;
+ case SQLSRV_TXN_SNAPSHOT:
+ $sql = "SNAPSHOT";
+ break;
+ case SQLSRV_TXN_SERIALIZABLE:
+ $sql = "SERIALIZABLE";
+ break;
+ default:
+ require_once 'Zend/Db/Adapter/Exception.php';
+ throw new Zend_Db_Adapter_Exception("Invalid transaction isolation level mode '$level' specified");
+ }
+
+ if (!$this->_connection->exec("SET TRANSACTION ISOLATION LEVEL $sql;")) {
+ require_once 'Zend/Db/Adapter/Exception.php';
+ throw new Zend_Db_Adapter_Exception("Transaction cannot be changed to '$level'");
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Returns a list of the tables in the database.
+ *
+ * @return array
+ */
+ public function listTables()
+ {
+ $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
+ return $this->fetchCol($sql);
+ }
+
+ /**
+ * Returns the column descriptions for a table.
+ *
+ * The return value is an associative array keyed by the column name,
+ * as returned by the RDBMS.
+ *
+ * The value of each array element is an associative array
+ * with the following keys:
+ *
+ * SCHEMA_NAME => string; name of database or schema
+ * TABLE_NAME => string;
+ * COLUMN_NAME => string; column name
+ * COLUMN_POSITION => number; ordinal position of column in table
+ * DATA_TYPE => string; SQL datatype name of column
+ * DEFAULT => string; default expression of column, null if none
+ * NULLABLE => boolean; true if column can have nulls
+ * LENGTH => number; length of CHAR/VARCHAR
+ * SCALE => number; scale of NUMERIC/DECIMAL
+ * PRECISION => number; precision of NUMERIC/DECIMAL
+ * UNSIGNED => boolean; unsigned property of an integer type
+ * PRIMARY => boolean; true if column is part of the primary key
+ * PRIMARY_POSITION => integer; position of column in primary key
+ * PRIMARY_AUTO => integer; position of auto-generated column in primary key
+ *
+ * @todo Discover column primary key position.
+ * @todo Discover integer unsigned property.
+ *
+ * @param string $tableName
+ * @param string $schemaName OPTIONAL
+ * @return array
+ */
+ public function describeTable($tableName, $schemaName = null)
+ {
+ if ($schemaName != null) {
+ if (strpos($schemaName, '.') !== false) {
+ $result = explode('.', $schemaName);
+ $schemaName = $result[1];
+ }
+ }
+ /**
+ * Discover metadata information about this table.
+ */
+ $sql = "exec sp_columns @table_name = " . $this->quoteIdentifier($tableName, true);
+ if ($schemaName != null) {
+ $sql .= ", @table_owner = " . $this->quoteIdentifier($schemaName, true);
+ }
+
+ $stmt = $this->query($sql);
+ $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
+
+ $table_name = 2;
+ $column_name = 3;
+ $type_name = 5;
+ $precision = 6;
+ $length = 7;
+ $scale = 8;
+ $nullable = 10;
+ $column_def = 12;
+ $column_position = 16;
+
+ /**
+ * Discover primary key column(s) for this table.
+ */
+ $sql = "exec sp_pkeys @table_name = " . $this->quoteIdentifier($tableName, true);
+ if ($schemaName != null) {
+ $sql .= ", @table_owner = " . $this->quoteIdentifier($schemaName, true);
+ }
+
+ $stmt = $this->query($sql);
+ $primaryKeysResult = $stmt->fetchAll(Zend_Db::FETCH_NUM);
+ $primaryKeyColumn = array();
+ $pkey_column_name = 3;
+ $pkey_key_seq = 4;
+ foreach ($primaryKeysResult as $pkeysRow) {
+ $primaryKeyColumn[$pkeysRow[$pkey_column_name]] = $pkeysRow[$pkey_key_seq];
+ }
+
+ $desc = array();
+ $p = 1;
+ foreach ($result as $key => $row) {
+ $identity = false;
+ $words = explode(' ', $row[$type_name], 2);
+ if (isset($words[0])) {
+ $type = $words[0];
+ if (isset($words[1])) {
+ $identity = (bool) preg_match('/identity/', $words[1]);
+ }
+ }
+
+ $isPrimary = array_key_exists($row[$column_name], $primaryKeyColumn);
+ if ($isPrimary) {
+ $primaryPosition = $primaryKeyColumn[$row[$column_name]];
+ } else {
+ $primaryPosition = null;
+ }
+
+ $desc[$this->foldCase($row[$column_name])] = array(
+ 'SCHEMA_NAME' => null, // @todo
+ 'TABLE_NAME' => $this->foldCase($row[$table_name]),
+ 'COLUMN_NAME' => $this->foldCase($row[$column_name]),
+ 'COLUMN_POSITION' => (int) $row[$column_position],
+ 'DATA_TYPE' => $type,
+ 'DEFAULT' => $row[$column_def],
+ 'NULLABLE' => (bool) $row[$nullable],
+ 'LENGTH' => $row[$length],
+ 'SCALE' => $row[$scale],
+ 'PRECISION' => $row[$precision],
+ 'UNSIGNED' => null, // @todo
+ 'PRIMARY' => $isPrimary,
+ 'PRIMARY_POSITION' => $primaryPosition,
+ 'IDENTITY' => $identity
+ );
+ }
+ return $desc;
+ }
+
+ /**
+ * Adds an adapter-specific LIMIT clause to the SELECT statement.
+ *
+ * @param string $sql
+ * @param integer $count
+ * @param integer $offset OPTIONAL
+ * @return string
+ * @throws Zend_Db_Adapter_Exceptions
+ */
+ public function limit($sql, $count, $offset = 0)
+ {
+ $count = intval($count);
+ if ($count <= 0) {
+ require_once 'Zend/Db/Adapter/Exception.php';
+ throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
+ }
+
+ $offset = intval($offset);
+ if ($offset < 0) {
+ /** @see Zend_Db_Adapter_Exception */
+ require_once 'Zend/Db/Adapter/Exception.php';
+ throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
+ }
+
+ if ($offset == 0) {
+ $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . $count . ' ', $sql);
+ } else {
+ $orderby = stristr($sql, 'ORDER BY');
+ if ($orderby !== false) {
+ $sort = (stripos($orderby, ' desc') !== false) ? 'desc' : 'asc';
+ $order = str_ireplace('ORDER BY', '', $orderby);
+ $order = trim(preg_replace('/\bASC\b|\bDESC\b/i', '', $order));
+ }
+
+ $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . ($count+$offset) . ' ', $sql);
+
+ $sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl';
+ if ($orderby !== false) {
+ $innerOrder = preg_replace('/\".*\".\"(.*)\"/i', '"inner_tbl"."$1"', $order);
+ $sql .= ' ORDER BY ' . $innerOrder . ' ';
+ $sql .= (stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC';
+ }
+ $sql .= ') AS outer_tbl';
+ if ($orderby !== false) {
+ $outerOrder = preg_replace('/\".*\".\"(.*)\"/i', '"outer_tbl"."$1"', $order);
+ $sql .= ' ORDER BY ' . $outerOrder . ' ' . $sort;
+ }
+ }
+
+ return $sql;
+ }
+
+ /**
+ * Retrieve server version in PHP style
+ * Pdo_Mssql doesn't support getAttribute(PDO::ATTR_SERVER_VERSION)
+ * @return string
+ */
+ public function getServerVersion()
+ {
+ try {
+ $stmt = $this->query("SELECT SERVERPROPERTY('productversion')");
+ $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
+ if (count($result)) {
+ return $result[0][0];
+ }
+ return null;
+ } catch (PDOException $e) {
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/Zend/Db/Schema/AbstractChange.php b/library/Zend/Db/Schema/AbstractChange.php
new file mode 100644
index 0000000000..16590ea095
--- /dev/null
+++ b/library/Zend/Db/Schema/AbstractChange.php
@@ -0,0 +1,41 @@
+_db = $db;
+ $this->_tablePrefix = $tablePrefix;
+ }
+
+ /**
+ * Changes to be applied in this change
+ *
+ * @return null
+ */
+ abstract function up();
+
+ /**
+ * Rollback changes made in up()
+ *
+ * @return null
+ */
+ abstract function down();
+
+}
\ No newline at end of file
diff --git a/library/Zend/Db/Schema/Exception.php b/library/Zend/Db/Schema/Exception.php
new file mode 100644
index 0000000000..38e996cc90
--- /dev/null
+++ b/library/Zend/Db/Schema/Exception.php
@@ -0,0 +1,3 @@
+ prefix string to place before table names
+ * 'schema_version_table_name' => name of table to use for holding the schema version number
+ *
+ *
+ * @param string $dir Directory where migrations files are stored
+ * @param Zend_Db_Adapter_Abstract $db Database adapter
+ * @param string $tablePrefix Table prefix to be used by change files
+ */
+ public function __construct($dir, Zend_Db_Adapter_Abstract $db, $tablePrefix='')
+ {
+ $this->_dir = realpath($dir);
+ $this->_db = $db;
+ $this->_tablePrefix = $tablePrefix;
+ }
+
+ /**
+ * Retrieves the current database schema version from the database
+ *
+ * If the table does not exist, it will be created and the version will
+ * be set to 0.
+ *
+ * @return int
+ */
+ public function getCurrentSchemaVersion()
+ {
+ // Ensure we have valid connection to the database
+ if (!$this->_db->isConnected()) {
+ $this->_db->getServerVersion();
+ }
+ $schemaVersionTableName = $this->getPrefixedSchemaVersionTableName();
+
+ $sql = "SELECT version FROM " . $schemaVersionTableName;
+ try {
+ $version = $this->_db->fetchOne($sql);
+ } catch (Zend_Db_Exception $e) {
+ // exception means that the schema version table doesn't exist, so create it
+ $createSql = "CREATE TABLE $schemaVersionTableName (
+ version bigint NOT NULL,
+ PRIMARY KEY (version)
+ )";
+ $this->_db->query($createSql);
+ $insertSql = "INSERT INTO $schemaVersionTableName (version) VALUES (0)";
+ $this->_db->query($insertSql);
+ $version = $this->_db->fetchOne($sql);
+ }
+
+ return $version;
+ }
+
+ /**
+ * Updates the database schema to a specified version. If upgrading (increasing
+ * version number) the schema version will be the largest available version
+ * that is less than or equal to the specified version. ie, if the highest version
+ * is 050 and 7000 is specified for $version, the resulting version will be
+ * 050. If downgrading (decreasing version number) the ending version will be
+ * the highest version that is less than or equal to the specified version
+ * number. i.e, if versions 10, 15 and 20 exist and the version is updated
+ * to 19, the resulting version will be 15 since version 20 will be downgraded.
+ *
+ * The method automatcally determines the direction of the migration by comparing
+ * the current version (from the database) and the desired version. If they
+ * are the same, no migration will be performed and the version will remain
+ * the same.
+ *
+ * @param string $version
+ *
+ * @return string
+ */
+ public function updateTo($version = null)
+ {
+ if (is_null($version)) {
+ $version = PHP_INT_MAX;
+ }
+ $version = (int)$version;
+ $currentVersion = $this->getCurrentSchemaVersion();
+ if($currentVersion == $version) {
+ return self::RESULT_AT_CURRENT_VERSION;
+ }
+
+ $migrations = $this->_getMigrationFiles($currentVersion, $version);
+ if(empty($migrations)) {
+ if ($version == PHP_INT_MAX) {
+ return self::RESULT_AT_CURRENT_VERSION;
+ }
+ return self::RESULT_NO_MIGRATIONS_FOUND;
+ }
+
+ $direction = 'up';
+ if ($currentVersion > $version) {
+ $direction = 'down';
+ }
+ foreach ($migrations as $migration) {
+ $this->_processFile($migration, $direction);
+ }
+
+ // figure out what the real version we're going to is if going down
+ // TODO: make this more efficient by caching file information instead
+ // of fetching it again.
+ if ($direction == 'down') {
+ $files = $this->_getMigrationFiles($version, 0);
+ if (empty($files)) {
+ $realVersion = 0;
+ } else {
+ $versionFile = array_shift($files);
+ $realVersion = $versionFile['version'];
+ }
+ // update the database to the version we're actually at
+ $this->_updateSchemaVersion($realVersion);
+ }
+
+ return self::RESULT_OK;
+ }
+
+ /**
+ * Increments the database version a specified number of upgrades. For instance,
+ * if $versions is 1, it will update to the next highest version of the database.
+ *
+ * If $versions is provided and less than 1, it will assume 1 and update
+ * a single version. If a number higher than the available upgradable versions
+ * is specified, it will update to the highest version number.
+ *
+ * If the database is already at the highest version number available, it will
+ * not do anything and indicate it is at the maximum version number via
+ * the return value.
+ *
+ * @param int $versions Number of versions to increment. Must be 1 or greater
+ *
+ * @return string
+ */
+ public function incrementVersion($versions)
+ {
+ $versions = (int)$versions;
+ if ($versions < 1) {
+ $versions = 1;
+ }
+ $currentVersion = $this->getCurrentSchemaVersion();
+
+ $files = $this->_getMigrationFiles($currentVersion, PHP_INT_MAX);
+ if (empty($files)) {
+ return self::RESULT_AT_MAXIMUM_VERSION;
+ }
+
+ $files = array_slice($files, 0, $versions);
+
+ $nextFile = array_pop($files);
+ $nextVersion = $nextFile['version'];
+
+ return $this->updateTo($nextVersion);
+ }
+
+ /**
+ * Decrements the version of the database by the specified number of versions.
+ *
+ * If the database is already at the lowest version number, it will indicate
+ * this through the return value.
+ *
+ * @param int $versions Number of versions to decrement.
+ *
+ * @return string
+ */
+ public function decrementVersion($versions)
+ {
+ $versions = (int)$versions;
+ if ($versions < 1) {
+ $versions = 1;
+ }
+ $currentVersion = $this->getCurrentSchemaVersion();
+
+ $files = $this->_getMigrationFiles($currentVersion, 0);
+ if (empty($files)) {
+ return self::RESULT_AT_MINIMUM_VERSION;
+ }
+
+ $files = array_slice($files, 0, $versions+1);
+ $nextFile = array_pop($files);
+ $nextVersion = $nextFile['version'];
+
+ return $this->updateTo($nextVersion);
+ }
+
+ /**
+ * Retrieves the migration files that are needed to take the database from
+ * its a specified version (current version) to the desired version. It
+ * will also determine the direction of the migration and sort the files
+ * accordingly.
+ *
+ * @param string $currentVersion Version to migrate database from
+ * @param string $stopVersion Version to migrate database to
+ * @param string $dir Directory containing migration files
+ *
+ * @throws Zend_Db_Schema_Exception
+ *
+ * @return array of file name, version and class name
+ */
+ protected function _getMigrationFiles($currentVersion, $stopVersion, $dir = null)
+ {
+ if ($dir === null) {
+ $dir = $this->_dir;
+ }
+
+ $direction = 'up';
+ $from = $currentVersion;
+ $to = $stopVersion;
+ if($stopVersion < $currentVersion) {
+ $direction = 'down';
+ $from = $stopVersion;
+ $to = $currentVersion;
+ }
+
+ $files = array();
+ if (!is_dir($dir) || !is_readable($dir)) {
+ return $files;
+ }
+
+ $d = dir($dir);
+ $seen = array();
+ while (false !== ($entry = $d->read())) {
+ if (preg_match('/^([0-9]+)\-(.*)\.php/i', $entry, $matches) ) {
+ $versionNumber = (int)$matches[1];
+ if (isset($seen[$versionNumber])) {
+ throw new Zend_Db_Schema_Exception("version $versionNumber is used for multiple migrations.");
+ }
+ $seen[$versionNumber] = true;
+ $className = $matches[2];
+ if ($versionNumber > $from && $versionNumber <= $to) {
+ $path = $this->_relativePath($this->_dir, $dir);
+ $files["v{$matches[1]}"] = array(
+ 'path'=>$path,
+ 'filename'=>$entry,
+ 'version'=>$versionNumber,
+ 'classname'=>$className);
+ }
+ } elseif ($entry != '.' && $entry != '..') {
+ $subdir = $dir . '/' . $entry;
+ if (is_dir($subdir) && is_readable($subdir)) {
+ $files = array_merge(
+ $files,
+ $this->_getMigrationFiles(
+ $currentVersion, $stopVersion, $subdir
+ )
+ );
+ }
+ }
+ }
+ $d->close();
+
+ if($direction == 'up') {
+ ksort($files);
+ } else {
+ krsort($files);
+ }
+
+ return $files;
+ }
+
+ /**
+ * Runs a migration file according to the information provided. The
+ * migration parameter is an array or object allowing ArrayAccess with the
+ * following fields:
+ *
+ * version - The version of the migration this file represents
+ * filename - The name of the file containing the code to upgrade or downgrade the database
+ * classname - The name of the class contained in the file
+ *
+ * The direction parameter should be one of either "up" or "down" and indicates
+ * which of the migration class methods should be executed. The up method is
+ * assumed to move the database schema to the next version while down is
+ * assumed to undo whatever up did.
+ *
+ * @param array|ArrayAccess $migration Information about the migration file
+ * @param string $direction "up" or "down"
+ *
+ * @throws Zend_Db_Schema_Exception
+ *
+ * @return null
+ *
+ * @todo I think there may be a problem with different migration files using
+ * the same class name. -- Confirmed. If you migrate single versions at a time,
+ * i.e. using increment or decrement then you will have no problems. If you
+ * try to migrate through files where there are more than one file with a
+ * particular class name, it will fail because it tries to redeclare a class
+ * that already exists.
+ */
+ protected function _processFile($migration, $direction)
+ {
+ $path = $migration['path'];
+ $version = $migration['version'];
+ $filename = $migration['filename'];
+ $classname = $migration['classname'];
+ require_once($this->_dir.'/'.$path.'/'.$filename);
+ if (!class_exists($classname, false)) {
+ throw new Zend_Db_Schema_Exception("Could not find class '$classname' in file '$filename'");
+ }
+ $class = new $classname($this->_db, $this->_tablePrefix);
+ $class->$direction();
+
+ if($direction == 'down') {
+ // current version is actually one lower than this version now
+ $version--;
+ }
+ $this->_updateSchemaVersion($version);
+ }
+
+ /**
+ * Updates the schema version in the database.
+ *
+ * @param int $version Version to update into database
+ *
+ * @return null
+ */
+ protected function _updateSchemaVersion($version)
+ {
+ $schemaVersionTableName = $this->getPrefixedSchemaVersionTableName();
+ $sql = "UPDATE $schemaVersionTableName SET version = " . (int)$version;
+ $this->_db->query($sql);
+ }
+
+ /**
+ * Retrieves the prefixed version of the schema version table.
+ *
+ * @return string
+ */
+ public function getPrefixedSchemaVersionTableName()
+ {
+ return $this->_tablePrefix . $this->_schemaVersionTableName;
+ }
+
+ /**
+ * Returns a relative path from one directory to another
+ *
+ * @param string $from Directory to start from
+ * @param string $to Directory to end at
+ * @param string $ps Path seperator
+ *
+ * @return string
+ */
+ protected function _relativePath($from, $to, $ps = DIRECTORY_SEPARATOR)
+ {
+ $arFrom = explode($ps, rtrim($from, $ps));
+ $arTo = explode($ps, rtrim($to, $ps));
+ while (count($arFrom) && count($arTo) && ($arFrom[0] == $arTo[0])) {
+ array_shift($arFrom);
+ array_shift($arTo);
+ }
+ return str_pad("", count($arFrom) * 3, '..'.$ps).implode($ps, $arTo);
+ }
+}
+
diff --git a/library/Zend/Db/Statement.php b/library/Zend/Db/Statement.php
index be5e2d5912..f544dfc8a2 100644
--- a/library/Zend/Db/Statement.php
+++ b/library/Zend/Db/Statement.php
@@ -193,7 +193,7 @@ protected function _stripQuoted($sql)
// this segfaults only after 65,000 characters instead of 9,000
$sql = preg_replace("/$q([^$q{$escapeChar}]*|($qe)*)*$q/s", '', $sql);
}
-
+
// get a version of the SQL statement with all quoted
// values and delimited identifiers stripped out
// remove "foo\"bar"
diff --git a/library/Zend/Db/Table/Abstract.php b/library/Zend/Db/Table/Abstract.php
index 66aa60545a..cbd27db2fc 100644
--- a/library/Zend/Db/Table/Abstract.php
+++ b/library/Zend/Db/Table/Abstract.php
@@ -1304,7 +1304,11 @@ public function find()
$whereList = array();
$numberTerms = 0;
foreach ($args as $keyPosition => $keyValues) {
- $keyValuesCount = count($keyValues);
+ if (is_array($keyValues) || $keyValues instanceof Countable) {
+ $keyValuesCount = count($keyValues);
+ } else {
+ $keyValuesCount = $keyValues === null ? 0 : 1;
+ }
// Coerce the values to an array.
// Don't simply typecast to array, because the values
// might be Zend_Db_Expr objects.
diff --git a/library/Zend/Feed/Element.php b/library/Zend/Feed/Element.php
index 6e8ffde88b..9376c2551a 100644
--- a/library/Zend/Feed/Element.php
+++ b/library/Zend/Feed/Element.php
@@ -193,7 +193,7 @@ public function __get($var)
if ($length == 1) {
return new Zend_Feed_Element($nodes[0]);
} elseif ($length > 1) {
- return array_map(create_function('$e', 'return new Zend_Feed_Element($e);'), $nodes);
+ return array_map(function ($e) { return new Zend_Feed_Element($e); }, $nodes);
} else {
// When creating anonymous nodes for __set chaining, don't
// call appendChild() on them. Instead we pass the current
diff --git a/library/Zend/Feed/Entry/Atom.php b/library/Zend/Feed/Entry/Atom.php
index 83fd8f1d06..3c3a0a8469 100644
--- a/library/Zend/Feed/Entry/Atom.php
+++ b/library/Zend/Feed/Entry/Atom.php
@@ -103,7 +103,7 @@ public function delete()
// Redirect
case 3:
$deleteUri = $response->getHeader('Location');
- continue;
+ break;
// Error
default:
/**
diff --git a/library/Zend/Filter/Compress/Zip.php b/library/Zend/Filter/Compress/Zip.php
index 9921fe9648..9c71a88444 100644
--- a/library/Zend/Filter/Compress/Zip.php
+++ b/library/Zend/Filter/Compress/Zip.php
@@ -237,7 +237,7 @@ public function decompress($content)
for ($i = 0; $i < $zip->numFiles; $i++) {
$statIndex = $zip->statIndex($i);
$currName = $statIndex['name'];
- if (($currName{0} == '/') ||
+ if (($currName[0] == '/') ||
(substr($currName, 0, 2) == '..') ||
(substr($currName, 0, 4) == './..')
)
diff --git a/library/Zend/Form.php b/library/Zend/Form.php
index 0512dc850b..f16b05f547 100644
--- a/library/Zend/Form.php
+++ b/library/Zend/Form.php
@@ -1170,7 +1170,7 @@ public function addElements(array $elements)
} else {
switch ($argc) {
case 0:
- continue;
+ break;
case (1 <= $argc):
$type = array_shift($spec);
case (2 <= $argc):
@@ -1687,7 +1687,7 @@ public function addSubForms(array $subForms)
$order = null;
switch ($argc) {
case 0:
- continue;
+ break;
case (1 <= $argc):
$subForm = array_shift($spec);
diff --git a/library/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php b/library/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php
index b23dc29d71..4448ed5d0e 100644
--- a/library/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php
+++ b/library/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php
@@ -88,7 +88,7 @@ public static function getAllCapabilities(TeraWurfl $wurflObj)
if (!is_array($group)) {
continue;
}
- while (list ($key, $value) = each($group)) {
+ foreach ($group as $key => $value) {
if (is_bool($value)) {
// to have the same type than the official WURFL API
$features[$key] = ($value ? 'true' : 'false');
diff --git a/library/Zend/Json/Decoder.php b/library/Zend/Json/Decoder.php
index 8a79f0cdd2..6cc569c478 100644
--- a/library/Zend/Json/Decoder.php
+++ b/library/Zend/Json/Decoder.php
@@ -324,7 +324,7 @@ protected function _getNextToken()
$i = $this->_offset;
$start = $i;
- switch ($str{$i}) {
+ switch ($str[$i]) {
case '{':
$this->_token = self::LBRACE;
break;
@@ -351,14 +351,14 @@ protected function _getNextToken()
break;
}
- $chr = $str{$i};
+ $chr = $str[$i];
if ($chr == '\\') {
$i++;
if ($i >= $str_length) {
break;
}
- $chr = $str{$i};
+ $chr = $str[$i];
switch ($chr) {
case '"' :
$result .= '"';
@@ -431,7 +431,7 @@ protected function _getNextToken()
return($this->_token);
}
- $chr = $str{$i};
+ $chr = $str[$i];
if ($chr == '-' || $chr == '.' || ($chr >= '0' && $chr <= '9')) {
if (preg_match('/-?([0-9])*(\.[0-9]*)?((e|E)((-|\+)?)[0-9]+)?/s',
$str, $matches, PREG_OFFSET_CAPTURE, $start) && $matches[0][1] == $start) {
@@ -494,7 +494,7 @@ public static function decodeUnicodeString($chrs)
$i += 5;
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
- $utf8 .= $chrs{$i};
+ $utf8 .= $chrs[$i];
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX
@@ -552,7 +552,7 @@ protected static function _utf162utf8($utf16)
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
- $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
+ $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);
switch (true) {
case ((0x7F & $bytes) == $bytes):
diff --git a/library/Zend/Json/Encoder.php b/library/Zend/Json/Encoder.php
index fbf5b53cca..9013b285c3 100644
--- a/library/Zend/Json/Encoder.php
+++ b/library/Zend/Json/Encoder.php
@@ -558,17 +558,17 @@ protected static function _utf82utf16($utf8)
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr(0x07 & (ord($utf8{0}) >> 2))
- . chr((0xC0 & (ord($utf8{0}) << 6))
- | (0x3F & ord($utf8{1})));
+ return chr(0x07 & (ord($utf8[0]) >> 2))
+ . chr((0xC0 & (ord($utf8[0]) << 6))
+ | (0x3F & ord($utf8[1])));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr((0xF0 & (ord($utf8{0}) << 4))
- | (0x0F & (ord($utf8{1}) >> 2)))
- . chr((0xC0 & (ord($utf8{1}) << 6))
- | (0x7F & ord($utf8{2})));
+ return chr((0xF0 & (ord($utf8[0]) << 4))
+ | (0x0F & (ord($utf8[1]) >> 2)))
+ . chr((0xC0 & (ord($utf8[1]) << 6))
+ | (0x7F & ord($utf8[2])));
}
// ignoring UTF-32 for now, sorry
diff --git a/library/Zend/Locale/Format.php b/library/Zend/Locale/Format.php
index 517dcbb415..c520ffe9a0 100644
--- a/library/Zend/Locale/Format.php
+++ b/library/Zend/Locale/Format.php
@@ -925,7 +925,7 @@ private static function _parseDate($date, $options)
$result['day'] = $splitted[0][$cnt];
}
} else {
- $result['day'] = iconv_substr($splitted[0][0], $split, 2);
+ $result['day'] = (iconv_substr($splitted[0][0], $split, 2)?: false);
$split += 2;
}
++$cnt;
@@ -936,7 +936,7 @@ private static function _parseDate($date, $options)
$result['month'] = $splitted[0][$cnt];
}
} else {
- $result['month'] = iconv_substr($splitted[0][0], $split, 2);
+ $result['month'] = (iconv_substr($splitted[0][0], $split, 2)?: false);
$split += 2;
}
++$cnt;
@@ -953,7 +953,7 @@ private static function _parseDate($date, $options)
$result['year'] = $splitted[0][$cnt];
}
} else {
- $result['year'] = iconv_substr($splitted[0][0], $split, $length);
+ $result['year'] = (iconv_substr($splitted[0][0], $split, $length)?: false);
$split += $length;
}
@@ -965,7 +965,7 @@ private static function _parseDate($date, $options)
$result['hour'] = $splitted[0][$cnt];
}
} else {
- $result['hour'] = iconv_substr($splitted[0][0], $split, 2);
+ $result['hour'] = (iconv_substr($splitted[0][0], $split, 2)?: false);
$split += 2;
}
++$cnt;
@@ -976,7 +976,7 @@ private static function _parseDate($date, $options)
$result['minute'] = $splitted[0][$cnt];
}
} else {
- $result['minute'] = iconv_substr($splitted[0][0], $split, 2);
+ $result['minute'] = (iconv_substr($splitted[0][0], $split, 2)?: false);
$split += 2;
}
++$cnt;
@@ -987,7 +987,7 @@ private static function _parseDate($date, $options)
$result['second'] = $splitted[0][$cnt];
}
} else {
- $result['second'] = iconv_substr($splitted[0][0], $split, 2);
+ $result['second'] = (iconv_substr($splitted[0][0], $split, 2)?: false);
$split += 2;
}
++$cnt;
diff --git a/library/Zend/Pdf/FileParser/Font/OpenType.php b/library/Zend/Pdf/FileParser/Font/OpenType.php
index 05a1d96ba4..76e833cac8 100644
--- a/library/Zend/Pdf/FileParser/Font/OpenType.php
+++ b/library/Zend/Pdf/FileParser/Font/OpenType.php
@@ -890,7 +890,6 @@ protected function _parseCmapTable()
$cmapOffset = $baseOffset + $offset;
$this->moveToOffset($cmapOffset);
$format = $this->readUInt(2);
- $language = -1;
switch ($format) {
case 0x0:
$cmapLength = $this->readUInt(2);
@@ -898,7 +897,7 @@ protected function _parseCmapTable()
if ($language != 0) {
$this->_debugLog('Type 0 cmap tables must be language-independent;'
. ' language: %d; skipping', $language);
- continue;
+ continue 2;
}
break;
@@ -917,7 +916,7 @@ protected function _parseCmapTable()
case 0xa: // break intentionally omitted
case 0xc:
$this->_debugLog('Format: 0x%x currently unsupported; skipping', $format);
- continue;
+ continue 2;
//$this->skipBytes(2);
//$cmapLength = $this->readUInt(4);
//$language = $this->readUInt(4);
@@ -929,7 +928,7 @@ protected function _parseCmapTable()
default:
$this->_debugLog('Unknown subtable format: 0x%x; skipping', $format);
- continue;
+ continue 2;
}
$cmapType = $format;
break;
diff --git a/library/Zend/Reflection/File.php b/library/Zend/Reflection/File.php
index 86d9ffa35a..3e1b21c57d 100644
--- a/library/Zend/Reflection/File.php
+++ b/library/Zend/Reflection/File.php
@@ -355,7 +355,7 @@ protected function _reflect()
case T_DOLLAR_OPEN_CURLY_BRACES:
case T_CURLY_OPEN:
$embeddedVariableTrapped = true;
- continue;
+ break;
// Name of something
case T_STRING:
@@ -366,7 +366,7 @@ protected function _reflect()
$this->_classes[] = $value;
$classTrapped = false;
}
- continue;
+ break;
// Required file names are T_CONSTANT_ENCAPSED_STRING
case T_CONSTANT_ENCAPSED_STRING:
@@ -374,7 +374,7 @@ protected function _reflect()
$this->_requiredFiles[] = $value ."\n";
$requireTrapped = false;
}
- continue;
+ break;
// Functions
case T_FUNCTION:
diff --git a/library/Zend/Registry.php b/library/Zend/Registry.php
index 837b05ae50..4a15a4d18f 100644
--- a/library/Zend/Registry.php
+++ b/library/Zend/Registry.php
@@ -195,15 +195,4 @@ public function __construct($array = array(), $flags = parent::ARRAY_AS_PROPS)
parent::__construct($array, $flags);
}
- /**
- * @param string $index
- * @returns mixed
- *
- * Workaround for http://bugs.php.net/bug.php?id=40442 (ZF-960).
- */
- public function offsetExists($index)
- {
- return array_key_exists($index, $this);
- }
-
}
diff --git a/library/Zend/Rest/Route.php b/library/Zend/Rest/Route.php
index 2b7cdd6241..949a43dd78 100644
--- a/library/Zend/Rest/Route.php
+++ b/library/Zend/Rest/Route.php
@@ -241,7 +241,7 @@ public function match($request, $partial = false)
* @param bool $encode Weither to return urlencoded string
* @return string Route path with user submitted parameters
*/
- public function assemble($data = array(), $reset = false, $encode = true)
+ public function assemble($data = array(), $reset = false, $encode = true, $partial = false)
{
if (!$this->_keysSet) {
if (null === $this->_request) {
diff --git a/library/Zend/Session.php b/library/Zend/Session.php
index 6378cbf612..ce5836a84a 100644
--- a/library/Zend/Session.php
+++ b/library/Zend/Session.php
@@ -199,7 +199,7 @@ protected function __construct()
public static function setOptions(array $userOptions = array())
{
// set default options on first run only (before applying user settings)
- if (!self::$_defaultOptionsSet) {
+ if (!self::$_defaultOptionsSet && !self::$_unitTestEnabled) {
foreach (self::$_defaultOptions as $defaultOptionName => $defaultOptionValue) {
if (isset(self::$_defaultOptions[$defaultOptionName])) {
ini_set("session.$defaultOptionName", $defaultOptionValue);
@@ -216,7 +216,9 @@ public static function setOptions(array $userOptions = array())
// set the ini based values
if (array_key_exists($userOptionName, self::$_defaultOptions)) {
- ini_set("session.$userOptionName", $userOptionValue);
+ if(!self::$_sessionStarted) {
+ ini_set("session.$userOptionName", $userOptionValue);
+ }
}
elseif (isset(self::$_localOptions[$userOptionName])) {
self::${self::$_localOptions[$userOptionName]} = $userOptionValue;
@@ -366,16 +368,17 @@ public static function rememberUntil($seconds = 0)
self::regenerateId();
return;
}
-
- $cookieParams = session_get_cookie_params();
-
- session_set_cookie_params(
- $seconds,
- $cookieParams['path'],
- $cookieParams['domain'],
- $cookieParams['secure']
- );
-
+
+ if (!self::sessionExists()) { // session_set_cookie_params(): Cannot change session cookie parameters when session is active
+ $cookieParams = session_get_cookie_params();
+ session_set_cookie_params(
+ $seconds,
+ $cookieParams['path'],
+ $cookieParams['domain'],
+ $cookieParams['secure']
+ );
+ }
+
// normally "rememberMe()" represents a security context change, so should use new session id
self::regenerateId();
}
@@ -532,6 +535,7 @@ protected static function _checkId($id)
if (!$hashBitsPerChar) {
$hashBitsPerChar = 5; // the default value
}
+ $pattern = '';
switch($hashBitsPerChar) {
case 4: $pattern = '^[0-9a-f]*$'; break;
case 5: $pattern = '^[0-9a-v]*$'; break;
diff --git a/library/Zend/Session/SaveHandler/DbTable.php b/library/Zend/Session/SaveHandler/DbTable.php
index e423a18d4c..69c2cf2326 100644
--- a/library/Zend/Session/SaveHandler/DbTable.php
+++ b/library/Zend/Session/SaveHandler/DbTable.php
@@ -346,10 +346,8 @@ public function write($id, $data)
if (count($rows)) {
$data[$this->_lifetimeColumn] = $this->_getLifetime($rows->current());
-
- if ($this->update($data, $this->_getPrimary($id, self::PRIMARY_TYPE_WHERECLAUSE))) {
- $return = true;
- }
+ $this->update($data, $this->_getPrimary($id, self::PRIMARY_TYPE_WHERECLAUSE));
+ $return = true;
} else {
$data[$this->_lifetimeColumn] = $this->_lifetime;
diff --git a/library/Zend/Tool/DatabaseSchemaProvider.php b/library/Zend/Tool/DatabaseSchemaProvider.php
new file mode 100644
index 0000000000..bdbe9b1127
--- /dev/null
+++ b/library/Zend/Tool/DatabaseSchemaProvider.php
@@ -0,0 +1,471 @@
+updateTo(null, $env, $dir);
+ }
+
+ /**
+ * Allows you to change the database schema version by specifying the desired version. If you are
+ * upgrading (choosing a higher version), it will update to the highest version that is available.
+ * If you are downgrading, it will go to the highest version that is equal to or lower than the
+ * version you specified.
+ *
+ * @param string $version Version to change to
+ * @param string $env Environment to retrieve database credentials from, default is development
+ * @param string $dir Directory containing migration files, default is ./scripts/migrations
+ *
+ * @return boolean
+ */
+ public function updateTo($version, $env='development', $dir='./scripts/migrations')
+ {
+ $this->_init($env);
+ $response = $this->_registry->getResponse();
+ try {
+ $db = $this->_getDbAdapter();
+ $manager = new Zend_Db_Schema_Manager($dir, $db, $this->getTablePrefix());
+
+ $result = $manager->updateTo($version);
+
+ switch ($result) {
+ case Zend_Db_Schema_Manager::RESULT_AT_CURRENT_VERSION:
+ if (!$version) {
+ $version = $manager->getCurrentSchemaVersion();
+ }
+ $response->appendContent("Already at version $version");
+ break;
+
+ case Zend_Db_Schema_Manager::RESULT_NO_MIGRATIONS_FOUND :
+ $response->appendContent("No migration files found to migrate from {$manager->getCurrentSchemaVersion()} to $version");
+ break;
+
+ default:
+ $response->appendContent('Schema updated to version ' . $manager->getCurrentSchemaVersion());
+ }
+
+ return true;
+ } catch (Exception $e) {
+ $response->appendContent('AN ERROR HAS OCCURED:');
+ $response->appendContent($e->getMessage());
+ $response->appendContent($e->getTraceAsString());
+ return false;
+ }
+ }
+
+ /**
+ * Decrements the database schema version to the next version or if specified
+ * down a specified number of versions.
+ *
+ * @param int $versions Number of versions to decrement. Default is 1
+ * @param string $env Environment to read database credentials from
+ * @param string $dir Directory containing migration files
+ *
+ * @return boolean
+ */
+ public function decrement($versions=1, $env='development', $dir='./scripts/migrations')
+ {
+ $this->_init($env);
+ $response = $this->_registry->getResponse();
+ try {
+ $db = $this->_getDbAdapter();
+ $manager = new Zend_Db_Schema_Manager($dir, $db, $this->getTablePrefix());
+
+ $result = $manager->decrementVersion($versions);
+
+ switch ($result) {
+ case Zend_Db_Schema_Manager::RESULT_AT_MINIMUM_VERSION:
+ $response->appendContent("Already at minimum version " . $manager->getCurrentSchemaVersion());
+ break;
+
+ default:
+ $response->appendContent('Schema updated to version ' . $manager->getCurrentSchemaVersion());
+ }
+
+ return true;
+ } catch (Exception $e) {
+ $response->appendContent('AN ERROR HAS OCCURRED: ');
+ $response->appendContent($e->getMessage());
+ $response->appendContent($e->getTraceAsString());
+ return false;
+ }
+ }
+
+ /**
+ * Increments the datbase schema version to the next version or up a specified
+ * number of versions
+ *
+ * @param int $versions Number of versions to increment. Default is 1
+ * @param string $env Environment to read database conguration from
+ * @param string $dir Directory containing migration scripts
+ *
+ * @return booolean
+ */
+ public function increment($versions=1,$env='development', $dir='./scripts/migrations')
+ {
+ $this->_init($env);
+ $response = $this->_registry->getResponse();
+ try {
+ $db = $this->_getDbAdapter();
+ $manager = new Zend_Db_Schema_Manager($dir, $db, $this->getTablePrefix());
+
+ $result = $manager->incrementVersion($versions);
+
+ switch ($result) {
+ case Zend_Db_Schema_Manager::RESULT_AT_MAXIMUM_VERSION:
+ $response->appendContent("Already at maximum version " . $manager->getCurrentSchemaVersion());
+ break;
+
+ default:
+ $response->appendContent('Schema updated to version ' . $manager->getCurrentSchemaVersion());
+ }
+
+ return true;
+ } catch (Exception $e) {
+ $response->appendContent('AN ERROR HAS OCCURED:');
+ $response->appendContent($e->getMessage());
+ $response->appendContent($e->getTraceAsString());
+ return false;
+ }
+ }
+
+ /**
+ * Provide the current schema version number
+ *
+ * @return boolean
+ */
+ public function current($env='development', $dir='./migrations')
+ {
+ $this->_init($env);
+ try {
+
+ // Initialize and retrieve DB resource
+ $db = $this->_getDbAdapter();
+ $manager = new Zend_Db_Schema_Manager($dir, $db, $this->getTablePrefix());
+ echo 'Current schema version is ' . $manager->getCurrentSchemaVersion() . PHP_EOL;
+
+ return true;
+ } catch (Exception $e) {
+ echo 'AN ERROR HAS OCCURED:' . PHP_EOL;
+ echo $e->getMessage() . PHP_EOL;
+ echo $e->getTraceAsString() . PHP_EOL;
+ return false;
+ }
+ }
+
+ /**
+ * Retrieves the realpath for ./scripts/migrations. Does not appear to be
+ * used anywhere. Possible candidate for removal.
+ *
+ * @return string
+ * @deprecated
+ */
+ protected function _getDirectory()
+ {
+ $dir = './scripts/migrations';
+ return realpath($dir);
+ }
+
+ /**
+ * Initializes the Akrabat functionality and adds it to Zend_Tool (zf)
+ *
+ * @param string $env Environment to initialize for
+ *
+ * @return null
+ *
+ * @throws Zend_Tool_Project_Exception
+ */
+ protected function _init($env)
+ {
+ $profile = $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
+ $appConfigFileResource = $profile->search('applicationConfigFile');
+
+ if ($appConfigFileResource == false) {
+ throw new Zend_Tool_Project_Exception('A project with an application config file is required to use this provider.');
+ }
+ $appConfigFilePath = $appConfigFileResource->getPath();
+
+ // Base config, normally the application.ini in the configs dir of your app
+ $this->_config = $this->_createConfig($appConfigFilePath, $env, true);
+
+ // Are there any override config files?
+ foreach($this->_getAppConfigOverridePathList($appConfigFilePath) as $path) {
+ $overrideConfig = $this->_createConfig($path);
+ if (isset($overrideConfig->$env)) {
+ $this->_config->merge($overrideConfig->$env);
+ }
+ }
+
+ require_once 'Zend/Loader/Autoloader.php';
+ $autoloader = Zend_Loader_Autoloader::getInstance();
+ $autoloader->registerNamespace('Zend_');
+ }
+
+ /**
+ * Pull the akrabat section of the zf.ini
+ *
+ * @return Zend_Config_Ini|false Fasle if not set
+ */
+ protected function _getUserConfig()
+ {
+ $userConfig = false;
+ if (isset($this->_registry->getConfig()->akrabat)) {
+ $userConfig = $this->_registry->getConfig()->akrabat;
+ }
+ return $userConfig;
+ }
+
+ /**
+ * Create new Zend_Config object based on a filename
+ *
+ * Mostly a copy and paste from Zend_Application::_loadConfig
+ *
+ * @param string $filename File to create the object from
+ * @param string $section If not null, pull this sestion of the config
+ * file only. Doesn't apply to .php and .inc file
+ * @param string $allowModifications Should the object be mutable or not
+ *
+ * @throws Zend_Db_Schema_Exception
+ *
+ * @return Zend_Config
+ */
+ protected function _createConfig($filename, $section = null, $allowModifications = false) {
+
+ $options = false;
+ if ($allowModifications) {
+ $options = array('allowModifications' => true);
+ }
+
+ $suffix = pathinfo($filename, PATHINFO_EXTENSION);
+ $suffix = ($suffix === 'dist')
+ ? pathinfo(basename($filename, ".$suffix"), PATHINFO_EXTENSION)
+ : $suffix;
+
+ switch (strtolower($suffix)) {
+ case 'ini':
+ $config = new Zend_Config_Ini($filename, $section, $options);
+ break;
+
+ case 'xml':
+ $config = new Zend_Config_Xml($filename, $section, $options);
+ break;
+
+ case 'json':
+ $config = new Zend_Config_Json($filename, $section, $options);
+ break;
+
+ case 'yaml':
+ case 'yml':
+ $config = new Zend_Config_Yaml($filename, $section, $options);
+ break;
+
+ case 'php':
+ case 'inc':
+ $config = include $filename;
+ if (!is_array($config)) {
+ throw new Zend_Db_Schema_Exception(
+ 'Invalid configuration file provided; PHP file does not return array value'
+ );
+ }
+ $config = new Zend_Config($config, $allowModifications);
+ break;
+
+ default:
+ throw new Zend_Db_Schema_Exception(
+ 'Invalid configuration file provided; unknown config type'
+ );
+ }
+ return $config;
+ }
+
+ /**
+ * Will pull a list of file paths to application config overrides
+ *
+ * There is a deliberate attempt to be very forgiving. If a file doesn't exist,
+ * it won't be included in the list. If a the file doesn't have a section that
+ * corresponds the current target environment it don't be merged.
+ *
+ * The config files should be standalone, they will not be able to extend
+ * sections from the base config file.
+ *
+ * The ini, xml, json, yaml and php config file types are supported
+ *
+ * By default we will look for a "local.ini" in the applications configs
+ * directory.
+ *
+ * Config files are added with an order, the order run from lowest to highest.
+ * The "local.ini" file in this case will be given the order of 100
+ *
+ * This can be disabled with the following in your .zf.ini:
+ *
+ * akrabat.appConfigOverride.skipLocal = true
+ *
+ * You can have add to the list of file names to look for in the configs
+ * directory by adding the following to the .zf.ini:
+ *
+ * akrabat.appConfigOverride.name = 'override.ini'
+ *
+ * You can only add one name with this approach and it will be added with the
+ * order of 200
+ *
+ * To add mutiple names to be checked use the following in the .zf.ini:
+ *
+ * akrabat.appConfigOverride.name.60 = 'dev.ini'
+ * akrabat.appConfigOverride.name.50 = 'override.ini.ini'
+ *
+ * Where the last part of the config key is the order to merge the files.
+ *
+ * To add a path to be include, do the following in your .zf.ini:
+ *
+ * akrabat.appConfigOverride.path = '/home/user/projects/account/configs/local.ini'
+ *
+ * You can only add one path with this approach and it will be added with the
+ * order of 300
+ *
+ * To add mutiple path use the following in the .zf.ini:
+ *
+ * akrabat.appConfigOverride.path.1 = './application/configs/dev.ini'
+ * akrabat.appConfigOverride.path.4 = '/home/user/projects/account/configs/local.ini'
+ *
+ * Where the last part of the config key is the order to merge the files.
+ *
+ * If a path is added with an order that clashes with another file then the
+ * path will be added the end of the queue
+ *
+ * @param string $appConfigFilePath
+ *
+ * @return array
+ */
+ protected function _getAppConfigOverridePathList($appConfigFilePath)
+ {
+ $pathList = array();
+ $appConfigDir = dirname($appConfigFilePath);
+ $userConfig = false;
+
+ if ($this->_getUserConfig() !== false
+ && isset($this->_getUserConfig()->appConfigOverride)
+ ) {
+ $userConfig = $this->_getUserConfig()->appConfigOverride;
+ }
+
+ $skipLocal = false;
+ if ($userConfig !== false && isset($userConfig->skipLocal)) {
+ $skipLocal = (bool)$userConfig->skipLocal;
+ }
+
+ // The convention over configuration option
+ if ($skipLocal === false) {
+ $appConfigFilePathLocal = realpath($appConfigDir.'/local.ini');
+ if ($appConfigFilePathLocal) {
+ $pathList[100] = $appConfigFilePathLocal;
+ }
+ }
+
+ if ($userConfig === false) {
+ return $pathList;
+ }
+
+ // Look for file names in the app configs dir
+ if (isset($userConfig->name)) {
+ if ($userConfig->name instanceof Zend_Config) {
+ $fileNameList = $userConfig->name->toArray();
+ } else {
+ $fileNameList = array(200 => $userConfig->name);
+ }
+
+ foreach($fileNameList as $order => $fileName) {
+ $path = realpath($appConfigDir.'/'.$fileName);
+ if ($path) {
+ $pathList[$order] = $appConfigDir.'/'.$fileName;
+ }
+ }
+ }
+
+ // A full or relative path, app dir will not be prefixed
+ if (isset($userConfig->path)) {
+ if ($userConfig->path instanceof Zend_Config) {
+ $filePathList = $userConfig->path->toArray();
+ } else {
+ $filePathList = array(300 => $userConfig->path);
+ }
+
+ foreach($filePathList as $order => $filePath) {
+ if (file_exists($filePath) === false) {
+ continue;
+ }
+ if (isset($pathList[$order])) {
+ $pathList[] = $filePath;
+ } else {
+ $pathList[$order] = $filePath;
+ }
+ }
+ }
+
+ ksort($pathList);
+ return $pathList;
+ }
+
+ /**
+ * Retrieve initialized DB connection
+ *
+ * @return Zend_Db_Adapter_Interface
+ */
+ protected function _getDbAdapter()
+ {
+ if ((null === $this->_db)) {
+ if($this->_config->resources->db){
+ $dbConfig = $this->_config->resources->db;
+ $this->_db = Zend_Db::factory($dbConfig->adapter, $dbConfig->params);
+ } elseif($this->_config->resources->multidb){
+ foreach ($this->_config->resources->multidb as $db) {
+ if($db->default){
+ $this->_db = Zend_Db::factory($db->adapter, $db);
+ }
+ }
+ }
+ if($this->_db instanceof Zend_Db_Adapter_Interface) {
+ throw new Zend_Db_Schema_Exception('Database was not initialized');
+ }
+ }
+ return $this->_db;
+ }
+
+ /**
+ * Retrieve table prefix
+ *
+ * @return string
+ */
+ public function getTablePrefix()
+ {
+ if ((null === $this->_tablePrefix)) {
+ $prefix = '';
+ if (isset($this->_config->resources->db->table_prefix)) {
+ $prefix = $this->_config->resources->db->table_prefix . '_';
+ }
+ $this->_tablePrefix = $prefix;
+ }
+ return $this->_tablePrefix;
+ }
+
+}
diff --git a/library/Zend/Tool/Project/Context/Zf/ApplicationConfigFile.php b/library/Zend/Tool/Project/Context/Zf/ApplicationConfigFile.php
index da74e4dbec..0f4c5a5c2f 100644
--- a/library/Zend/Tool/Project/Context/Zf/ApplicationConfigFile.php
+++ b/library/Zend/Tool/Project/Context/Zf/ApplicationConfigFile.php
@@ -139,7 +139,7 @@ public function addStringItem($key, $value, $section = 'production', $quoteValue
$newLines[] = $contentLine;
if ($insideSection) {
// if its blank, or a section heading
- if (isset($contentLines[$contentLineIndex + 1]{0}) && $contentLines[$contentLineIndex + 1]{0} == '[') {
+ if (isset($contentLines[$contentLineIndex + 1][0]) && $contentLines[$contentLineIndex + 1][0] == '[') {
$newLines[] = $key . ' = ' . $value;
$insideSection = null;
} else if (!isset($contentLines[$contentLineIndex + 1])){
diff --git a/library/Zend/Tool/Project/Profile/Resource/Container.php b/library/Zend/Tool/Project/Profile/Resource/Container.php
index 4f06f6f55d..ffbee3ebc0 100644
--- a/library/Zend/Tool/Project/Profile/Resource/Container.php
+++ b/library/Zend/Tool/Project/Profile/Resource/Container.php
@@ -383,7 +383,7 @@ public function valid()
*/
public function hasChildren()
{
- return (count($this->_subResources > 0)) ? true : false;
+ return (count($this->_subResources) > 0) ? true : false;
}
/**
diff --git a/library/Zend/Validate/File/Count.php b/library/Zend/Validate/File/Count.php
index aa822dfb14..95876f337b 100644
--- a/library/Zend/Validate/File/Count.php
+++ b/library/Zend/Validate/File/Count.php
@@ -254,7 +254,7 @@ public function isValid($value, $file = null)
$this->addFile($value);
}
- $this->_count = count($this->_files);
+ $this->_count = count($this->_files === null ? [] : $this->_files);
if (($this->_max !== null) && ($this->_count > $this->_max)) {
return $this->_throw($file, self::TOO_MANY);
}
diff --git a/library/Zend/Validate/File/FilesSize.php b/library/Zend/Validate/File/FilesSize.php
index b648133416..6fdb57cae7 100644
--- a/library/Zend/Validate/File/FilesSize.php
+++ b/library/Zend/Validate/File/FilesSize.php
@@ -155,10 +155,6 @@ public function isValid($value, $file = null)
}
}
- if (count($this->_messages) > 0) {
- return false;
- }
-
- return true;
+ return empty($this->_messages);
}
}
diff --git a/library/Zend/Validate/File/ImageSize.php b/library/Zend/Validate/File/ImageSize.php
index 871fef84ff..1f1796109f 100644
--- a/library/Zend/Validate/File/ImageSize.php
+++ b/library/Zend/Validate/File/ImageSize.php
@@ -338,11 +338,7 @@ public function isValid($value, $file = null)
$this->_throw($file, self::HEIGHT_TOO_BIG);
}
- if (count($this->_messages) > 0) {
- return false;
- }
-
- return true;
+ return empty($this->_messages);
}
/**
diff --git a/library/Zend/Validate/File/Upload.php b/library/Zend/Validate/File/Upload.php
index 5eae769846..ba5d309893 100644
--- a/library/Zend/Validate/File/Upload.php
+++ b/library/Zend/Validate/File/Upload.php
@@ -161,7 +161,9 @@ public function setFiles($files = array())
*/
public function isValid($value, $file = null)
{
- $this->_messages = null;
+ $this->_messages = array();
+ $files = array();
+
if (array_key_exists($value, $this->_files)) {
$files[$value] = $this->_files[$value];
} else {
@@ -223,11 +225,7 @@ public function isValid($value, $file = null)
}
}
- if (count($this->_messages) > 0) {
- return false;
- } else {
- return true;
- }
+ return empty($this->_messages);
}
/**
diff --git a/library/Zend/Version.php b/library/Zend/Version.php
index ea3df6f7f0..6ce2680fc3 100644
--- a/library/Zend/Version.php
+++ b/library/Zend/Version.php
@@ -32,7 +32,7 @@ final class Zend_Version
/**
* Zend Framework version identification - see compareVersion()
*/
- const VERSION = '1.12.21dev';
+ const VERSION = '1.16.2';
/**
* The latest stable version Zend Framework available
diff --git a/library/Zend/View/Helper/HeadLink.php b/library/Zend/View/Helper/HeadLink.php
index 61bf0a29d3..48cae230ff 100644
--- a/library/Zend/View/Helper/HeadLink.php
+++ b/library/Zend/View/Helper/HeadLink.php
@@ -396,6 +396,7 @@ public function createDataStylesheet(array $args)
}
}
+ $extras = null;
if(0 < count($args) && is_array($args[0])) {
$extras = array_shift($args);
$extras = (array) $extras;
diff --git a/library/Zend/View/Helper/Navigation/Sitemap.php b/library/Zend/View/Helper/Navigation/Sitemap.php
index b93808a2c6..4df6dc38d1 100644
--- a/library/Zend/View/Helper/Navigation/Sitemap.php
+++ b/library/Zend/View/Helper/Navigation/Sitemap.php
@@ -253,10 +253,10 @@ public function url(Zend_Navigation_Page $page)
{
$href = $page->getHref();
- if (!isset($href{0})) {
+ if (!isset($href[0])) {
// no href
return '';
- } elseif ($href{0} == '/') {
+ } elseif ($href[0] == '/') {
// href is relative to root; use serverUrl helper
$url = $this->getServerUrl() . $href;
} elseif (preg_match('/^[a-z]+:/im', (string) $href)) {
diff --git a/library/Zend/Wildfire/Plugin/FirePhp.php b/library/Zend/Wildfire/Plugin/FirePhp.php
index b0e3d5e87a..727d7daaaf 100644
--- a/library/Zend/Wildfire/Plugin/FirePhp.php
+++ b/library/Zend/Wildfire/Plugin/FirePhp.php
@@ -742,7 +742,7 @@ protected function _encodeObject($object, $objectDepth = 1, $arrayDepth = 1)
$name = $raw_name = $just_name;
- if ($name{0} == "\0") {
+ if ($name[0] == "\0") {
$parts = explode("\0", $name);
$name = $parts[2];
}
diff --git a/library/Zend/XmlRpc/Value.php b/library/Zend/XmlRpc/Value.php
index 6b22449964..d9697a69a2 100644
--- a/library/Zend/XmlRpc/Value.php
+++ b/library/Zend/XmlRpc/Value.php
@@ -486,13 +486,13 @@ protected static function _createSimpleXMLElement(&$xml)
*/
protected static function _extractTypeAndValue(SimpleXMLElement $xml, &$type, &$value)
{
- list($type, $value) = each($xml);
+ [$type, $value] = [key($xml), current($xml)];
if (!$type and $value === null) {
$namespaces = array('ex' => 'http://ws.apache.org/xmlrpc/namespaces/extensions');
foreach ($namespaces as $namespaceName => $namespaceUri) {
$namespaceXml = $xml->children($namespaceUri);
- list($type, $value) = each($namespaceXml);
+ [$type, $value] = [key($namespaceXml), current($namespaceXml)];
if ($type !== null) {
$type = $namespaceName . ':' . $type;
break;
diff --git a/tests/Zend/Form/FormTest.php b/tests/Zend/Form/FormTest.php
index 75fbeb65f0..0e271c0116 100644
--- a/tests/Zend/Form/FormTest.php
+++ b/tests/Zend/Form/FormTest.php
@@ -2790,9 +2790,9 @@ public function testErrorMessagesFromProcessAjaxAreLocalizedWhenTranslateAdapter
*/
public function _setup9697()
{
- $callback = create_function('$value, $options',
- 'return (isset($options["bar"]["quo"]["foo"]) &&
- "foo Value" === $options["bar"]["quo"]["foo"]);');
+ $callback = function($value, $options) {
+ return (isset($options["bar"]["quo"]["foo"]) && "foo Value" === $options["bar"]["quo"]["foo"]);
+ };
$this->form->addElement('text', 'foo')
->foo->setBelongsTo('bar[quo]');
@@ -4596,7 +4596,7 @@ public function testIfViewIsSetInTime()
}
$this->assertNotEquals($result,'');
}
-
+
/**
* @group ZF-11088
*/
@@ -4608,7 +4608,7 @@ public function testAddErrorOnElementMakesFormInvalidAndReturnsCustomError()
$errorMessages = $element->getErrorMessages();
$this->assertSame(1, count($errorMessages));
$this->assertSame($errorString, $errorMessages[0]);
-
+
$element2 = new Zend_Form_Element_Text('bar');
$this->form->addElement($element2);
$this->form->getElement('bar')->addError($errorString);
@@ -4616,7 +4616,7 @@ public function testAddErrorOnElementMakesFormInvalidAndReturnsCustomError()
$this->assertSame(1, count($errorMessages2));
$this->assertSame($errorString, $errorMessages2[0]);
}
-
+
/**
* @group ZF-10865
* @expectedException Zend_Form_Exception
@@ -4644,7 +4644,7 @@ public function testDashSeparatedElementsInDisplayGroupsShouldNotRenderOutsideDi
$count = substr_count($html, 'randomelementname-element');
$this->assertEquals(1, $count, $html);
}
-
+
/**
* @group ZF-11831
*/
@@ -4659,7 +4659,7 @@ public function testElementsOfSubFormReceiveCorrectDefaultTranslator()
'locale' => 'en'
));
Zend_Registry::set('Zend_Translate', $trDefault);
-
+
// Translator to use for elements
$trElement = new Zend_Translate(array(
'adapter' => 'array',
@@ -4669,14 +4669,14 @@ public function testElementsOfSubFormReceiveCorrectDefaultTranslator()
'locale' => 'en'
));
Zend_Validate_Abstract::setDefaultTranslator($trElement);
-
+
// Change the form's translator
$form = new Zend_Form();
$form->addElement(new Zend_Form_Element_Text('foo', array(
'required' => true,
'validators' => array('NotEmpty')
)));
-
+
// Create a subform with it's own validator
$sf1 = new Zend_Form_SubForm();
$sf1->addElement(new Zend_Form_Element_Text('foosub', array(
@@ -4684,20 +4684,20 @@ public function testElementsOfSubFormReceiveCorrectDefaultTranslator()
'validators' => array('NotEmpty')
)));
$form->addSubForm($sf1, 'Test1');
-
+
$form->isValid(array());
$messages = $form->getMessages();
$this->assertEquals(
- 'Element',
- @$messages['foo'][Zend_Validate_NotEmpty::IS_EMPTY],
+ 'Element',
+ @$messages['foo'][Zend_Validate_NotEmpty::IS_EMPTY],
'Form element received wrong validator'
);
$this->assertEquals(
- 'Element',
- @$messages['Test1']['foosub'][Zend_Validate_NotEmpty::IS_EMPTY],
+ 'Element',
+ @$messages['Test1']['foosub'][Zend_Validate_NotEmpty::IS_EMPTY],
'SubForm element received wrong validator'
- );
+ );
}
/**
diff --git a/tests/Zend/Gdata/AppTest.php b/tests/Zend/Gdata/AppTest.php
index 0b02b5d87d..b4d1c56654 100644
--- a/tests/Zend/Gdata/AppTest.php
+++ b/tests/Zend/Gdata/AppTest.php
@@ -598,8 +598,8 @@ public function testMagicConstructorsPropogateMinorVersion() {
/**
* When error handler is overridden to throw an ErrorException, the extension loader
- * in Zend_Gdata will throw an ErrorException when the class doesn't exist in the
- * first extension directory even if it exists in subsequent ones. This test
+ * in Zend_Gdata will throw an ErrorException when the class doesn't exist in the
+ * first extension directory even if it exists in subsequent ones. This test
* enforces a fix that keeps this from happening
*
* @group ZF-12268
@@ -608,8 +608,8 @@ public function testMagicConstructorsPropogateMinorVersion() {
public function testLoadExtensionCausesFatalErrorWhenErrorHandlerIsOverridden()
{
// Override the error handler to throw an ErrorException
- set_error_handler(create_function('$a, $b, $c, $d', 'throw new ErrorException($b, 0, $a, $c, $d);'), E_ALL);
- try {
+ set_error_handler(function($a, $b, $c, $d) { throw new ErrorException($b, 0, $a, $c, $d); }, E_ALL);
+ try {
$eq = $this->service->newEventQuery();
restore_error_handler();
$this->assertTrue($eq instanceof Zend_Gdata_Calendar_EventQuery);
diff --git a/tests/Zend/View/Helper/Navigation/_files/mvc/views/bc.phtml b/tests/Zend/View/Helper/Navigation/_files/mvc/views/bc.phtml
index dc66a5619f..8f683a4e4f 100644
--- a/tests/Zend/View/Helper/Navigation/_files/mvc/views/bc.phtml
+++ b/tests/Zend/View/Helper/Navigation/_files/mvc/views/bc.phtml
@@ -1,4 +1,4 @@
getLabel();'),
- $this->pages));
\ No newline at end of file
+ function($a) { return $a->getLabel(); },
+ $this->pages));
diff --git a/tests/Zend/XmlRpc/RequestTest.php b/tests/Zend/XmlRpc/RequestTest.php
index dec3f4075c..c86bee6aa0 100644
--- a/tests/Zend/XmlRpc/RequestTest.php
+++ b/tests/Zend/XmlRpc/RequestTest.php
@@ -287,18 +287,10 @@ protected function _testXmlRequest($xml, $argv)
}
$result = $sx->xpath('//methodName');
- $count = 0;
- while (list( , $node) = each($result)) {
- ++$count;
- }
- $this->assertEquals(1, $count, $xml);
+ $this->assertEquals(1, count($result), $xml);
$result = $sx->xpath('//params');
- $count = 0;
- while (list( , $node) = each($result)) {
- ++$count;
- }
- $this->assertEquals(1, $count, $xml);
+ $this->assertEquals(1, count($result), $xml);
try {
$methodName = (string) $sx->methodName;
diff --git a/tests/runalltests.php b/tests/runalltests.php
index f226fb2398..979ed90f2f 100755
--- a/tests/runalltests.php
+++ b/tests/runalltests.php
@@ -58,7 +58,7 @@
$result = 0;
// run through phpunit
-while(list(, $file)=each($files)) {
+foreach ($files as $file) {
if ($_SERVER['TRAVIS_PHP_VERSION'] == 'hhvm' && $file == 'Zend/CodeGenerator/AllTests.php') {
echo "Skipping $file on HHVM" . PHP_EOL; //gets stuck on the HHVM
continue;
@@ -68,7 +68,7 @@
system($PHPUNIT . ' --stderr -d memory_limit=-1 -d error_reporting=E_ALL\&E_STRICT -d display_errors=1 ' . escapeshellarg($file), $c_result);
echo PHP_EOL;
echo "Finished executing {$file}" . PHP_EOL;
-
+
if ($c_result) {
echo PHP_EOL . "Result of $file is $c_result" . PHP_EOL . PHP_EOL;
$result = $c_result;