[CORE] Fix undefined offset warnings in different files
This problem was presentend in the following issue: https://notabug.org/diogo/gnu-social/issues/60 AcceptHeader/util: - Perform isset before using the required array values
This commit is contained in:
parent
fe2168c5ae
commit
8f070f53ec
|
@ -49,12 +49,18 @@ class AcceptHeader extends \ArrayObject
|
|||
foreach ($items as $item) {
|
||||
$elems = explode(';', $item);
|
||||
|
||||
$acceptElement = [];
|
||||
$mime = current($elems);
|
||||
list($type, $subtype) = explode('/', $mime);
|
||||
$acceptElement['type'] = trim($type);
|
||||
$acceptElement['subtype'] = trim($subtype);
|
||||
$acceptElement['raw'] = $mime;
|
||||
$mime = current($elems);
|
||||
$types = explode('/', $mime);
|
||||
|
||||
if (!isset($types[1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$acceptElement = [
|
||||
'raw' => $mime,
|
||||
'type' => trim($types[0]),
|
||||
'subtype' => trim($types[1]),
|
||||
];
|
||||
|
||||
$acceptElement['params'] = [];
|
||||
while (next($elems)) {
|
||||
|
|
|
@ -2100,7 +2100,7 @@ function common_negotiate_type($cprefs, $sprefs)
|
|||
|
||||
foreach (array_keys($sprefs) as $type) {
|
||||
$parts = explode('/', $type);
|
||||
if ($parts[1] != '*') {
|
||||
if (isset($parts[1]) && $parts[1] != '*') {
|
||||
$ckey = common_mime_type_match($type, $cprefs);
|
||||
if ($ckey) {
|
||||
$combine[$type] = $sprefs[$type] * $cprefs[$ckey];
|
||||
|
@ -2110,7 +2110,7 @@ function common_negotiate_type($cprefs, $sprefs)
|
|||
|
||||
foreach (array_keys($cprefs) as $type) {
|
||||
$parts = explode('/', $type);
|
||||
if ($parts[1] != '*' && !array_key_exists($type, $sprefs)) {
|
||||
if (isset($parts[1]) && $parts[1] != '*' && !array_key_exists($type, $sprefs)) {
|
||||
$skey = common_mime_type_match($type, $sprefs);
|
||||
if ($skey) {
|
||||
$combine[$type] = $sprefs[$skey] * $cprefs[$type];
|
||||
|
|
Loading…
Reference in New Issue
Block a user