PHP Warning: “Undefined array key “pci_osm””
-
Hi all, thanks as always for this incredible plugin and all the support you put into it.
I discovered another one of those classic little bugs where an edge-case results in PHP warnings in the logs:
[18-Aug-2025 16:50:23] PHP warning: "Undefined array key "pci_osm"" file: [...]/powerpress/powerpress.php:1498 url: globalvoices.org/-/special/global-voices-podcast/feed/Seems easy enough to fix, as the code just doesn’t validate that the array item isn’t empty before checking if it’s an array:
if( !is_array($Feed['pci_geo']) && !empty($Feed['pci_geo']) ) {
echo " geo=\"" . htmlspecialchars($Feed['pci_geo']) . "\"";
}
if( !is_array($Feed['pci_osm']) && !empty($Feed['pci_osm']) ) {
echo " osm=\"" . htmlspecialchars($Feed['pci_osm']) . "\"";
}Seems to me all we need to do is flip the order so it checks
!empty()first, then check if it’s an array:if( !empty($Feed['pci_geo']) && !is_array($Feed['pci_geo']) ) {
echo " geo=\"" . htmlspecialchars($Feed['pci_geo']) . "\"";
}
if( !empty($Feed['pci_osm']) && !is_array($Feed['pci_osm']) ) {
echo " osm=\"" . htmlspecialchars($Feed['pci_osm']) . "\"";
}I wasn’t able to replicate this issue using a local test site, but I’m going to update my live site and confirm this solves the problem for me and reply back.
The topic ‘PHP Warning: “Undefined array key “pci_osm””’ is closed to new replies.