From fdbdad1eb029ab5a19c246150e7ef2067ff2bafb Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Tue, 1 Apr 2008 11:15:21 +0000
Subject: [PATCH] Utilities::getAcceptLanguage: Ensuer proper ordering of the
 output array.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@478 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/Utilities.php | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index 72b692ecc..8a8fe19af 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -674,6 +674,8 @@ class SimpleSAML_Utilities {
 	 * If an language includes a region, then the result will include both the language with the region
 	 * and the language without the region.
 	 *
+	 * The returned array will be in the same order as the input.
+	 *
 	 * @return An associative array with each language and the score for that language.
 	 */
 	public static function getAcceptLanguage() {
@@ -710,6 +712,9 @@ class SimpleSAML_Utilities {
 				}
 			}
 
+			/* Remove the old key to ensure that the element is added to the end. */
+			unset($ret[$l]);
+
 			/* Set the quality in the result. */
 			$ret[$l] = $q;
 
-- 
GitLab