From 08eab6cd73bf177e227df21753ab699334b47ea8 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 8 May 2013 08:02:09 +0200 Subject: php-horde-Horde-Date: upstream patch for preg_replace --- php-horde-Horde-Date.patch | 122 +++++++++++++++++++++++++++++++++++++++++++++ php-horde-Horde-Date.spec | 12 +++-- 2 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 php-horde-Horde-Date.patch diff --git a/php-horde-Horde-Date.patch b/php-horde-Horde-Date.patch new file mode 100644 index 0000000..404f1da --- /dev/null +++ b/php-horde-Horde-Date.patch @@ -0,0 +1,122 @@ +From 4b952e67b5720a1aaa6b605c997547238b00c642 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Tue, 7 May 2013 19:13:51 +0200 +Subject: [PATCH] use preg_replace_callback() instead of preg_replace() with + deprecated /e modifier + +--- + framework/Date/lib/Horde/Date.php | 92 ++++++++++++++++++++------------------- + 1 file changed, 48 insertions(+), 44 deletions(-) + +diff --git a/framework/Date/lib/Horde/Date.php b/framework/Date/lib/Horde/Date.php +index f412252..bdc6562 100644 +--- a/framework/Date/lib/Horde/Date.php ++++ b/framework/Date/lib/Horde/Date.php +@@ -893,56 +893,60 @@ public function strftime($format) + } + + /** ++ * Callback used to remplace a strtime pattern ++ * ++ * @param array $matches preg_replace_callback() matches. ++ * ++ * @return string Replacement string. ++ */ ++ protected function _regexCallback($reg) ++ { ++ switch ($reg[0]) { ++ case '%b': return $this->strftime(Horde_Nls::getLangInfo(constant('ABMON_' . (int)$this->_month))); ++ case '%B': return $this->strftime(Horde_Nls::getLangInfo(constant('MON_' . (int)$this->_month))); ++ case '%C': return (int)($this->_year / 100); ++ case '%-d': ++ case '%#d': return sprintf('%d', $this->_mday); ++ case '%d': return sprintf('%02d', $this->_mday); ++ case '%D': return $this->strftime('%m/%d/%y'); ++ case '%e': return sprintf('%2d', $this->_mday); ++ case '%-H': ++ case '%#H': return sprintf('%d', $this->_hour); ++ case '%H': return sprintf('%02d', $this->_hour); ++ case '%-I': ++ case '%#I': return sprintf('%d', $this->_hour == 0 ? 12 : ($this->_hour > 12 ? $this->_hour - 12 : $this->_hour)); ++ case '%I': return sprintf('%02d', $this->_hour == 0 ? 12 : ($this->_hour > 12 ? $this->_hour - 12 : $this->_hour)); ++ case '%-m': ++ case '%#m': return sprintf('%d', $this->_month); ++ case '%m': return sprintf('%02d', $this->_month); ++ case '%-M': ++ case '%#M': return sprintf('%d', $this->_min); ++ case '%M': return sprintf('%02d', $this->_min); ++ case '%n': return "\n"; ++ case '%p': return $this->strftime(Horde_Nls::getLangInfo($this->_hour < 12 ? AM_STR : PM_STR)); ++ case '%R': return $this->strftime('%H:%M'); ++ case '%-S': ++ case '%#S': return sprintf('%d', $this->_sec); ++ case '%S': return sprintf('%02d', $this->_sec); ++ case '%t': return "\t"; ++ case '%T': return $this->strftime('%H:%M:%S'); ++ case '%x': return $this->strftime(Horde_Nls::getLangInfo(D_FMT)); ++ case '%X': return $this->strftime(Horde_Nls::getLangInfo(T_FMT)); ++ case '%y': return substr(sprintf('%04d', $this->_year), -2); ++ case '%Y': return (int)$this->_year; ++ case '%%': return '%'; ++ } ++ return $reg[0]; ++ } ++ ++ /** + * Formats date and time using a limited set of the strftime() format. + * + * @return string strftime() formatted date and time. + */ + protected function _strftime($format) + { +- return preg_replace( +- array('/%b/e', +- '/%B/e', +- '/%C/e', +- '/%([-#]?)d/e', +- '/%D/e', +- '/%e/e', +- '/%([-#]?)H/e', +- '/%([-#]?)I/e', +- '/%([-#]?)m/e', +- '/%([-#]?)M/e', +- '/%n/', +- '/%p/e', +- '/%R/e', +- '/%([-#]?)S/e', +- '/%t/', +- '/%T/e', +- '/%x/e', +- '/%X/e', +- '/%y/e', +- '/%Y/', +- '/%%/'), +- array('$this->strftime(Horde_Nls::getLangInfo(constant(\'ABMON_\' . (int)$this->_month)))', +- '$this->strftime(Horde_Nls::getLangInfo(constant(\'MON_\' . (int)$this->_month)))', +- '(int)($this->_year / 100)', +- 'sprintf(\'%\' . (\'$1\' ? \'\' : \'02\') . \'d\', $this->_mday)', +- '$this->strftime(\'%m/%d/%y\')', +- 'sprintf(\'%2d\', $this->_mday)', +- 'sprintf(\'%\' . (\'$1\' ? \'\' : \'02\') . \'d\', $this->_hour)', +- 'sprintf(\'%\' . (\'$1\' ? \'\' : \'02\') . \'d\', $this->_hour == 0 ? 12 : ($this->_hour > 12 ? $this->_hour - 12 : $this->_hour))', +- 'sprintf(\'%\' . (\'$1\' ? \'\' : \'02\') . \'d\', $this->_month)', +- 'sprintf(\'%\' . (\'$1\' ? \'\' : \'02\') . \'d\', $this->_min)', +- "\n", +- '$this->strftime(Horde_Nls::getLangInfo($this->_hour < 12 ? AM_STR : PM_STR))', +- '$this->strftime(\'%H:%M\')', +- 'sprintf(\'%\' . (\'$1\' ? \'\' : \'02\') . \'d\', $this->_sec)', +- "\t", +- '$this->strftime(\'%H:%M:%S\')', +- '$this->strftime(Horde_Nls::getLangInfo(D_FMT))', +- '$this->strftime(Horde_Nls::getLangInfo(T_FMT))', +- 'substr(sprintf(\'%04d\', $this->_year), -2)', +- (int)$this->_year, +- '%'), +- $format); ++ return preg_replace_callback('/(%([-#]?)[%bBCdDeHImMnpRStTxXyY])/', array($this, '_regexCallback'), $format); + } + + /** +-- +1.8.1.6 + diff --git a/php-horde-Horde-Date.spec b/php-horde-Horde-Date.spec index d7926de..957b50b 100644 --- a/php-horde-Horde-Date.spec +++ b/php-horde-Horde-Date.spec @@ -7,7 +7,7 @@ Name: php-horde-Horde-Date Version: 2.0.5 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Horde Date package Group: Development/Libraries @@ -15,6 +15,9 @@ License: LGPLv2 URL: http://%{pear_channel} Source0: http://%{pear_channel}/get/%{pear_name}-%{version}.tgz +# preg_replace() /e is deprecated +Patch0: %{name}.patch + BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildArch: noarch BuildRequires: php-pear(PEAR) >= 1.7.0 @@ -57,9 +60,7 @@ Package for creating and manipulating dates. cd %{pear_name}-%{version} -# Silent warning for preg_replace(): The /e modifier is deprecated -sed -e 's/preg_replace/@preg_replace/' \ - -i lib/Horde/Date.php +%patch0 -p3 -b .callback # Don't install .po and .pot files # Remove checksum for .mo, as we regenerate them @@ -134,6 +135,9 @@ fi %changelog +* Wed May 08 2013 Remi Collet - 2.0.5-2 +- upstream patch for preg_replace + * Tue May 07 2013 Remi Collet - 2.0.5-1 - Update to 2.0.5 -- cgit