From e1c6ea99720ec4f1f22eca2b28e3fc420ef26c68 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 13 Oct 2017 12:59:47 +0200 Subject: add upstream patch for PHP 7.2, FTBFS from Koschei --- .gitignore | 8 + b452b5aa962b21316492c762639b6b4b659c8c6e.patch | 193 +++++++++++++++++++++++++ php-horde-Horde-Date-Parser.spec | 37 +++-- 3 files changed, 218 insertions(+), 20 deletions(-) create mode 100644 .gitignore create mode 100644 b452b5aa962b21316492c762639b6b4b659c8c6e.patch diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fc9aa8c --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +clog +package-*.xml +*.tgz +*.tar.gz +*.tar.xz +*.tar.xz.asc +*.src.rpm +*/*rpm diff --git a/b452b5aa962b21316492c762639b6b4b659c8c6e.patch b/b452b5aa962b21316492c762639b6b4b659c8c6e.patch new file mode 100644 index 0000000..c0fe317 --- /dev/null +++ b/b452b5aa962b21316492c762639b6b4b659c8c6e.patch @@ -0,0 +1,193 @@ +From b452b5aa962b21316492c762639b6b4b659c8c6e Mon Sep 17 00:00:00 2001 +From: Jan Schneider +Date: Mon, 13 Feb 2017 18:38:59 +0100 +Subject: [PATCH] Don't use create_function(). + +It's deprecated and unsafe and closures should be used instead. +--- + lib/Horde/Date/Parser.php | 13 ++++++++++++- + lib/Horde/Date/Parser/Locale/Base.php | 31 +++++++++++++++++++++++++------ + lib/Horde/Date/Parser/Locale/Pt.php | 4 +++- + lib/Horde/Date/Parser/Result.php | 16 ++++++++++++---- + lib/Horde/Date/Parser/Token.php | 14 ++++++++++++-- + 5 files changed, 64 insertions(+), 14 deletions(-) + +diff --git a/lib/Horde/Date/Parser.php b/lib/Horde/Date/Parser.php +index b297932..29c542e 100644 +--- a/lib/Horde/Date/Parser.php ++++ b/lib/Horde/Date/Parser.php +@@ -44,7 +44,18 @@ public static function getLocales() + foreach (new DirectoryIterator($dir) as $f) { + if ($f->isFile()) { + $locale = str_replace('.php', '', $f->getFilename()); +- $locale = preg_replace_callback('/([A-Z][a-z]*)([A-Z].*)?/', create_function('$m', 'if (!isset($m[2])) { return Horde_String::lower($m[1]); } else { return Horde_String::lower($m[1]) . "_" . Horde_String::upper($m[2]); }'), $locale); ++ $locale = preg_replace_callback( ++ '/([A-Z][a-z]*)([A-Z].*)?/', ++ function ($m) { ++ if (!isset($m[2])) { ++ return Horde_String::lower($m[1]); ++ } else { ++ return Horde_String::lower($m[1]) ++ . '_' . Horde_String::upper($m[2]); ++ } ++ }, ++ $locale ++ ); + $locales[] = $locale; + } + } +diff --git a/lib/Horde/Date/Parser/Locale/Base.php b/lib/Horde/Date/Parser/Locale/Base.php +index 882e0fc..647b2fc 100644 +--- a/lib/Horde/Date/Parser/Locale/Base.php ++++ b/lib/Horde/Date/Parser/Locale/Base.php +@@ -97,7 +97,9 @@ public function parse($text, $specifiedOptions = array()) + } + + // strip any non-tagged tokens +- $taggedTokens = array_values(array_filter($tokens, create_function('$t', 'return $t->tagged();'))); ++ $taggedTokens = array_values(array_filter( ++ $tokens, function ($t) { return $t->tagged(); } ++ )); + + // Remove tokens we know we don't want - for example, if the first token + // is a separator, drop it. +@@ -197,7 +199,10 @@ public function numericizeOrdinals($text) + */ + public function preTokenize($text) + { +- return array_map(create_function('$w', 'return new Horde_Date_Parser_Token($w);'), preg_split('/\s+/', $text)); ++ return array_map( ++ function ($w) { return new Horde_Date_Parser_Token($w); }, ++ preg_split('/\s+/', $text) ++ ); + } + + /** +@@ -292,7 +297,9 @@ public function tokensToSpan($tokens, $options) + // maybe it's a specific date + foreach ($this->definitions['date'] as $handler) { + if ($handler->match($tokens, $this->definitions)) { +- $goodTokens = array_values(array_filter($tokens, create_function('$o', 'return !$o->getTag("separator");'))); ++ $goodTokens = array_values(array_filter( ++ $tokens, function ($o) { return !$o->getTag('separator'); } ++ )); + $this->debug($handler->handlerMethod, $goodTokens, $options); + return call_user_func(array($this, $handler->handlerMethod), $goodTokens, $options); + } +@@ -301,7 +308,9 @@ public function tokensToSpan($tokens, $options) + // I guess it's not a specific date, maybe it's just an anchor + foreach ($this->definitions['anchor'] as $handler) { + if ($handler->match($tokens, $this->definitions)) { +- $goodTokens = array_values(array_filter($tokens, create_function('$o', 'return !$o->getTag("separator");'))); ++ $goodTokens = array_values(array_filter( ++ $tokens, function ($o) { return !$o->getTag('separator'); } ++ )); + $this->debug($handler->handlerMethod, $goodTokens, $options); + return call_user_func(array($this, $handler->handlerMethod), $goodTokens, $options); + } +@@ -310,7 +319,14 @@ public function tokensToSpan($tokens, $options) + // not an anchor, perhaps it's an arrow + foreach ($this->definitions['arrow'] as $handler) { + if ($handler->match($tokens, $this->definitions)) { +- $goodTokens = array_values(array_filter($tokens, create_function('$o', 'return !$o->getTag("separator_at") && !$o->getTag("separator_slash_or_dash") && !$o->getTag("separator_comma");'))); ++ $goodTokens = array_values(array_filter( ++ $tokens, ++ function ($o) { ++ return !$o->getTag('separator_at') && ++ !$o->getTag('separator_slash_or_dash') && ++ !$o->getTag('separator_comma'); ++ } ++ )); + $this->debug($handler->handlerMethod, $goodTokens, $options); + return call_user_func(array($this, $handler->handlerMethod), $goodTokens, $options); + } +@@ -603,7 +619,10 @@ public function getRepeaters($tokens) + } + + // Return repeaters in order from widest (years) to smallest (seconds) +- usort($repeaters, create_function('$a, $b', 'return $b->width() > $a->width();')); ++ usort( ++ $repeaters, ++ function ($a, $b) { return $b->width() > $a->width(); } ++ ); + return $repeaters; + } + +diff --git a/lib/Horde/Date/Parser/Locale/Pt.php b/lib/Horde/Date/Parser/Locale/Pt.php +index 79d43b3..f5f2e40 100644 +--- a/lib/Horde/Date/Parser/Locale/Pt.php ++++ b/lib/Horde/Date/Parser/Locale/Pt.php +@@ -100,7 +100,9 @@ public function parse($text, $specifiedOptions = array()) + } + + // strip any non-tagged tokens +- $taggedTokens = array_values(array_filter($tokens, create_function('$t', 'return $t->tagged();'))); ++ $taggedTokens = array_values(array_filter( ++ $tokens, function ($t) { return $t->tagged(); } ++ )); + + // Remove tokens we know we don't want - for example, if the first + // token is a separator, drop it. +diff --git a/lib/Horde/Date/Parser/Result.php b/lib/Horde/Date/Parser/Result.php +index 415b77c..859d14a 100644 +--- a/lib/Horde/Date/Parser/Result.php ++++ b/lib/Horde/Date/Parser/Result.php +@@ -28,14 +28,22 @@ public function guess() + + public function taggedText() + { +- $taggedTokens = array_values(array_filter($this->tokens, create_function('$t', 'return $t->tagged();'))); +- return implode(' ', array_map(create_function('$t', 'return $t->word;'), $taggedTokens)); ++ $taggedTokens = array_values(array_filter( ++ $this->tokens, function ($t) { return $t->tagged(); } ++ )); ++ return implode( ++ ' ', array_map(function ($t) { return $t->word; }, $taggedTokens) ++ ); + } + + public function untaggedText() + { +- $untaggedTokens = array_values(array_filter($this->tokens, create_function('$t', 'return ! $t->tagged();'))); +- return implode(' ', array_map(create_function('$t', 'return $t->word;'), $untaggedTokens)); ++ $untaggedTokens = array_values(array_filter( ++ $this->tokens, function ($t) { return !$t->tagged(); } ++ )); ++ return implode( ++ ' ', array_map(function ($t) { return $t->word; }, $untaggedTokens) ++ ); + } + + } +diff --git a/lib/Horde/Date/Parser/Token.php b/lib/Horde/Date/Parser/Token.php +index 39aeca4..5e88d74 100644 +--- a/lib/Horde/Date/Parser/Token.php ++++ b/lib/Horde/Date/Parser/Token.php +@@ -23,7 +23,12 @@ public function tag($tagClass, $tag) + */ + public function untag($tagClass) + { +- $this->tags = array_filter($this->tags, create_function('$t', 'return substr($t[0], 0, ' . strlen($tagClass) . ') != "' . $tagClass . '";')); ++ $this->tags = array_filter( ++ $this->tags, ++ function ($t) use ($tagClass) { ++ return substr($t[0], 0, strlen($tagClass)) != $tagClass; ++ } ++ ); + } + + /** +@@ -39,7 +44,12 @@ public function tagged() + */ + public function getTag($tagClass) + { +- $matches = array_filter($this->tags, create_function('$t', 'return substr($t[0], 0, ' . strlen($tagClass) . ') == "' . $tagClass . '";')); ++ $matches = array_filter( ++ $this->tags, ++ function ($t) use ($tagClass) { ++ return substr($t[0], 0, strlen($tagClass)) == $tagClass; ++ } ++ ); + $match = array_shift($matches); + return $match[1]; + } diff --git a/php-horde-Horde-Date-Parser.spec b/php-horde-Horde-Date-Parser.spec index 23c023a..6cba16f 100644 --- a/php-horde-Horde-Date-Parser.spec +++ b/php-horde-Horde-Date-Parser.spec @@ -12,7 +12,7 @@ Name: php-horde-Horde-Date-Parser Version: 2.0.6 -Release: 1%{?dist} +Release: 4%{?dist} Summary: Horde Date Parser Group: Development/Libraries @@ -20,7 +20,8 @@ License: LGPLv2 URL: http://pear.horde.org Source0: http://%{pear_channel}/get/%{pear_name}-%{version}.tgz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +Patch0: https://github.com/horde/Date_Parser/commit/b452b5aa962b21316492c762639b6b4b659c8c6e.patch + BuildArch: noarch BuildRequires: php(language) >= 5.3.0 BuildRequires: php-pear(PEAR) >= 1.7.0 @@ -54,9 +55,12 @@ languages and locales %prep %setup -q -c - cd %{pear_name}-%{version} -mv ../package.xml %{name}.xml +%patch0 -p1 -b .upstream + +sed -e '/Parser/s/md5sum=.*name=/name=/' \ + ../package.xml >%{name}.xml +touch -r ../package.xml %{name}.xml %build @@ -79,21 +83,12 @@ install -pm 644 %{name}.xml %{buildroot}%{pear_xmldir} %check cd %{pear_name}-%{version}/test/$(echo %{pear_name} | sed -e s:_:/:g) -# remirepo:11 -run=0 ret=0 -if which php56; then - php56 %{_bindir}/phpunit . || ret=1 - run=1 -fi -if which php71; then - php71 %{_bindir}/phpunit . || ret=1 - run=1 -fi -if [ $run -eq 0 ]; then -%{_bindir}/phpunit --verbose . -# remirepo:2 -fi +for cmd in php php56 php70 php71 php72; do + if which $cmd; then + $cmd %{_bindir}/phpunit . || ret=1 + fi +done exit $ret @@ -109,15 +104,17 @@ fi %files -%defattr(-,root,root,-) %doc %{pear_docdir}/%{pear_name} %{pear_xmldir}/%{name}.xml %{pear_phpdir}/Horde/Date/Parser %{pear_phpdir}/Horde/Date/Parser.php -%{pear_testdir}/%{pear_name} +%doc %{pear_testdir}/%{pear_name} %changelog +* Fri Oct 13 2017 Remi Collet - 2.0.6-4 +- add upstream patch for PHP 7.2, FTBFS from Koschei + * Wed Jul 13 2016 Remi Collet - 2.0.6-1 - Update to 2.0.6 -- cgit