Yaron Koren has uploaded a new change for review.
https://gerrit.wikimedia.org/r/149922
Change subject: Some small fixes/changes for #get_file_data addition
......................................................................
Some small fixes/changes for #get_file_data addition
Change-Id: I3a6e92b56782412d7d0d6e66bc63f31de588f702
---
M ED_Utils.php
1 file changed, 11 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData
refs/changes/22/149922/1
diff --git a/ED_Utils.php b/ED_Utils.php
index 9535414..c3861ea 100644
--- a/ED_Utils.php
+++ b/ED_Utils.php
@@ -865,7 +865,7 @@
}
}
- static private function getData( $contents, $format, $mappings, $source
) {
+ static private function getDataFromText( $contents, $format, $mappings,
$source ) {
if ( $format == 'xml' ) {
return self::getXMLData( $contents );
} elseif ( $format == 'xml with xpath' ) {
@@ -914,20 +914,23 @@
$url_contents = self::fetchURL( $url, $postData,
$cacheExpireTime );
// Show an error message if there's nothing there.
if ( empty( $url_contents ) ) {
- return "No contents found at URL $url.";
+ return "Error: No contents found at URL $url.";
}
- return self::getData( $url_contents, $format, $mappings, $url );
+ return self::getDataFromText( $url_contents, $format,
$mappings, $url );
}
static private function getDataFromPath( $path, $format, $mappings ) {
+ if ( !file_exists( $path ) ) {
+ return "Error: No file found.";
+ }
$file_contents = file_get_contents( $path );
// Show an error message if there's nothing there.
if ( empty( $file_contents ) ) {
- return "Unable to get file contents.";
+ return "Error: Unable to get file contents.";
}
- return self::getData( $file_contents, $format, $mappings, $path
);
+ return self::getDataFromText( $file_contents, $format,
$mappings, $path );
}
static public function getDataFromFile( $file, $format, $mappings ) {
@@ -936,7 +939,7 @@
if ( array_key_exists( $file, $edgFilePath ) ) {
return self::getDataFromPath( $edgFilePath[$file],
$format, $mappings );
} else {
- return self::formatErrorMessage( "No file is set for ID
$file." );
+ return "Error: No file is set for ID \"$file\".";
}
}
@@ -949,10 +952,10 @@
if ( $path !== false && strpos( $path, $directoryPath )
=== 0 ) {
return self::getDataFromPath( $path, $format,
$mappings );
} else {
- return self::formatErrorMessage( "File name
$fileName not allowed for directory ID $directory." );
+ return "Error: File name \"$fileName\" is not
allowed for directory ID \"$directory\".";
}
} else {
- return self::formatErrorMessage( "No directory is set
for ID $directory." );
+ return "Error: No directory is set for ID
\"$directory\".";
}
}
--
To view, visit https://gerrit.wikimedia.org/r/149922
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3a6e92b56782412d7d0d6e66bc63f31de588f702
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ExternalData
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits