Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libs/Zend
diff options
context:
space:
mode:
authorrobocoder <anthon.pang@gmail.com>2010-04-02 08:55:16 +0400
committerrobocoder <anthon.pang@gmail.com>2010-04-02 08:55:16 +0400
commit5f32996b5f00ea0d92e4ffdc3f7226051c9e5e9c (patch)
treeaaaa87165a3e1e2a0c38592e0a992a8fabe7d4a7 /libs/Zend
parent9da7c3427d007a0bbf45da03a7c3176681332fef (diff)
fixes #1275 - update to ZendFramework 1.10.3
git-svn-id: http://dev.piwik.org/svn/trunk@2040 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'libs/Zend')
-rw-r--r--libs/Zend/Auth/Adapter/Ldap.php4
-rw-r--r--libs/Zend/Cache/Backend/File.php17
-rw-r--r--libs/Zend/Cache/Backend/Memcached.php12
-rw-r--r--libs/Zend/Cache/Backend/Static.php1
-rw-r--r--libs/Zend/Cache/Backend/Test.php145
-rw-r--r--libs/Zend/Cache/Core.php120
-rw-r--r--libs/Zend/Db/Adapter/Sqlsrv.php42
-rw-r--r--libs/Zend/Feed/Pubsubhubbub/Subscriber/Callback.php2
-rw-r--r--libs/Zend/Feed/Rss.php3
-rw-r--r--libs/Zend/Mail/Protocol/Abstract.php16
-rw-r--r--libs/Zend/Mail/Transport/Sendmail.php40
-rw-r--r--libs/Zend/Validate.php25
-rw-r--r--libs/Zend/Validate/CreditCard.php32
-rw-r--r--libs/Zend/Validate/EmailAddress.php6
-rw-r--r--libs/Zend/Validate/File/Count.php7
-rw-r--r--libs/Zend/Validate/File/MimeType.php56
-rw-r--r--libs/Zend/Validate/Float.php29
-rw-r--r--libs/Zend/Validate/Iban.php18
-rw-r--r--libs/Zend/Validate/PostCode.php14
-rw-r--r--libs/Zend/Validate/Regex.php21
-rw-r--r--libs/Zend/Validate/Sitemap/Changefreq.php12
-rw-r--r--libs/Zend/Validate/Sitemap/Lastmod.php18
-rw-r--r--libs/Zend/Validate/Sitemap/Loc.php18
-rw-r--r--libs/Zend/Validate/Sitemap/Priority.php19
24 files changed, 497 insertions, 180 deletions
diff --git a/libs/Zend/Auth/Adapter/Ldap.php b/libs/Zend/Auth/Adapter/Ldap.php
index 11b21daa18..b159c91064 100644
--- a/libs/Zend/Auth/Adapter/Ldap.php
+++ b/libs/Zend/Auth/Adapter/Ldap.php
@@ -17,7 +17,7 @@
* @subpackage Zend_Auth_Adapter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Ldap.php 21009 2010-02-09 14:06:42Z sgehrig $
+ * @version $Id: Ldap.php 21320 2010-03-04 16:05:09Z sgehrig $
*/
/**
@@ -286,7 +286,7 @@ class Zend_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface
* @see Zend_Auth_Adapter_Exception
*/
require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Adapter options array not in array');
+ throw new Zend_Auth_Adapter_Exception('Adapter options array not an array');
}
$adapterOptions = $this->_prepareOptions($ldap, $options);
$dname = '';
diff --git a/libs/Zend/Cache/Backend/File.php b/libs/Zend/Cache/Backend/File.php
index 3f86e30f53..dc8888c7b8 100644
--- a/libs/Zend/Cache/Backend/File.php
+++ b/libs/Zend/Cache/Backend/File.php
@@ -17,7 +17,7 @@
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: File.php 20096 2010-01-06 02:05:09Z bkarwin $
+ * @version $Id: File.php 21642 2010-03-25 17:07:02Z mabe $
*/
/**
@@ -123,8 +123,8 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
$this->setCacheDir(self::getTmpDir() . DIRECTORY_SEPARATOR, false);
}
if (isset($this->_options['file_name_prefix'])) { // particular case for this option
- if (!preg_match('~^[\w]+$~', $this->_options['file_name_prefix'])) {
- Zend_Cache::throwException('Invalid file_name_prefix : must use only [a-zA-A0-9_]');
+ if (!preg_match('~^[a-zA-Z0-9_]+$~D', $this->_options['file_name_prefix'])) {
+ Zend_Cache::throwException('Invalid file_name_prefix : must use only [a-zA-Z0-9_]');
}
}
if ($this->_options['metadatas_array_max_size'] < 10) {
@@ -647,6 +647,7 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
$prefix = $this->_options['file_name_prefix'];
$glob = @glob($dir . $prefix . '--*');
if ($glob === false) {
+ // On some systems it is impossible to distinguish between empty match and an error.
return true;
}
foreach ($glob as $file) {
@@ -739,7 +740,8 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
$prefix = $this->_options['file_name_prefix'];
$glob = @glob($dir . $prefix . '--*');
if ($glob === false) {
- return true;
+ // On some systems it is impossible to distinguish between empty match and an error.
+ return array();
}
foreach ($glob as $file) {
if (is_file($file)) {
@@ -802,7 +804,12 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
}
if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) {
// Recursive call
- $result = array_unique(array_merge($result, $this->_get($file . DIRECTORY_SEPARATOR, $mode, $tags)));
+ $recursiveRs = $this->_get($file . DIRECTORY_SEPARATOR, $mode, $tags);
+ if ($recursiveRs === false) {
+ $this->_log('Zend_Cache_Backend_File::_get() / recursive call : can\'t list entries of "'.$file.'"');
+ } else {
+ $result = array_unique(array_merge($result, $recursiveRs));
+ }
}
}
return array_unique($result);
diff --git a/libs/Zend/Cache/Backend/Memcached.php b/libs/Zend/Cache/Backend/Memcached.php
index d5fe002b0c..5c488a6e0f 100644
--- a/libs/Zend/Cache/Backend/Memcached.php
+++ b/libs/Zend/Cache/Backend/Memcached.php
@@ -17,7 +17,7 @@
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Memcached.php 20591 2010-01-25 00:14:10Z mabe $
+ * @version $Id: Memcached.php 21535 2010-03-17 18:20:53Z mabe $
*/
@@ -238,7 +238,7 @@ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Ca
*/
public function remove($id)
{
- return $this->_memcache->delete($id);
+ return $this->_memcache->delete($id, 0);
}
/**
@@ -381,10 +381,10 @@ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Ca
{
$mems = $this->_memcache->getExtendedStats();
- $memSize = 0;
- $memUsed = 0;
+ $memSize = null;
+ $memUsed = null;
foreach ($mems as $key => $mem) {
- if ($mem === false || !$mem['limit_maxbytes']) {
+ if ($mem === false) {
$this->_log('can\'t get stat from ' . $key);
continue;
}
@@ -399,7 +399,7 @@ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Ca
$memUsed += $eachUsed;
}
- if (!$memSize || !$memUsed) {
+ if ($memSize === null || $memUsed === null) {
Zend_Cache::throwException('Can\'t get filling percentage');
}
diff --git a/libs/Zend/Cache/Backend/Static.php b/libs/Zend/Cache/Backend/Static.php
index e2fc5288ad..224e9d4e7d 100644
--- a/libs/Zend/Cache/Backend/Static.php
+++ b/libs/Zend/Cache/Backend/Static.php
@@ -233,7 +233,6 @@ class Zend_Cache_Backend_Static
if ($extension) $ext = $extension;
$file = rtrim($pathName, '/') . '/' . $fileName . $ext;
if ($this->_options['file_locking']) {
- file_put_contents('/var/www/data.dump', $file.$data);
$result = file_put_contents($file, $data, LOCK_EX);
} else {
$result = file_put_contents($file, $data);
diff --git a/libs/Zend/Cache/Backend/Test.php b/libs/Zend/Cache/Backend/Test.php
index 9e9a229a85..eaeec3b4b7 100644
--- a/libs/Zend/Cache/Backend/Test.php
+++ b/libs/Zend/Cache/Backend/Test.php
@@ -17,14 +17,14 @@
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Test.php 20379 2010-01-18 14:40:57Z mabe $
+ * @version $Id: Test.php 21292 2010-03-02 10:25:22Z mabe $
*/
/**
* @see Zend_Cache_Backend_Interface
*/
-require_once 'Zend/Cache/Backend/Interface.php';
+require_once 'Zend/Cache/Backend/ExtendedInterface.php';
/**
* @see Zend_Cache_Backend
@@ -37,7 +37,7 @@ require_once 'Zend/Cache/Backend.php';
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Cache_Backend_Test extends Zend_Cache_Backend implements Zend_Cache_Backend_Interface
+class Zend_Cache_Backend_Test extends Zend_Cache_Backend implements Zend_Cache_Backend_ExtendedInterface
{
/**
* Available options
@@ -253,6 +253,145 @@ class Zend_Cache_Backend_Test extends Zend_Cache_Backend implements Zend_Cache_B
}
/**
+ * Return an array of stored cache ids
+ *
+ * @return array array of stored cache ids (string)
+ */
+ public function getIds()
+ {
+ return array(
+ 'prefix_id1', 'prefix_id2'
+ );
+ }
+
+ /**
+ * Return an array of stored tags
+ *
+ * @return array array of stored tags (string)
+ */
+ public function getTags()
+ {
+ return array(
+ 'tag1', 'tag2'
+ );
+ }
+
+ /**
+ * Return an array of stored cache ids which match given tags
+ *
+ * In case of multiple tags, a logical AND is made between tags
+ *
+ * @param array $tags array of tags
+ * @return array array of matching cache ids (string)
+ */
+ public function getIdsMatchingTags($tags = array())
+ {
+ if ($tags == array('tag1', 'tag2')) {
+ return array('prefix_id1', 'prefix_id2');
+ }
+
+ return array();
+ }
+
+ /**
+ * Return an array of stored cache ids which don't match given tags
+ *
+ * In case of multiple tags, a logical OR is made between tags
+ *
+ * @param array $tags array of tags
+ * @return array array of not matching cache ids (string)
+ */
+ public function getIdsNotMatchingTags($tags = array())
+ {
+ if ($tags == array('tag3', 'tag4')) {
+ return array('prefix_id3', 'prefix_id4');
+ }
+
+ return array();
+ }
+
+ /**
+ * Return an array of stored cache ids which match any given tags
+ *
+ * In case of multiple tags, a logical AND is made between tags
+ *
+ * @param array $tags array of tags
+ * @return array array of any matching cache ids (string)
+ */
+ public function getIdsMatchingAnyTags($tags = array())
+ {
+ if ($tags == array('tag5', 'tag6')) {
+ return array('prefix_id5', 'prefix_id6');
+ }
+
+ return array();
+ }
+
+ /**
+ * Return the filling percentage of the backend storage
+ *
+ * @return int integer between 0 and 100
+ */
+ public function getFillingPercentage()
+ {
+ return 50;
+ }
+
+ /**
+ * Return an array of metadatas for the given cache id
+ *
+ * The array must include these keys :
+ * - expire : the expire timestamp
+ * - tags : a string array of tags
+ * - mtime : timestamp of last modification time
+ *
+ * @param string $id cache id
+ * @return array array of metadatas (false if the cache id is not found)
+ */
+ public function getMetadatas($id)
+ {
+ return false;
+ }
+
+ /**
+ * Give (if possible) an extra lifetime to the given cache id
+ *
+ * @param string $id cache id
+ * @param int $extraLifetime
+ * @return boolean true if ok
+ */
+ public function touch($id, $extraLifetime)
+ {
+ return true;
+ }
+
+ /**
+ * Return an associative array of capabilities (booleans) of the backend
+ *
+ * The array must include these keys :
+ * - automatic_cleaning (is automating cleaning necessary)
+ * - tags (are tags supported)
+ * - expired_read (is it possible to read expired cache records
+ * (for doNotTestCacheValidity option for example))
+ * - priority does the backend deal with priority when saving
+ * - infinite_lifetime (is infinite lifetime can work with this backend)
+ * - get_list (is it possible to get the list of cache ids and the complete list of tags)
+ *
+ * @return array associative of with capabilities
+ */
+ public function getCapabilities()
+ {
+ return array(
+ 'automatic_cleaning' => true,
+ 'tags' => true,
+ 'expired_read' => false,
+ 'priority' => true,
+ 'infinite_lifetime' => true,
+ 'get_list' => true
+ );
+ }
+
+ /**
* Add an event to the log array
*
* @param string $methodName MethodName
diff --git a/libs/Zend/Cache/Core.php b/libs/Zend/Cache/Core.php
index f643dcb152..6598c109a7 100644
--- a/libs/Zend/Cache/Core.php
+++ b/libs/Zend/Cache/Core.php
@@ -16,7 +16,7 @@
* @package Zend_Cache
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Core.php 20930 2010-02-05 14:37:52Z padraic $
+ * @version $Id: Core.php 21293 2010-03-02 10:26:32Z mabe $
*/
@@ -28,6 +28,12 @@
class Zend_Cache_Core
{
/**
+ * Messages
+ */
+ const BACKEND_NOT_SUPPORTS_TAG = 'tags are not supported by the current backend';
+ const BACKEND_NOT_IMPLEMENTS_EXTENDED_IF = 'Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available';
+
+ /**
* Backend Object
*
* @var object $_backend
@@ -466,12 +472,26 @@ class Zend_Cache_Core
public function getIdsMatchingTags($tags = array())
{
if (!$this->_extendedBackend) {
- Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available');
+ Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
}
if (!($this->_backendCapabilities['tags'])) {
- Zend_Cache::throwException('tags are not supported by the current backend');
+ Zend_Cache::throwException(self::BACKEND_NOT_SUPPORT_TAG);
+ }
+
+ $ids = $this->_backend->getIdsMatchingTags($tags);
+
+ // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
+ if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
+ $prefix = & $this->_options['cache_id_prefix'];
+ $prefixLen = strlen($prefix);
+ foreach ($ids as &$id) {
+ if (strpos($id, $prefix) === 0) {
+ $id = substr($id, $prefixLen);
+ }
+ }
}
- return $this->_backend->getIdsMatchingTags($tags);
+
+ return $ids;
}
/**
@@ -485,12 +505,59 @@ class Zend_Cache_Core
public function getIdsNotMatchingTags($tags = array())
{
if (!$this->_extendedBackend) {
- Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available');
+ Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
}
if (!($this->_backendCapabilities['tags'])) {
- Zend_Cache::throwException('tags are not supported by the current backend');
+ Zend_Cache::throwException(self::BACKEND_NOT_SUPPORT_TAG);
+ }
+
+ $ids = $this->_backend->getIdsNotMatchingTags($tags);
+
+ // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
+ if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
+ $prefix = & $this->_options['cache_id_prefix'];
+ $prefixLen = strlen($prefix);
+ foreach ($ids as &$id) {
+ if (strpos($id, $prefix) === 0) {
+ $id = substr($id, $prefixLen);
+ }
+ }
}
- return $this->_backend->getIdsNotMatchingTags($tags);
+
+ return $ids;
+ }
+
+ /**
+ * Return an array of stored cache ids which match any given tags
+ *
+ * In case of multiple tags, a logical OR is made between tags
+ *
+ * @param array $tags array of tags
+ * @return array array of matching any cache ids (string)
+ */
+ public function getIdsMatchingAnyTags($tags = array())
+ {
+ if (!$this->_extendedBackend) {
+ Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
+ }
+ if (!($this->_backendCapabilities['tags'])) {
+ Zend_Cache::throwException(self::BACKEND_NOT_SUPPORT_TAG);
+ }
+
+ $ids = $this->_backend->getIdsMatchingAnyTags($tags);
+
+ // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
+ if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
+ $prefix = & $this->_options['cache_id_prefix'];
+ $prefixLen = strlen($prefix);
+ foreach ($ids as &$id) {
+ if (strpos($id, $prefix) === 0) {
+ $id = substr($id, $prefixLen);
+ }
+ }
+ }
+
+ return $ids;
}
/**
@@ -501,20 +568,23 @@ class Zend_Cache_Core
public function getIds()
{
if (!$this->_extendedBackend) {
- Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available');
- }
- $array = $this->_backend->getIds();
- if ((!isset($this->_options['cache_id_prefix'])) || ($this->_options['cache_id_prefix'] == '')) return $array;
- // we need to remove cache_id_prefix from ids (see #ZF-6178)
- $res = array();
- while (list(,$id) = each($array)) {
- if (strpos($id, $this->_options['cache_id_prefix']) === 0) {
- $res[] = preg_replace("~^{$this->_options['cache_id_prefix']}~", '', $id);
- } else {
- $res[] = $id;
+ Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
+ }
+
+ $ids = $this->_backend->getIds();
+
+ // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
+ if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
+ $prefix = & $this->_options['cache_id_prefix'];
+ $prefixLen = strlen($prefix);
+ foreach ($ids as &$id) {
+ if (strpos($id, $prefix) === 0) {
+ $id = substr($id, $prefixLen);
+ }
}
}
- return $res;
+
+ return $ids;
}
/**
@@ -525,10 +595,10 @@ class Zend_Cache_Core
public function getTags()
{
if (!$this->_extendedBackend) {
- Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available');
+ Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
}
if (!($this->_backendCapabilities['tags'])) {
- Zend_Cache::throwException('tags are not supported by the current backend');
+ Zend_Cache::throwException(self::BACKEND_NOT_SUPPORT_TAG);
}
return $this->_backend->getTags();
}
@@ -541,7 +611,7 @@ class Zend_Cache_Core
public function getFillingPercentage()
{
if (!$this->_extendedBackend) {
- Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available');
+ Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
}
return $this->_backend->getFillingPercentage();
}
@@ -560,7 +630,7 @@ class Zend_Cache_Core
public function getMetadatas($id)
{
if (!$this->_extendedBackend) {
- Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available');
+ Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
}
$id = $this->_id($id); // cache id may need prefix
return $this->_backend->getMetadatas($id);
@@ -576,7 +646,7 @@ class Zend_Cache_Core
public function touch($id, $extraLifetime)
{
if (!$this->_extendedBackend) {
- Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available');
+ Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
}
$id = $this->_id($id); // cache id may need prefix
return $this->_backend->touch($id, $extraLifetime);
@@ -599,7 +669,7 @@ class Zend_Cache_Core
if (substr($string, 0, 9) == 'internal-') {
Zend_Cache::throwException('"internal-*" ids or tags are reserved');
}
- if (!preg_match('~^[\w]+$~D', $string)) {
+ if (!preg_match('~^[a-zA-Z0-9_]+$~D', $string)) {
Zend_Cache::throwException("Invalid id or tag '$string' : must use only [a-zA-Z0-9_]");
}
}
diff --git a/libs/Zend/Db/Adapter/Sqlsrv.php b/libs/Zend/Db/Adapter/Sqlsrv.php
index 51c7345dff..6cccc9f5eb 100644
--- a/libs/Zend/Db/Adapter/Sqlsrv.php
+++ b/libs/Zend/Db/Adapter/Sqlsrv.php
@@ -17,7 +17,7 @@
* @subpackage Adapter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Sqlsrv.php 20630 2010-01-25 21:18:20Z ralph $
+ * @version $Id: Sqlsrv.php 21197 2010-02-24 16:12:53Z rob $
*/
/**
@@ -605,23 +605,29 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract
throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
}
- $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) {
- $sql .= ' ORDER BY ' . $order . ' ';
- $sql .= (stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC';
- }
- $sql .= ') AS outer_tbl';
- if ($orderby !== false) {
- $sql .= ' ORDER BY ' . $order . ' ' . $sort;
+ 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;
diff --git a/libs/Zend/Feed/Pubsubhubbub/Subscriber/Callback.php b/libs/Zend/Feed/Pubsubhubbub/Subscriber/Callback.php
index 182c857d55..c7195809c9 100644
--- a/libs/Zend/Feed/Pubsubhubbub/Subscriber/Callback.php
+++ b/libs/Zend/Feed/Pubsubhubbub/Subscriber/Callback.php
@@ -105,6 +105,8 @@ class Zend_Feed_Pubsubhubbub_Subscriber_Callback
&& $this->_hasValidVerifyToken(null, false)
&& ($this->_getHeader('Content-Type') == 'application/atom+xml'
|| $this->_getHeader('Content-Type') == 'application/rss+xml'
+ || $this->_getHeader('Content-Type') == 'application/xml'
+ || $this->_getHeader('Content-Type') == 'text/xml'
|| $this->_getHeader('Content-Type') == 'application/rdf+xml')
) {
$this->setFeedUpdate($this->_getRawBody());
diff --git a/libs/Zend/Feed/Rss.php b/libs/Zend/Feed/Rss.php
index 237943a2ca..39be817e1c 100644
--- a/libs/Zend/Feed/Rss.php
+++ b/libs/Zend/Feed/Rss.php
@@ -282,8 +282,7 @@ class Zend_Feed_Rss extends Zend_Feed_Abstract
$author = '';
$email = '';
if (isset($array->itunes->owner)) {
- // ZF-9313
- $itunesOwner = $array->itunes->owner;
+ $itunesOwner = $array->itunes->owner;
if (isset($itunesOwner['name'])) {
$author = $itunesOwner['name'];
}
diff --git a/libs/Zend/Mail/Protocol/Abstract.php b/libs/Zend/Mail/Protocol/Abstract.php
index 617e7b7c52..80c8e2fa97 100644
--- a/libs/Zend/Mail/Protocol/Abstract.php
+++ b/libs/Zend/Mail/Protocol/Abstract.php
@@ -18,7 +18,7 @@
* @subpackage Protocol
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $
+ * @version $Id: Abstract.php 21635 2010-03-24 15:25:13Z yoshida@zend.co.jp $
*/
@@ -44,7 +44,7 @@ require_once 'Zend/Validate/Hostname.php';
* @subpackage Protocol
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $
+ * @version $Id: Abstract.php 21635 2010-03-24 15:25:13Z yoshida@zend.co.jp $
* @todo Implement proxy settings
*/
abstract class Zend_Mail_Protocol_Abstract
@@ -111,6 +111,7 @@ abstract class Zend_Mail_Protocol_Abstract
/**
* String template for parsing server responses using sscanf (default: 3 digit code and response string)
* @var resource
+ * @deprecated Since 1.10.3
*/
protected $_template = '%d%s';
@@ -378,8 +379,9 @@ abstract class Zend_Mail_Protocol_Abstract
protected function _expect($code, $timeout = null)
{
$this->_response = array();
- $cmd = '';
- $msg = '';
+ $cmd = '';
+ $more = '';
+ $msg = '';
$errMsg = '';
if (!is_array($code)) {
@@ -388,15 +390,15 @@ abstract class Zend_Mail_Protocol_Abstract
do {
$this->_response[] = $result = $this->_receive($timeout);
- sscanf($result, $this->_template, $cmd, $msg);
+ list($cmd, $more, $msg) = preg_split('/([\s-]+)/', $result, 2, PREG_SPLIT_DELIM_CAPTURE);
if ($errMsg !== '') {
- $errMsg .= $msg;
+ $errMsg .= ' ' . $msg;
} elseif ($cmd === null || !in_array($cmd, $code)) {
$errMsg = $msg;
}
- } while (strpos($msg, '-') === 0); // The '-' message prefix indicates an information string instead of a response string.
+ } while (strpos($more, '-') === 0); // The '-' message prefix indicates an information string instead of a response string.
if ($errMsg !== '') {
/**
diff --git a/libs/Zend/Mail/Transport/Sendmail.php b/libs/Zend/Mail/Transport/Sendmail.php
index 9ab64d26c0..6111ba7cf6 100644
--- a/libs/Zend/Mail/Transport/Sendmail.php
+++ b/libs/Zend/Mail/Transport/Sendmail.php
@@ -17,7 +17,7 @@
* @subpackage Transport
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Sendmail.php 20816 2010-02-01 21:13:54Z freak $
+ * @version $Id: Sendmail.php 21605 2010-03-22 15:09:03Z yoshida@zend.co.jp $
*/
@@ -74,14 +74,14 @@ class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract
*/
public function __construct($parameters = null)
{
- if ($parameters instanceof Zend_Config) {
- $parameters = $parameters->toArray();
- }
-
- if (is_array($parameters)) {
- $parameters = implode(' ', $parameters);
- }
-
+ if ($parameters instanceof Zend_Config) {
+ $parameters = $parameters->toArray();
+ }
+
+ if (is_array($parameters)) {
+ $parameters = implode(' ', $parameters);
+ }
+
$this->parameters = $parameters;
}
@@ -97,35 +97,37 @@ class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract
*/
public function _sendMail()
{
- set_error_handler(array($this, '_handleMailErrors'));
if ($this->parameters === null) {
+ set_error_handler(array($this, '_handleMailErrors'));
$result = mail(
$this->recipients,
$this->_mail->getSubject(),
$this->body,
$this->header);
+ restore_error_handler();
} else {
- if(!is_string($this->parameters)) {
- /**
- * @see Zend_Mail_Transport_Exception
- *
- * Exception is thrown here because
- * $parameters is a public property
- */
+ if(!is_string($this->parameters)) {
+ /**
+ * @see Zend_Mail_Transport_Exception
+ *
+ * Exception is thrown here because
+ * $parameters is a public property
+ */
require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Transport_Exception(
'Parameters were set but are not a string'
);
- }
+ }
+ set_error_handler(array($this, '_handleMailErrors'));
$result = mail(
$this->recipients,
$this->_mail->getSubject(),
$this->body,
$this->header,
$this->parameters);
+ restore_error_handler();
}
- restore_error_handler();
if ($this->_errstr !== null || !$result) {
/**
diff --git a/libs/Zend/Validate.php b/libs/Zend/Validate.php
index b3d4026a76..98b9c310b4 100644
--- a/libs/Zend/Validate.php
+++ b/libs/Zend/Validate.php
@@ -16,7 +16,7 @@
* @package Zend_Validate
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Validate.php 21097 2010-02-19 20:11:34Z thomas $
+ * @version $Id: Validate.php 21340 2010-03-05 15:33:49Z thomas $
*/
/**
@@ -205,6 +205,7 @@ class Zend_Validate implements Zend_Validate_Interface
if (Zend_Loader::isReadable($file)) {
Zend_Loader::loadClass($class);
$className = $class;
+ break;
}
}
}
@@ -264,4 +265,26 @@ class Zend_Validate implements Zend_Validate_Interface
require_once 'Zend/Validate/Abstract.php';
Zend_Validate_Abstract::setMessageLength($length);
}
+
+ /**
+ * Returns the default translation object
+ *
+ * @return Zend_Translate_Adapter|null
+ */
+ public static function getDefaultTranslator($translator = null)
+ {
+ require_once 'Zend/Validate/Abstract.php';
+ return Zend_Validate_Abstract::getDefaultTranslator();
+ }
+
+ /**
+ * Sets a default translation object for all validation objects
+ *
+ * @param Zend_Translate|Zend_Translate_Adapter|null $translator
+ */
+ public static function setDefaultTranslator($translator = null)
+ {
+ require_once 'Zend/Validate/Abstract.php';
+ Zend_Validate_Abstract::setDefaultTranslator($translator);
+ }
}
diff --git a/libs/Zend/Validate/CreditCard.php b/libs/Zend/Validate/CreditCard.php
index 127e2f2e63..e96b92a97a 100644
--- a/libs/Zend/Validate/CreditCard.php
+++ b/libs/Zend/Validate/CreditCard.php
@@ -16,7 +16,7 @@
* @package Zend_Validate
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: CreditCard.php 20358 2010-01-17 19:03:49Z thomas $
+ * @version $Id: CreditCard.php 21570 2010-03-19 19:00:50Z thomas $
*/
/**
@@ -259,26 +259,28 @@ class Zend_Validate_CreditCard extends Zend_Validate_Abstract
$length = strlen($value);
$types = $this->getType();
- $found = false;
+ $foundp = false;
+ $foundl = false;
foreach ($types as $type) {
- if (in_array($length, $this->_cardLength[$type])) {
- foreach ($this->_cardType[$type] as $prefix) {
- if (substr($value, 0, strlen($prefix)) == $prefix) {
- $found = true;
- break;
+ foreach ($this->_cardType[$type] as $prefix) {
+ if (substr($value, 0, strlen($prefix)) == $prefix) {
+ $foundp = true;
+ if (in_array($length, $this->_cardLength[$type])) {
+ $foundl = true;
+ break 2;
}
}
}
}
- if ($found == false) {
- if (!in_array($length, $this->_cardLength[$type])) {
- $this->_error(self::LENGTH, $value);
- return false;
- } else {
- $this->_error(self::PREFIX, $value);
- return false;
- }
+ if ($foundp == false){
+ $this->_error(self::PREFIX, $value);
+ return false;
+ }
+
+ if ($foundl == false) {
+ $this->_error(self::LENGTH, $value);
+ return false;
}
$sum = 0;
diff --git a/libs/Zend/Validate/EmailAddress.php b/libs/Zend/Validate/EmailAddress.php
index ff5630e108..834ed65e75 100644
--- a/libs/Zend/Validate/EmailAddress.php
+++ b/libs/Zend/Validate/EmailAddress.php
@@ -16,7 +16,7 @@
* @package Zend_Validate
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: EmailAddress.php 21083 2010-02-18 19:29:20Z thomas $
+ * @version $Id: EmailAddress.php 21461 2010-03-10 22:34:03Z thomas $
*/
/**
@@ -443,7 +443,9 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract
{
$mxHosts = array();
$result = getmxrr($this->_hostname, $mxHosts);
- if ($result && $this->_options['deep'] && function_exists('checkdnsrr')) {
+ if (!$result) {
+ $this->_error(self::INVALID_MX_RECORD);
+ } else if ($this->_options['deep'] && function_exists('checkdnsrr')) {
$validAddress = false;
$reserved = true;
foreach ($mxHosts as $hostname) {
diff --git a/libs/Zend/Validate/File/Count.php b/libs/Zend/Validate/File/Count.php
index e7519b0d63..b2a4e27a02 100644
--- a/libs/Zend/Validate/File/Count.php
+++ b/libs/Zend/Validate/File/Count.php
@@ -16,7 +16,7 @@
* @package Zend_Validate
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Count.php 20358 2010-01-17 19:03:49Z thomas $
+ * @version $Id: Count.php 21326 2010-03-04 20:32:39Z thomas $
*/
/**
@@ -249,7 +249,10 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract
$value = $file['destination'] . DIRECTORY_SEPARATOR . $file['name'];
}
- $this->addFile($value);
+ if (($file === null) || !empty($file['tmp_name'])) {
+ $this->addFile($value);
+ }
+
$this->_count = count($this->_files);
if (($this->_max !== null) && ($this->_count > $this->_max)) {
return $this->_throw($file, self::TOO_MANY);
diff --git a/libs/Zend/Validate/File/MimeType.php b/libs/Zend/Validate/File/MimeType.php
index a4b4ec58aa..f70788e4ee 100644
--- a/libs/Zend/Validate/File/MimeType.php
+++ b/libs/Zend/Validate/File/MimeType.php
@@ -16,7 +16,7 @@
* @package Zend_Validate
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: MimeType.php 20505 2010-01-21 21:40:23Z thomas $
+ * @version $Id: MimeType.php 21472 2010-03-11 22:16:55Z thomas $
*/
/**
@@ -80,6 +80,13 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract
protected $_magicfile;
/**
+ * Finfo object to use
+ *
+ * @var resource
+ */
+ protected $_finfo;
+
+ /**
* If no $_ENV['MAGIC'] is set, try and autodiscover it based on common locations
* @var array
*/
@@ -145,14 +152,23 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract
if (!empty($_ENV['MAGIC'])) {
$this->setMagicFile($_ENV['MAGIC']);
} elseif (!(@ini_get("safe_mode") == 'On' || @ini_get("safe_mode") === 1)) {
+ require_once 'Zend/Validate/Exception.php';
foreach ($this->_magicFiles as $file) {
// supressing errors which are thrown due to openbase_dir restrictions
- if (@file_exists($file)) {
+ try {
$this->setMagicFile($file);
- break;
+ if ($this->_magicfile !== null) {
+ break;
+ }
+ } catch (Zend_Validate_Exception $e) {
+ // Intentionally, catch and fall through
}
}
}
+
+ if ($this->_magicfile === null) {
+ $this->_magicfile = false;
+ }
}
return $this->_magicfile;
@@ -161,19 +177,33 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract
/**
* Sets the magicfile to use
* if null, the MAGIC constant from php is used
+ * if the MAGIC file is errorous, no file will be set
*
* @param string $file
+ * @throws Zend_Validate_Exception When finfo can not read the magicfile
* @return Zend_Validate_File_MimeType Provides fluid interface
*/
public function setMagicFile($file)
{
if (empty($file)) {
$this->_magicfile = null;
+ } else if (!(class_exists('finfo', false))) {
+ $this->_magicfile = null;
+ require_once 'Zend/Validate/Exception.php';
+ throw new Zend_Validate_Exception('Magicfile can not be set. There is no finfo extension installed');
} else if (!is_readable($file)) {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception('The given magicfile can not be read');
} else {
- $this->_magicfile = (string) $file;
+ $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
+ $this->_finfo = @finfo_open($const, $file);
+ if ($this->_finfo === false) {
+ $this->_finfo = null;
+ require_once 'Zend/Validate/Exception.php';
+ throw new Zend_Validate_Exception('The given magicfile is not accepted by finfo');
+ } else {
+ $this->_magicfile = $file;
+ }
}
return $this;
@@ -302,16 +332,19 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract
$mimefile = $this->getMagicFile();
if (class_exists('finfo', false)) {
$const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
- if (!empty($mimefile)) {
- $mime = new finfo($const, $mimefile);
- } else {
- $mime = new finfo($const);
+ if (!empty($mimefile) && !empty($this->_finfo)) {
+ $this->_finfo = @finfo_open($const, $mimefile);
}
- if ($mime !== false) {
- $this->_type = $mime->file($value);
+ if ($this->_finfo === false) {
+ $this->_finfo = @finfo_open($const);
}
- unset($mime);
+
+ if ($this->_finfo !== false) {
+ $this->_type = finfo_file($this->_finfo, $value);
+ }
+
+ unset($this->_finfo);
}
if (empty($this->_type) &&
@@ -334,6 +367,7 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract
$types = explode('/', $this->_type);
$types = array_merge($types, explode('-', $this->_type));
+ $types = array_merge($types, explode(';', $this->_type));
foreach($mimetype as $mime) {
if (in_array($mime, $types)) {
return true;
diff --git a/libs/Zend/Validate/Float.php b/libs/Zend/Validate/Float.php
index c855aeaf03..4b0899d5a6 100644
--- a/libs/Zend/Validate/Float.php
+++ b/libs/Zend/Validate/Float.php
@@ -16,7 +16,7 @@
* @package Zend_Validate
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Float.php 20532 2010-01-22 20:18:23Z thomas $
+ * @version $Id: Float.php 21664 2010-03-27 21:39:38Z thomas $
*/
/**
@@ -76,9 +76,7 @@ class Zend_Validate_Float extends Zend_Validate_Abstract
}
}
- if ($locale !== null) {
- $this->setLocale($locale);
- }
+ $this->setLocale($locale);
}
/**
@@ -121,27 +119,14 @@ class Zend_Validate_Float extends Zend_Validate_Abstract
}
$this->_setValue($value);
- if ($this->_locale === null) {
- $locale = localeconv();
- $valueFiltered = str_replace($locale['thousands_sep'], '', (string) $value);
- $valueFiltered = str_replace($locale['decimal_point'], '.', $valueFiltered);
-
- if (strval(floatval($valueFiltered)) != $valueFiltered) {
- $this->_error(self::NOT_FLOAT);
- return false;
- }
-
- } else {
- try {
- if (!Zend_Locale_Format::isFloat($value, array('locale' => 'en')) &&
- !Zend_Locale_Format::isFloat($value, array('locale' => $this->_locale))) {
- $this->_error(self::NOT_FLOAT);
- return false;
- }
- } catch (Zend_Locale_Exception $e) {
+ try {
+ if (!Zend_Locale_Format::isFloat($value, array('locale' => $this->_locale))) {
$this->_error(self::NOT_FLOAT);
return false;
}
+ } catch (Zend_Locale_Exception $e) {
+ $this->_error(self::NOT_FLOAT);
+ return false;
}
return true;
diff --git a/libs/Zend/Validate/Iban.php b/libs/Zend/Validate/Iban.php
index e230b3f08e..a35dff5263 100644
--- a/libs/Zend/Validate/Iban.php
+++ b/libs/Zend/Validate/Iban.php
@@ -16,7 +16,7 @@
* @package Zend_Validate
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Iban.php 20532 2010-01-22 20:18:23Z thomas $
+ * @version $Id: Iban.php 21563 2010-03-19 10:10:45Z thomas $
*/
/**
@@ -123,14 +123,14 @@ class Zend_Validate_Iban extends Zend_Validate_Abstract
}
}
- if (empty($locale)) {
+ if ($locale !== false) {
require_once 'Zend/Registry.php';
if (Zend_Registry::isRegistered('Zend_Locale')) {
$locale = Zend_Registry::get('Zend_Locale');
}
}
- if ($locale !== null) {
+ if (!empty($locale)) {
$this->setLocale($locale);
}
}
@@ -153,11 +153,13 @@ class Zend_Validate_Iban extends Zend_Validate_Abstract
*/
public function setLocale($locale = null)
{
- require_once 'Zend/Locale.php';
- $locale = Zend_Locale::findLocale($locale);
- if (strlen($locale) < 4) {
- require_once 'Zend/Validate/Exception.php';
- throw new Zend_Validate_Exception('Region must be given for IBAN validation');
+ if ($locale !== false) {
+ require_once 'Zend/Locale.php';
+ $locale = Zend_Locale::findLocale($locale);
+ if (strlen($locale) < 4) {
+ require_once 'Zend/Validate/Exception.php';
+ throw new Zend_Validate_Exception('Region must be given for IBAN validation');
+ }
}
$this->_locale = $locale;
diff --git a/libs/Zend/Validate/PostCode.php b/libs/Zend/Validate/PostCode.php
index b6bafe0f93..9d122c93e5 100644
--- a/libs/Zend/Validate/PostCode.php
+++ b/libs/Zend/Validate/PostCode.php
@@ -16,7 +16,7 @@
* @package Zend_Validate
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: PostCode.php 21107 2010-02-19 21:40:22Z thomas $
+ * @version $Id: PostCode.php 21487 2010-03-14 10:17:35Z thomas $
*/
/**
@@ -44,8 +44,8 @@ class Zend_Validate_PostCode extends Zend_Validate_Abstract
* @var array
*/
protected $_messageTemplates = array(
- self::INVALID => "Invalid type given, value should be string or integer",
- self::NO_MATCH => "'%value%' does not appear to be an postal code",
+ self::INVALID => "Invalid type given. The value should be a string or a integer",
+ self::NO_MATCH => "'%value%' does not appear to be a postal code",
);
/**
@@ -99,7 +99,7 @@ class Zend_Validate_PostCode extends Zend_Validate_Abstract
$format = $this->getFormat();
if (empty($format)) {
require_once 'Zend/Validate/Exception.php';
- throw new Zend_Validate_Exception("Format has to be a not empty string");
+ throw new Zend_Validate_Exception("A postcode-format string has to be given for validation");
}
}
@@ -129,7 +129,7 @@ class Zend_Validate_PostCode extends Zend_Validate_Abstract
$region = $locale->getRegion();
if (empty($region)) {
require_once 'Zend/Validate/Exception.php';
- throw new Zend_Validate_Exception("Unable to detect a region from the locale '$locale'");
+ throw new Zend_Validate_Exception("Unable to detect a region for the locale '$locale'");
}
$format = Zend_Locale::getTranslation(
@@ -140,7 +140,7 @@ class Zend_Validate_PostCode extends Zend_Validate_Abstract
if (empty($format)) {
require_once 'Zend/Validate/Exception.php';
- throw new Zend_Validate_Exception("Unable to detect a format from the region '{$locale->getRegion()}'");
+ throw new Zend_Validate_Exception("Unable to detect a postcode format for the region '{$locale->getRegion()}'");
}
$this->setFormat($format);
@@ -168,7 +168,7 @@ class Zend_Validate_PostCode extends Zend_Validate_Abstract
{
if (empty($format) || !is_string($format)) {
require_once 'Zend/Validate/Exception.php';
- throw new Zend_Validate_Exception("Format has to be a not empty string");
+ throw new Zend_Validate_Exception("A postcode-format string has to be given for validation");
}
if ($format[0] !== '/') {
diff --git a/libs/Zend/Validate/Regex.php b/libs/Zend/Validate/Regex.php
index db0f376553..4c9b5ed36f 100644
--- a/libs/Zend/Validate/Regex.php
+++ b/libs/Zend/Validate/Regex.php
@@ -16,7 +16,7 @@
* @package Zend_Validate
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Regex.php 20358 2010-01-17 19:03:49Z thomas $
+ * @version $Id: Regex.php 21574 2010-03-19 20:00:37Z thomas $
*/
/**
@@ -34,6 +34,7 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
{
const INVALID = 'regexInvalid';
const NOT_MATCH = 'regexNotMatch';
+ const ERROROUS = 'regexErrorous';
/**
* @var array
@@ -41,6 +42,7 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
protected $_messageTemplates = array(
self::INVALID => "Invalid type given, value should be string, integer or float",
self::NOT_MATCH => "'%value%' does not match against pattern '%pattern%'",
+ self::ERROROUS => "There was an internal error while using the pattern '%pattern%'",
);
/**
@@ -61,6 +63,7 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
* Sets validator options
*
* @param string|Zend_Config $pattern
+ * @throws Zend_Validate_Exception On missing 'pattern' parameter
* @return void
*/
public function __construct($pattern)
@@ -95,11 +98,19 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
* Sets the pattern option
*
* @param string $pattern
+ * @throws Zend_Validate_Exception if there is a fatal error in pattern matching
* @return Zend_Validate_Regex Provides a fluent interface
*/
public function setPattern($pattern)
{
$this->_pattern = (string) $pattern;
+ $status = @preg_match($this->_pattern, "Test");
+
+ if (false === $status) {
+ require_once 'Zend/Validate/Exception.php';
+ throw new Zend_Validate_Exception("Internal error while using the pattern '$this->_pattern'");
+ }
+
return $this;
}
@@ -109,7 +120,6 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
* Returns true if and only if $value matches against the pattern option
*
* @param string $value
- * @throws Zend_Validate_Exception if there is a fatal error in pattern matching
* @return boolean
*/
public function isValid($value)
@@ -123,14 +133,15 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
$status = @preg_match($this->_pattern, $value);
if (false === $status) {
- require_once 'Zend/Validate/Exception.php';
- throw new Zend_Validate_Exception("Internal error matching pattern '$this->_pattern' against value '$value'");
+ $this->_error(self::ERROROUS);
+ return false;
}
+
if (!$status) {
$this->_error(self::NOT_MATCH);
return false;
}
+
return true;
}
-
}
diff --git a/libs/Zend/Validate/Sitemap/Changefreq.php b/libs/Zend/Validate/Sitemap/Changefreq.php
index 6e4cd61d76..517f9b577d 100644
--- a/libs/Zend/Validate/Sitemap/Changefreq.php
+++ b/libs/Zend/Validate/Sitemap/Changefreq.php
@@ -17,7 +17,7 @@
* @subpackage Sitemap
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Changefreq.php 20358 2010-01-17 19:03:49Z thomas $
+ * @version $Id: Changefreq.php 21365 2010-03-07 09:38:41Z thomas $
*/
/**
@@ -42,7 +42,8 @@ class Zend_Validate_Sitemap_Changefreq extends Zend_Validate_Abstract
* Validation key for not valid
*
*/
- const NOT_VALID = 'invalidSitemapChangefreq';
+ const NOT_VALID = 'sitemapChangefreqNotValid';
+ const INVALID = 'sitemapChangefreqInvalid';
/**
* Validation failure message template definitions
@@ -51,6 +52,7 @@ class Zend_Validate_Sitemap_Changefreq extends Zend_Validate_Abstract
*/
protected $_messageTemplates = array(
self::NOT_VALID => "'%value%' is no valid sitemap changefreq",
+ self::INVALID => "Invalid type given, the value should be a string",
);
/**
@@ -73,8 +75,12 @@ class Zend_Validate_Sitemap_Changefreq extends Zend_Validate_Abstract
*/
public function isValid($value)
{
- $this->_setValue($value);
+ if (!is_string($value)) {
+ $this->_error(self::INVALID);
+ return false;
+ }
+ $this->_setValue($value);
if (!is_string($value)) {
return false;
}
diff --git a/libs/Zend/Validate/Sitemap/Lastmod.php b/libs/Zend/Validate/Sitemap/Lastmod.php
index c738a5570f..5644137da5 100644
--- a/libs/Zend/Validate/Sitemap/Lastmod.php
+++ b/libs/Zend/Validate/Sitemap/Lastmod.php
@@ -17,7 +17,7 @@
* @subpackage Sitemap
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Lastmod.php 20358 2010-01-17 19:03:49Z thomas $
+ * @version $Id: Lastmod.php 21365 2010-03-07 09:38:41Z thomas $
*/
/**
@@ -48,7 +48,8 @@ class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract
* Validation key for not valid
*
*/
- const NOT_VALID = 'invalidSitemapLastmod';
+ const NOT_VALID = 'sitemapLastmodNotValid';
+ const INVALID = 'sitemapLastmodInvalid';
/**
* Validation failure message template definitions
@@ -57,6 +58,7 @@ class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract
*/
protected $_messageTemplates = array(
self::NOT_VALID => "'%value%' is no valid sitemap lastmod",
+ self::INVALID => "Invalid type given, the value should be a string",
);
/**
@@ -69,12 +71,18 @@ class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract
*/
public function isValid($value)
{
- $this->_setValue($value);
-
if (!is_string($value)) {
+ $this->_error(self::INVALID);
+ return false;
+ }
+
+ $this->_setValue($value);
+ $result = @preg_match(self::LASTMOD_REGEX, $value);
+ if ($result != 1) {
+ $this->_error(self::NOT_VALID);
return false;
}
- return @preg_match(self::LASTMOD_REGEX, $value) == 1;
+ return true;
}
}
diff --git a/libs/Zend/Validate/Sitemap/Loc.php b/libs/Zend/Validate/Sitemap/Loc.php
index 0ea313f3ba..7e0668f9ff 100644
--- a/libs/Zend/Validate/Sitemap/Loc.php
+++ b/libs/Zend/Validate/Sitemap/Loc.php
@@ -17,7 +17,7 @@
* @subpackage Sitemap
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Loc.php 20358 2010-01-17 19:03:49Z thomas $
+ * @version $Id: Loc.php 21365 2010-03-07 09:38:41Z thomas $
*/
/**
@@ -47,7 +47,8 @@ class Zend_Validate_Sitemap_Loc extends Zend_Validate_Abstract
* Validation key for not valid
*
*/
- const NOT_VALID = 'invalidSitemapLoc';
+ const NOT_VALID = 'sitemapLocNotValid';
+ const INVALID = 'sitemapLocInvalid';
/**
* Validation failure message template definitions
@@ -56,6 +57,7 @@ class Zend_Validate_Sitemap_Loc extends Zend_Validate_Abstract
*/
protected $_messageTemplates = array(
self::NOT_VALID => "'%value%' is no valid sitemap location",
+ self::INVALID => "Invalid type given, the value should be a string",
);
/**
@@ -68,12 +70,18 @@ class Zend_Validate_Sitemap_Loc extends Zend_Validate_Abstract
*/
public function isValid($value)
{
- $this->_setValue($value);
-
if (!is_string($value)) {
+ $this->_error(self::INVALID);
+ return false;
+ }
+
+ $this->_setValue($value);
+ $result = Zend_Uri::check($value);
+ if ($result !== true) {
+ $this->_error(self::NOT_VALID);
return false;
}
- return Zend_Uri::check($value);
+ return true;
}
}
diff --git a/libs/Zend/Validate/Sitemap/Priority.php b/libs/Zend/Validate/Sitemap/Priority.php
index a045daf061..9875ecd20a 100644
--- a/libs/Zend/Validate/Sitemap/Priority.php
+++ b/libs/Zend/Validate/Sitemap/Priority.php
@@ -17,7 +17,7 @@
* @subpackage Sitemap
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Priority.php 20358 2010-01-17 19:03:49Z thomas $
+ * @version $Id: Priority.php 21365 2010-03-07 09:38:41Z thomas $
*/
/**
@@ -42,7 +42,8 @@ class Zend_Validate_Sitemap_Priority extends Zend_Validate_Abstract
* Validation key for not valid
*
*/
- const NOT_VALID = 'invalidSitemapPriority';
+ const NOT_VALID = 'sitemapPriorityNotValid';
+ const INVALID = 'sitemapPriorityInvalid';
/**
* Validation failure message template definitions
@@ -51,6 +52,7 @@ class Zend_Validate_Sitemap_Priority extends Zend_Validate_Abstract
*/
protected $_messageTemplates = array(
self::NOT_VALID => "'%value%' is no valid sitemap priority",
+ self::INVALID => "Invalid type given, the value should be a integer, a float or a numeric string",
);
/**
@@ -63,13 +65,18 @@ class Zend_Validate_Sitemap_Priority extends Zend_Validate_Abstract
*/
public function isValid($value)
{
- $this->_setValue($value);
-
if (!is_numeric($value)) {
+ $this->_error(self::INVALID);
+ return false;
+ }
+
+ $this->_setValue($value);
+ $value = (float) $value;
+ if ($value < 0 || $value > 1) {
+ $this->_error(self::NOT_VALID);
return false;
}
- $value = (float)$value;
- return $value >= 0 && $value <= 1;
+ return true;
}
}