Fix PHP 7.2/7.3 incompatibilites

This commit is contained in:
FiveFilters.org 2019-04-05 00:07:05 +02:00
parent a5a4a192bc
commit 384d52fd83
11 changed files with 63 additions and 90 deletions

View File

@ -30,22 +30,6 @@ error_reporting(E_ALL ^ E_NOTICE);
ini_set("display_errors", 1);
@set_time_limit(120);
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
if (is_array($v)) {
$process[$key][stripslashes($k)] = $v;
$process[] = &$process[$key][stripslashes($k)];
} else {
$process[$key][stripslashes($k)] = stripslashes($v);
}
}
}
unset($process);
}
require_once '../libraries/content-extractor/SiteConfig.php';
////////////////////////////////

View File

@ -147,7 +147,7 @@ if (!is_object($latest_info_json)) {
}
$ff_version = $latest_info_json->pushed_at;
if ($version == $ff_version) {
die('Your site config files are up to date! If you have trouble extracting from a particular site, please email us: help@fivefilters.org');
die('Your site config files are up to date!');
} else {
println("Updated site patterns are available (version $ff_version)...");
}

View File

@ -2,6 +2,9 @@ FiveFilters.org: Full-Text RSS
http://fivefilters.org/content-only/
CHANGELOG
------------------------------------
3.8.2 (unreleased)
- Removed deprecated PHP 7.2 and 7.3 calls
3.8.1 (2017-10-31)
- Bug fix: Systems with old ICU library produced an idn_to_ascii() error
- Compatibility test file updated to check for DOM extension

View File

@ -15,16 +15,16 @@
* @category Zend
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Backend.php 24989 2012-06-21 07:24:13Z mabe $
* @version $Id$
*/
/**
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Cache_Backend
@ -58,12 +58,10 @@ class Zend_Cache_Backend
* Constructor
*
* @param array $options Associative array of options
* @throws Zend_Cache_Exception
* @return void
*/
public function __construct(array $options = array())
{
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
}
@ -269,7 +267,7 @@ class Zend_Cache_Backend
* Log a message at the WARN (4) priority.
*
* @param string $message
* @throws Zend_Cache_Exception
* @param int $priority
* @return void
*/
protected function _log($message, $priority = 4)
@ -287,4 +285,4 @@ class Zend_Cache_Backend
}
$logger->log($message, $priority);
}
}
}

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: File.php 24844 2012-05-31 19:01:36Z rob $
* @version $Id$
*/
/**
@ -25,19 +25,16 @@
*/
//require_once 'Zend/Cache/Backend/ExtendedInterface.php';
require_once dirname(__FILE__).'/ExtendedInterface.php';
/**
* @see Zend_Cache_Backend
*/
//require_once 'Zend/Cache/Backend.php';
require_once realpath(dirname(__FILE__).'/..').DIRECTORY_SEPARATOR.'Backend.php';
/**
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_Backend_ExtendedInterface
@ -123,7 +120,6 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
*
* @param array $options associative array of options
* @throws Zend_Cache_Exception
* @return void
*/
public function __construct(array $options = array())
{
@ -237,10 +233,10 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
* Note : $data is always "string" (serialization is done by the
* core not by the backend)
*
* @param string $data Datas to cache
* @param string $id Cache id
* @param array $tags Array of strings, the cache record will be tagged by each string entry
* @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
* @param string $data Datas to cache
* @param string $id Cache id
* @param array $tags Array of strings, the cache record will be tagged by each string entry
* @param boolean|int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
* @return boolean true if no problem
*/
public function save($data, $id, $tags = array(), $specificLifetime = false)
@ -306,7 +302,7 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
* ($tags can be an array of strings or a single string)
*
* @param string $mode clean mode
* @param tags array $tags array of tags
* @param array $tags array of tags
* @return boolean true if no problem
*/
public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
@ -678,14 +674,17 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
// On some systems it is impossible to distinguish between empty match and an error.
return true;
}
$metadataFiles = array();
foreach ($glob as $file) {
if (is_file($file)) {
$fileName = basename($file);
if ($this->_isMetadatasFile($fileName)) {
// in CLEANING_MODE_ALL, we drop anything, even remainings old metadatas files
if ($mode != Zend_Cache::CLEANING_MODE_ALL) {
continue;
// In CLEANING_MODE_ALL, we drop anything, even remainings old metadatas files.
// To do that, we need to save the list of the metadata files first.
if ($mode == Zend_Cache::CLEANING_MODE_ALL) {
$metadataFiles[] = $file;
}
continue;
}
$id = $this->_fileNameToId($fileName);
$metadatas = $this->_getMetadatas($id);
@ -694,12 +693,7 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
}
switch ($mode) {
case Zend_Cache::CLEANING_MODE_ALL:
$res = $this->remove($id);
if (!$res) {
// in this case only, we accept a problem with the metadatas file drop
$res = $this->_remove($file);
}
$result = $result && $res;
$result = $result && $this->remove($id);
break;
case Zend_Cache::CLEANING_MODE_OLD:
if (time() > $metadatas['expire']) {
@ -756,6 +750,14 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
}
}
}
// cycle through metadataFiles and delete orphaned ones
foreach ($metadataFiles as $file) {
if (file_exists($file)) {
$result = $this->_remove($file) && $result;
}
}
return $result;
}
@ -846,6 +848,7 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
/**
* Compute & return the expire time
*
* @param int $lifetime
* @return int expire time (unix timestamp)
*/
protected function _expireTime($lifetime)
@ -1031,4 +1034,4 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
return preg_replace('~^' . $prefix . '---(.*)$~', '$1', $fileName);
}
}
}

