Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions categories-page.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
require_once(dirname(__FILE__) . '/admin-ui.php');

#[\AllowDynamicProperties]
class FeedWordPressCategoriesPage extends FeedWordPressAdminPage {
public function __construct( $link = -1 ) {
if (is_numeric($link) and -1 == $link) :
Expand Down
9 changes: 8 additions & 1 deletion feedfinder.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ function is_401 ($uri = NULL) {
function is_feed ($uri = NULL) {
$data = $this->data($uri);

if (is_null($data)) {
return false;
}

return (
preg_match (
"\007(".implode('|',$this->_feed_markers).")\007i",
Expand Down Expand Up @@ -269,7 +273,10 @@ function _link_rel_feeds () {
$href = array ();
for ($n=0; $n<$link_count; $n++) {
if (strtolower($links[$n]['rel']) == 'alternate') {
if (in_array(strtolower($links[$n]['type']), $this->_feed_types)) {
if (isset($links[$n]['type'])
&& !is_null($links[$n]['type'])
&& in_array(strtolower($links[$n]['type']), $this->_feed_types)
) {
$href[] = $links[$n]['href'];
} /* if */
} /* if */
Expand Down
2 changes: 2 additions & 0 deletions feedwordpressparsedpostmeta.class.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

#[\AllowDynamicProperties]
class FeedWordPressParsedPostMeta {
var $s, $ptr, $ptrEOS;
var $delims, $delimCount, $delimPtr;
Expand Down
9 changes: 7 additions & 2 deletions magpiefromsimplepie.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @version 2010.0612
*/

#[\AllowDynamicProperties]
class MagpieFromSimplePie {
var $pie;
var $originals;
Expand Down Expand Up @@ -672,7 +673,9 @@ function normalize_category (&$source, $from, &$dest, $to, $i) {
if ( isset($source["{$cat_id}@term"]) ) : // category identifier
$source[$cat_id] = $source["{$cat_id}@term"];
elseif ( $this->is_rss() ) :
$source["{$cat_id}@term"] = $source[$cat_id];
$source["{$cat_id}@term"] = isset($source[$cat_id])
? $source[$cat_id]
: null; // Avoid PHP notice nastygrams - the source key is probably missing because was a self-closing or empty node
endif;

if ( isset($source["{$cat_id}@scheme"]) ) : // URI to taxonomy
Expand All @@ -682,7 +685,9 @@ function normalize_category (&$source, $from, &$dest, $to, $i) {
endif;

// Now put the identifier into dc:subject
$dest[$dc_id] = $source[$cat_id];
$dest[$dc_id] = isset($source[$cat_id])
? $source[$cat_id]
: null; // Avoid PHP notice nastygrams - the source key is probably missing because was a self-closing or empty node
} /* MagpieFromSimplePie::normalize_category */

/**
Expand Down
3 changes: 2 additions & 1 deletion posts-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require_once(dirname(__FILE__) . '/admin-ui.php');
require_once(dirname(__FILE__) . '/updatedpostscontrol.class.php');

#[\AllowDynamicProperties]
class FeedWordPressPostsPage extends FeedWordPressAdminPage {
var $link = NULL;
var $updatedPosts = NULL;
Expand Down Expand Up @@ -224,7 +225,7 @@ function formatting_box( $page, $box = NULL ) {

if ($page->for_feed_settings()) :
$formatting_filters = null;
$url = preg_replace('|/+$|', '', $page->link->homepage());
$url = preg_replace('|/+$|', '', $page->link->homepage() ?? '');
else :
$formatting_filters = get_option('feedwordpress_formatting_filters', 'no');
$url = 'http://example.com';
Expand Down
2 changes: 1 addition & 1 deletion syndicatedlink.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ public function automatic_ttl() {

// We get a fudge of 1/3 of window from elsewhere. We'll do some more
// fudging here.
$fudgedInterval = $updateWindow + rand( - ( $updateWindow / 6 ), 5 * ( $updateWindow / 12 ) );
$fudgedInterval = $updateWindow + rand( (int) - ( $updateWindow / 6 ), (int) (5 * ( $updateWindow / 12 )) );
return apply_filters( 'syndicated_feed_automatic_ttl', $fudgedInterval, $this );
} /* SyndicatedLink::automatic_ttl() */

Expand Down
18 changes: 10 additions & 8 deletions syndicatedpost.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,13 @@ public function content ($params = array())

public function excerpt () {
# Identify and sanitize excerpt: atom:summary, or rss:description
$excerpt = $this->entry->get_description();
$excerpt = $this->entry->get_description() ?? '';

# Many RSS feeds use rss:description, inadvisably, to
# carry the entire post (typically with escaped HTML).
# If that's what happened, we don't want the full
# content for the excerpt.
$content = $this->content();
$content = $this->content() ?? '';

// Ignore whitespace, case, and tag cruft.
$theExcerpt = preg_replace('/\s+/', '', strtolower(strip_tags(html_entity_decode($excerpt))));
Expand Down Expand Up @@ -909,7 +909,7 @@ public function get_terms_from_feeds () {
*/
function inline_tags () {
$tags = array();
$content = $this->content();
$content = $this->content() ?? '';
$pattern = FeedWordPressHTML::tagWithAttributeRegex('a', 'rel', 'tag');
preg_match_all($pattern, $content, $refs, PREG_SET_ORDER);
if (is_countable($refs) and count($refs) > 0) :
Expand Down Expand Up @@ -1168,11 +1168,13 @@ static function resolve_relative_uris ($content, $obj) {
// Relying on preg_replace_callback() here can cause a PHP seg fault on my development
// server. preg_match_all() causes a similar problem. Apparently this is a PCRE issue
// Cf. discussion of similar issue <https://bugs.php.net/bug.php?id=65009>
$content = preg_replace_callback (
$pattern,
array($obj, 'resolve_single_relative_uri'),
$content
);
$content = is_null($content)
? ''
: preg_replace_callback (
$pattern,
array($obj, 'resolve_single_relative_uri'),
$content
);

endforeach;
endif;
Expand Down
2 changes: 1 addition & 1 deletion syndicatedpostterm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function is_forbidden_in ($tax = NULL) {
$tax = $this->tax[0];
endif;

if ($tax=='category' and strtolower($term)=='uncategorized') :
if ($tax=='category' and !is_null($term) && strtolower($term)=='uncategorized') :
$forbid = true;
endif;

Expand Down
24 changes: 14 additions & 10 deletions syndicatedpostxpathquery.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@ public function setPath ($path) {
$this->urlHash = array();

$this->path = $path;

// Allow {url} notation for namespaces. URLs will contain : and /, so...
preg_match_all('/{([^}]+)}/', $path, $match, PREG_SET_ORDER);
foreach ($match as $ref) :
$this->urlHash[md5($ref[1])] = $ref[1];
endforeach;

foreach ($this->urlHash as $hash => $url) :
$path = str_replace('{'.$url.'}', '{#'.$hash.'}', $path);
endforeach;

if (is_string($path)) {
// got a non-string path, probably a place marker e.g. `category[1]`, so for now just don't give a warning, but should be fixed by not trying to set the path of an array!

// Allow {url} notation for namespaces. URLs will contain : and /, so...
preg_match_all('/{([^}]+)}/', $path, $match, PREG_SET_ORDER);
foreach ($match as $ref) :
$this->urlHash[md5($ref[1])] = $ref[1];
endforeach;

foreach ($this->urlHash as $hash => $url) :
$path = str_replace('{'.$url.'}', '{#'.$hash.'}', $path);
endforeach;
}

$path = $this->parsePath(/*cur=*/ $path, /*orig=*/ $path);

Expand Down
4 changes: 3 additions & 1 deletion template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ function is_syndicated ($id = NULL) {
* @return string containing an abbreviated display form of the URL (e.g.: `feedwordpress.radgeek.net/feed`)
*/
function feedwordpress_display_url ($url, $before = 60, $after = 0) {
$bits = parse_url($url);
$bits = is_null($url)
? []
: parse_url($url);

// Strip out crufty subdomains
if (isset($bits['host'])) :
Expand Down