Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated several error messages to provide better information (from Sk…

…yzyx, modified)
  • Loading branch information...
commit 9a1ebc038fc6653002e0f0691f530849aab49cf5 1 parent b47a83f
Ryan McCue rmccue authored
Showing with 20 additions and 13 deletions.
  1. +20 −13 simplepie.inc
33 simplepie.inc
View
@@ -1672,7 +1672,7 @@ class SimplePie
$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
if (!$cache->save($this))
{
- trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
+ trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
}
$cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
}
@@ -1680,7 +1680,7 @@ class SimplePie
}
else
{
- $this->error = "A feed could not be found at $this->feed_url";
+ $this->error = "A feed could not be found at $this->feed_url. A feed with an invalid mime type may fall victim to this error, or " . SIMPLEPIE_NAME . " was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed.";
SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
return false;
}
@@ -1777,27 +1777,27 @@ class SimplePie
// Cache the file if caching is enabled
if ($cache && !$cache->save($this))
{
- trigger_error("$cache->name is not writeable", E_USER_WARNING);
+ trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
}
return true;
}
else
{
- $this->error = "A feed could not be found at $this->feed_url";
+ $this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed.";
SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
return false;
}
}
}
}
- if(isset($parser))
+ if (isset($parser))
{
// We have an error, just set SimplePie_Misc::error to it and quit
- $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
+ $this->error = sprintf('This XML document is invalid, likely due to invalid characters. XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
}
else
{
- $this->error = 'The data could not be converted to UTF-8';
+ $this->error = 'The data could not be converted to UTF-8. You MUST have either the iconv or mbstring extension installed. Upgrading to PHP 5.x (which includes iconv) is highly recommended.';
}
SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
return false;
@@ -1984,7 +1984,7 @@ class SimplePie
}
else
{
- trigger_error("$cache->name is not writeable", E_USER_WARNING);
+ trigger_error("$cache->name is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
}
}
@@ -9241,15 +9241,22 @@ class SimplePie_Misc
$log_error = true;
if (!function_exists('error_log'))
- $log_error = false;
+ {
+ $log_error = false;
+ }
$log_file = @ini_get('error_log');
if (!empty($log_file) && ('syslog' != $log_file) && !@is_writable($log_file))
- $log_error = false;
+ {
+ $log_error = false;
+ }
- if ( $log_error )
- @error_log("$note: $message in $file on line $line", 0);
+ if ($log_error)
+ {
+ @error_log("$note: $message in $file on line $line", 0);
+ }
}
+
return $message;
}
@@ -14927,7 +14934,7 @@ class SimplePie_Sanitize
}
else
{
- trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
+ trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
}
}
}

2 comments on commit 9a1ebc0

Luca79

please note this:
Using this version I can not parse correctly feed from DELICIOUS. They get trunked to only 15 items

<?php
include_once 'simplepie.inc';
$feed = new SimplePie();
$feed->set_feed_url(array('http://feeds.delicious.com/v2/rss/tag/windows?count=100',''http://feeds.delicious.com/v2/rss/tag/linux?count=100));
$feed->enable_cache(false);
$feed->set_item_limit(50);
$feed->init();
echo 'PROCESSING:';
echo "\n";
print ($feed->get_item_quantity());
echo "\n";
?>

I get: 30 items
Using the original version I get 100 items

Luca79

Please note that using this version I can not get items correctly from delicious. The number get trunked at 15. Usining the same code with the original version I can get the correctly amount of item required.

Please sign in to comment.
Something went wrong with that request. Please try again.