View File

@ -14,15 +14,15 @@
*
* @category Zend
* @package Zend_Cache
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Core.php 24989 2012-06-21 07:24:13Z mabe $
* @version $Id$
*/
/**
* @package Zend_Cache
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Cache_Core
@ -143,7 +143,7 @@ class Zend_Cache_Core
Zend_Cache::throwException("Options passed were not an array"
. " or Zend_Config instance.");
}
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
$this->_loggerSanity();
@ -158,7 +158,7 @@ class Zend_Cache_Core
public function setConfig(Zend_Config $config)
{
$options = $config->toArray();
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}
return $this;
@ -300,7 +300,7 @@ class Zend_Cache_Core
}
$id = $this->_id($id); // cache id may need prefix
$this->_lastId = $id;
self::_validateIdOrTag($id);
$this->_validateIdOrTag($id);
$this->_log("Zend_Cache_Core: load item '{$id}'", 7);
$data = $this->_backend->load($id, $doNotTestCacheValidity);
@ -327,7 +327,7 @@ class Zend_Cache_Core
return false;
}
$id = $this->_id($id); // cache id may need prefix
self::_validateIdOrTag($id);
$this->_validateIdOrTag($id);
$this->_lastId = $id;
$this->_log("Zend_Cache_Core: test item '{$id}'", 7);
@ -355,8 +355,8 @@ class Zend_Cache_Core
} else {
$id = $this->_id($id);
}
self::_validateIdOrTag($id);
self::_validateTagsArray($tags);
$this->_validateIdOrTag($id);
$this->_validateTagsArray($tags);
if ($this->_options['automatic_serialization']) {
// we need to serialize datas before storing them
$data = serialize($data);
@ -424,7 +424,7 @@ class Zend_Cache_Core
return true;
}
$id = $this->_id($id); // cache id may need prefix
self::_validateIdOrTag($id);
$this->_validateIdOrTag($id);
$this->_log("Zend_Cache_Core: remove item '{$id}'", 7);
return $this->_backend->remove($id);
@ -460,7 +460,7 @@ class Zend_Cache_Core
Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG))) {
Zend_Cache::throwException('Invalid cleaning mode');
}
self::_validateTagsArray($tags);
$this->_validateTagsArray($tags);
return $this->_backend->clean($mode, $tags);
}
@ -667,7 +667,7 @@ class Zend_Cache_Core
* @throws Zend_Cache_Exception
* @return void
*/
protected static function _validateIdOrTag($string)
protected function _validateIdOrTag($string)
{
if (!is_string($string)) {
Zend_Cache::throwException('Invalid id or tag : must be a string');
@ -689,13 +689,13 @@ class Zend_Cache_Core
* @throws Zend_Cache_Exception
* @return void
*/
protected static function _validateTagsArray($tags)
protected function _validateTagsArray($tags)
{
if (!is_array($tags)) {
Zend_Cache::throwException('Invalid tags array : must be an array');
}
foreach($tags as $tag) {
self::_validateIdOrTag($tag);
$this->_validateIdOrTag($tag);
}
reset($tags);
}
@ -762,4 +762,4 @@ class Zend_Cache_Core
return $id; // no prefix, just return the $id passed
}
}
}

