Permalink
Browse files

updating Zend engine to 1.5.0

  • Loading branch information...
1 parent 3ae9e88 commit ab42d25ac1eb650d516976af9db532e7eb551288 diml committed Apr 7, 2008
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Search_Lucene
+ * @subpackage Analysis
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+
+/** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8 */
+require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8.php';
+
+/** Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 */
+require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php';
+
+
+/**
+ * @category Zend
+ * @package Zend_Search_Lucene
+ * @subpackage Analysis
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+
+class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive extends Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8
+{
+ public function __construct()
+ {
+ parent::__construct();
+
+ $this->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8());
+ }
+}
+
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Search_Lucene
+ * @subpackage Analysis
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+
+/** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num */
+require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php';
+
+/** Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 */
+require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php';
+
+
+/**
+ * @category Zend
+ * @package Zend_Search_Lucene
+ * @subpackage Analysis
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+
+class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive extends Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num
+{
+ public function __construct()
+ {
+ parent::__construct();
+
+ $this->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8());
+ }
+}
+
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Search_Lucene
+ * @subpackage Analysis
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+
+/** Zend_Search_Lucene_Analysis_TokenFilter */
+require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php';
+
+
+/**
+ * Lower case Token filter.
+ *
+ * @category Zend
+ * @package Zend_Search_Lucene
+ * @subpackage Analysis
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+class Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 extends Zend_Search_Lucene_Analysis_TokenFilter
+{
+ /**
+ * Object constructor
+ */
+ public function __construct()
+ {
+ if (!function_exists('mb_strtolower')) {
+ // mbstring extension is disabled
+ require_once 'Zend/Search/Lucene/Exception.php';
+ throw new Zend_Search_Lucene_Exception('Utf8 compatible lower case filter needs mbstring extension to be enabled.');
+ }
+ }
+
+ /**
+ * Normalize Token or remove it (if null is returned)
+ *
+ * @param Zend_Search_Lucene_Analysis_Token $srcToken
+ * @return Zend_Search_Lucene_Analysis_Token
+ */
+ public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
+ {
+ $newToken = new Zend_Search_Lucene_Analysis_Token(
+ mb_strtolower($srcToken->getTermText(), 'UTF-8'),
+ $srcToken->getStartOffset(),
+ $srcToken->getEndOffset());
+
+ $newToken->setPositionIncrement($srcToken->getPositionIncrement());
+
+ return $newToken;
+ }
+}
+
@@ -1,32 +0,0 @@
-<?php
-
-class EncodingConverter {
- private $last_error,
- $in_encoding,
- $out_encoding;
-
- function __construct($in_encoding, $out_encoding) {
- $this->in_encoding = $in_encoding;
- $this->out_encoding = $out_encoding;
- } //constructor
-
- function handleError($err, $msg) {
- $this->last_error = $msg;
- } //handleError
-
- function convert($str) {
- $this->last_error = FALSE;
-
- set_error_handler(array(&$this, 'handleError'));
- $ret = iconv($this->in_encoding, $this->out_encoding, $str);
- restore_error_handler();
-
- return $ret;
- } //convert
-
- function getLastError() {
- return $this->last_error;
- } //getLastError
-} //EncodingConverter
-
-?>
@@ -0,0 +1,161 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Search_Lucene
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+
+/** Zend_Search_Lucene_Exception */
+require_once 'Zend/Search/Lucene/Exception.php';
+
+/** Zend_Search_Lucene_Storage_Directory */
+require_once 'Zend/Search/Lucene/Storage/Directory.php';
+
+/** Zend_Search_Lucene_Storage_File */
+require_once 'Zend/Search/Lucene/Storage/File.php';
+
+
+
+/**
+ * This is an utility class which provides index locks processing functionality
+ *
+ * @category Zend
+ * @package Zend_Search_Lucene
+ * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Search_Lucene_LockManager
+{
+ const WRITE_LOCK_FILE = 'write.lock.file';
+ const READ_LOCK_FILE = 'read.lock.file';
+ const OPTIMIZATION_LOCK_FILE = 'optimization.lock.file';
+
+ /**
+ * Obtain exclusive write lock on the index
+ *
+ * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+ * @return Zend_Search_Lucene_Storage_File
+ * @throws Zend_Search_Lucene_Exception
+ */
+ public static function obtainWriteLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+ {
+ $lock = $lockDirectory->createFile(self::WRITE_LOCK_FILE);
+ if (!$lock->lock(LOCK_EX)) {
+ throw new Zend_Search_Lucene_Exception('Can\'t obtain exclusive index lock');
+ }
+ return $lock;
+ }
+
+ /**
+ * Release exclusive write lock
+ *
+ * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+ */
+ public static function releaseWriteLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+ {
+ $lock = $lockDirectory->getFileObject(self::WRITE_LOCK_FILE);
+ $lock->unlock();
+ }
+
+ /**
+ * Obtain shared read lock on the index
+ *
+ * It doesn't block other read or update processes, but prevent index from the premature cleaning-up
+ *
+ * @param Zend_Search_Lucene_Storage_Directory $defaultLockDirectory
+ * @return Zend_Search_Lucene_Storage_File
+ * @throws Zend_Search_Lucene_Exception
+ */
+ public static function obtainReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+ {
+ $lock = $lockDirectory->createFile(self::READ_LOCK_FILE);
+ if (!$lock->lock(LOCK_SH)) {
+ throw new Zend_Search_Lucene_Exception('Can\'t obtain shared reading index lock');
+ }
+ return $lock;
+ }
+
+ /**
+ * Release shared read lock
+ *
+ * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+ */
+ public static function releaseReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+ {
+ $lock = $lockDirectory->getFileObject(self::READ_LOCK_FILE);
+ $lock->unlock();
+ }
+
+ /**
+ * Escalate Read lock to exclusive level
+ *
+ * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+ * @return boolean
+ */
+ public static function escalateReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+ {
+ $lock = $lockDirectory->getFileObject(self::READ_LOCK_FILE);
+
+ // Try to escalate read lock
+ if (!$lock->lock(LOCK_EX, true)) {
+ // Restore lock state
+ $lock->lock(LOCK_SH);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * De-escalate Read lock to shared level
+ *
+ * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+ */
+ public static function deEscalateReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+ {
+ $lock = $lockDirectory->getFileObject(self::READ_LOCK_FILE);
+ $lock->lock(LOCK_SH);
+ }
+
+ /**
+ * Obtain exclusive optimization lock on the index
+ *
+ * Returns lock object on success and false otherwise (doesn't block execution)
+ *
+ * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+ * @return mixed
+ */
+ public static function obtainOptimizationLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+ {
+ $lock = $lockDirectory->createFile(self::OPTIMIZATION_LOCK_FILE);
+ if (!$lock->lock(LOCK_EX, true)) {
+ return false;
+ }
+ return $lock;
+ }
+
+ /**
+ * Release exclusive optimization lock
+ *
+ * @param Zend_Search_Lucene_Storage_Directory $lockDirectory
+ */
+ public static function releaseOptimizationLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
+ {
+ $lock = $lockDirectory->getFileObject(self::OPTIMIZATION_LOCK_FILE);
+ $lock->unlock();
+ }
+
+}
Oops, something went wrong.

0 comments on commit ab42d25

Please sign in to comment.