diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerMDX.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerMDX.php index 7364a6fe9cad856d59097922779720a3cfec6a20..bf405847518379524cb73c17376c28ed31edba6e 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerMDX.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerMDX.php @@ -140,8 +140,9 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerMDX extends SimpleSAML_Metadata_ $rawData = file_get_contents($cachefilename); if (empty($rawData)) { + $error = error_get_last(); throw new Exception('Error reading metadata from cache file "' . $cachefilename . '": ' . - SimpleSAML_Utilities::getLastError()); + $error['message']); } $data = unserialize($rawData); @@ -258,8 +259,9 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerMDX extends SimpleSAML_Metadata_ } if (empty($xmldata)) { + $error = error_get_last(); throw new Exception('Error downloading metadata for "'. $index .'" from "' . $mdx_url . '": ' . - SimpleSAML_Utilities::getLastError()); + $error['message']); } $entity = SimpleSAML_Metadata_SAMLParser::parseString($xmldata); diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php index 3415cd5cc0feb504e147cb08457e4063ad76d0f2..fae34c9fbf1b116e70e1090ecb3fe059d227ed2b 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php @@ -164,8 +164,9 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerSerialize extends SimpleSAML_Met $data = @file_get_contents($filePath); if ($data === FALSE) { + $error = error_get_last(); SimpleSAML_Logger::warning('Error reading file ' . $filePath . - ': ' . SimpleSAML_Utilities::getLastError()); + ': ' . $error['message']); return NULL; } @@ -199,8 +200,9 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerSerialize extends SimpleSAML_Met SimpleSAML_Logger::info('Creating directory: ' . $dir); $res = @mkdir($dir, 0777, TRUE); if ($res === FALSE) { + $error = error_get_last(); SimpleSAML_Logger::error('Failed to create directory ' . $dir . - ': ' . SimpleSAML_Utilities::getLastError()); + ': ' . $error['message']); return FALSE; } } @@ -211,15 +213,17 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerSerialize extends SimpleSAML_Met $res = file_put_contents($newPath, $data); if ($res === FALSE) { + $error = error_get_last(); SimpleSAML_Logger::error('Error saving file ' . $newPath . - ': ' . SimpleSAML_Utilities::getLastError()); + ': ' . $error['message']); return FALSE; } $res = rename($newPath, $filePath); if ($res === FALSE) { + $error = error_get_last(); SimpleSAML_Logger::error('Error renaming ' . $newPath . ' to ' . $filePath . - ': ' . SimpleSAML_Utilities::getLastError()); + ': ' . $error['message']); return FALSE; } @@ -248,8 +252,9 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerSerialize extends SimpleSAML_Met $res = unlink($filePath); if ($res === FALSE) { + $error = error_get_last(); SimpleSAML_Logger::error('Failed to delete file ' . $filePath . - ': ' . SimpleSAML_Utilities::getLastError()); + ': ' . $error['message']); } } diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 148be6ea11a2316eff54fe79be31766fa9f215f9..6e3549e95919655c557787af53bd83a466139b18 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -1199,13 +1199,7 @@ class SimpleSAML_Utilities { /** - * Retrieve last error message. - * - * This function retrieves the last error message. If no error has occurred, - * '[No error message found]' will be returned. If the required function isn't available, - * '[Cannot get error message]' will be returned. - * - * @return string Last error message. + * @deprecated This function will be removed in SSP 2.0. Please call error_get_last() directly. */ public static function getLastError() { @@ -1915,7 +1909,8 @@ class SimpleSAML_Utilities { $data = file_get_contents($path, FALSE, $context); if ($data === FALSE) { - throw new SimpleSAML_Error_Exception('Error fetching ' . var_export($path, TRUE) . ':' . self::getLastError()); + $error = error_get_last(); + throw new SimpleSAML_Error_Exception('Error fetching ' . var_export($path, TRUE) . ':' . $error['message']); } // Data and headers. diff --git a/lib/SimpleSAML/Utils/System.php b/lib/SimpleSAML/Utils/System.php index 59da67bdb4a8b07fed71b56a9d6e496f1be56172..bce9285cd1eb408c9e562c4caf58a8bd5b759e2c 100644 --- a/lib/SimpleSAML/Utils/System.php +++ b/lib/SimpleSAML/Utils/System.php @@ -74,8 +74,9 @@ class SimpleSAML_Utils_System if (!is_dir($tempDir)) { if (!mkdir($tempDir, 0700, true)) { + $error = error_get_last(); throw new SimpleSAML_Error_Exception('Error creating temporary directory "'.$tempDir. - '": '.SimpleSAML_Utilities::getLastError()); + '": '.$error['message']); } } elseif (function_exists('posix_getuid')) { // check that the owner of the temp directory is the current user @@ -117,22 +118,25 @@ class SimpleSAML_Utils_System $res = @file_put_contents($tmpFile, $data); if ($res === false) { + $error = error_get_last(); throw new SimpleSAML_Error_Exception('Error saving file "'.$tmpFile. - '": '.SimpleSAML_Utilities::getLastError()); + '": '.$error['message']); } if (self::getOS() !== self::WINDOWS) { if (!chmod($tmpFile, $mode)) { unlink($tmpFile); + $error = error_get_last(); throw new SimpleSAML_Error_Exception('Error changing file mode of "'.$tmpFile. - '": '.SimpleSAML_Utilities::getLastError()); + '": '.$error['message']); } } if (!rename($tmpFile, $filename)) { unlink($tmpFile); + $error = error_get_last(); throw new SimpleSAML_Error_Exception('Error moving "'.$tmpFile.'" to "'. - $filename.'": '.SimpleSAML_Utilities::getLastError()); + $filename.'": '.$error['message']); } } }