View File

@ -21,8 +21,8 @@ define('JSONP', 3);
class FeedWriter
{
private $self = null; // self URL - http://feed2.w3.org/docs/warning/MissingAtomSelfLink.html
private $alternate = array(); // alternate URL and title
private $related = array(); // related URL and title
private $alternate = null; // alternate URL and title
private $related = null; // related URL and title
private $hubs = array(); // PubSubHubbub hubs
private $channels = array(); // Collection of channel elements
private $items = array(); // Collection of items as object of FeedItem class.

View File

@ -311,10 +311,10 @@ class HumbleHttpAgent
public function validateUrl($url) {
$url = filter_var($url, FILTER_SANITIZE_URL);
$test = filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED);
$test = filter_var($url, FILTER_VALIDATE_URL);
// deal with bug http://bugs.php.net/51192 (present in PHP 5.2.13 and PHP 5.3.2)
if ($test === false) {
$test = filter_var(strtr($url, '-', '_'), FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED);
$test = filter_var(strtr($url, '-', '_'), FILTER_VALIDATE_URL);
}
if ($test !== false && $test !== null && preg_match('!^https?://!', $url)) {
return $url;

View File

@ -71,10 +71,10 @@ class HumbleHttpAgentDummy
public function validateUrl($url) {
$url = filter_var($url, FILTER_SANITIZE_URL);
$test = filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED);
$test = filter_var($url, FILTER_VALIDATE_URL);
// deal with bug http://bugs.php.net/51192 (present in PHP 5.2.13 and PHP 5.3.2)
if ($test === false) {
$test = filter_var(strtr($url, '-', '_'), FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED);
$test = filter_var(strtr($url, '-', '_'), FILTER_VALIDATE_URL);
}
if ($test !== false && $test !== null && preg_match('!^https?://!', $url)) {
return $url;

View File

@ -42,23 +42,6 @@ if (_FF_FTR_MODE === 'simple') {
$_REQUEST = $_GET;
}
// Deal with magic quotes
if (get_magic_quotes_gpc()) {
$process = array(&$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
if (is_array($v)) {
$process[$key][stripslashes($k)] = $v;
$process[] = &$process[$key][stripslashes($k)];
} else {
$process[$key][stripslashes($k)] = stripslashes($v);
}
}
}
unset($process);
}
// set include path
set_include_path(realpath(dirname(__FILE__).'/libraries').PATH_SEPARATOR.get_include_path());
// Autoloading of classes allows us to include files only when they're
@ -1268,10 +1251,10 @@ function validate_url($url) {
}
}
$url = filter_var($url, FILTER_SANITIZE_URL);
$test = filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED);
$test = filter_var($url, FILTER_VALIDATE_URL);
// deal with bug http://bugs.php.net/51192 (present in PHP 5.2.13 and PHP 5.3.2)
if ($test === false) {
$test = filter_var(strtr($url, '-', '_'), FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED);
$test = filter_var(strtr($url, '-', '_'), FILTER_VALIDATE_URL);
}
if ($test !== false && $test !== null && preg_match('!^https?://!i', $url)) {
return $url;

View File

@ -1,4 +1,6 @@
# Puppet file intended to install server componenets for FiveFilters.org web services
# Puppet file intended to install server componenets for FiveFilters.org web services.
# This file should only be run once when setting up a new server to run Full-Text RSS.
# See http://help.fivefilters.org/customer/portal/articles/1143210-hosting for more information.
# This file is intended for base images of:
# Ubuntu 16.04
@ -164,8 +166,8 @@ class php_pecl_http {
ensure => present,
#owner => root, group => root, mode => 444,
content => "; priority=25
extension=raphf.so
extension=propro.so
;extension=raphf.so
;extension=propro.so
extension=http.so",
before => [Exec["install-http-pecl"], Exec["enable-http"]],
require => Class["php"]