Comments (4)
Assuming you don't want to force PHP8 at his stage, I'd recommend using the #[\ReturnTypeWillChange]
attribute on all the affected methods to suppress. Otherwise, if you update the declarations, it will fatal error in PHP7.4.
from wp-update-server.
Thank you for the report. I'd like to fix all of these minor PHP 8 compatibility issues at some point, but I'm busy with another project at the moment. I'll leave the issue open for now.
from wp-update-server.
same here, @YahnisElsts please fix it.
Thank you
Here is a quick fix until the owner updates his package: Replace the includes\Wpup\Header.php with this code:
<?php
class Wpup_Headers implements ArrayAccess, IteratorAggregate, Countable {
protected $headers = array();
/**
* HTTP headers stored in the $_SERVER array are usually prefixed with "HTTP_" or "X_".
* These special headers don't have that prefix, so we need an explicit list to identify them.
*
* @var array
*/
protected static $unprefixedNames = array(
'CONTENT_TYPE',
'CONTENT_LENGTH',
'PHP_AUTH_USER',
'PHP_AUTH_PW',
'PHP_AUTH_DIGEST',
'AUTH_TYPE'
);
public function __construct($headers = array()) {
foreach ($headers as $name => $value) {
$this->set($name, $value);
}
}
/**
* Extract HTTP headers from an array of data (usually $_SERVER).
*
* @param array $environment
* @return array
*/
public static function parse($environment) {
$results = array();
foreach ($environment as $key => $value) {
$key = strtoupper($key);
if ( self::isHeaderName($key) ) {
//Remove the "HTTP_" prefix that PHP adds to headers stored in $_SERVER.
$key = preg_replace('/^HTTP[_-]/', '', $key);
$results[$key] = $value;
}
}
return $results;
}
/**
* Check if a $_SERVER key looks like a HTTP header name.
*
* @param string $key
* @return bool
*/
protected static function isHeaderName($key) {
return self::startsWith($key, 'X_')
|| self::startsWith($key, 'HTTP_')
|| in_array($key, static::$unprefixedNames);
}
/**
* Parse headers for the current HTTP request.
* Will automatically choose the best way to get the headers from PHP.
*
* @return array
*/
public static function parseCurrent() {
//getallheaders() is the easiest solution, but it's not available in some server configurations.
if ( function_exists('getallheaders') ) {
$headers = getallheaders();
if ( $headers !== false ) {
return $headers;
}
}
return self::parse($_SERVER);
}
/**
* Convert a header name to "Title-Case-With-Dashes".
*
* @param string $name
* @return string
*/
protected function normalizeName($name) {
$name = strtolower($name);
$name = str_replace(array('_', '-'), ' ', $name);
$name = ucwords($name);
$name = str_replace(' ', '-', $name);
return $name;
}
/**
* Check if a string starts with the given prefix.
*
* @param string $string
* @param string $prefix
* @return bool
*/
protected static function startsWith($string, $prefix) {
return (substr($string, 0, strlen($prefix)) === $prefix);
}
/**
* Get the value of a HTTP header.
*
* @param string $name Header name.
* @param mixed $default The default value to return if the header doesn't exist.
* @return string|null
*/
public function get($name, $default = null) {
$name = $this->normalizeName($name);
if ( isset($this->headers[$name]) ) {
return $this->headers[$name];
}
return $default;
}
/**
* Set a header to value.
*
* @param string $name
* @param string $value
*/
public function set($name, $value) {
$name = $this->normalizeName($name);
$this->headers[$name] = $value;
}
/* ArrayAccess interface */
#[\ReturnTypeWillChange]
public function offsetExists($offset) {
return array_key_exists($offset, $this->headers);
}
#[\ReturnTypeWillChange]
public function offsetGet($offset) {
return $this->get($offset);
}
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value) {
$this->set($offset, $value);
}
#[\ReturnTypeWillChange]
public function offsetUnset($offset) {
$name = $this->normalizeName($offset);
unset($this->headers[$name]);
}
/* Countable interface */
#[\ReturnTypeWillChange]
public function count() {
return count($this->headers);
}
/* IteratorAggregate interface */
#[\ReturnTypeWillChange]
public function getIterator() {
return new ArrayIterator($this->headers);
}
}
from wp-update-server.
Thanks for the reminder! I had forgotten about this one. I've added the #[\ReturnTypeWillChange]
attributes to the class.
from wp-update-server.
Related Issues (20)
- Issue with the latest wp-update-server version HOT 5
- Critical Error Upon Setup HOT 4
- Sudenly I get: Update failed: You have the latest version of the plugin. HOT 10
- Handling alpha and beta plugin versions HOT 2
- Problem connecting server with checker library HOT 1
- Is it possible to add a list of domains to update? HOT 5
- How about implementing WordPress Code Standards? HOT 4
- Server maintenance questions. HOT 4
- PHP 8.2.7 Deprecated warnings on Server returning metadata (WP_DEBUG true) HOT 3
- Extension for packages list HOT 4
- Need a little help with extends Wpup_UpdateServer HOT 5
- What's going on here? HOT 3
- Can you change it to a remote zip URL? HOT 2
- guidance HOT 1
- Forbidden HOT 13
- Update Packagist HOT 2
- where I have to put example-theme.zip and which class is correct ? HOT 9
- unexpected error HOT 1
- Secure download link error message HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wp-update-server.