summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-04-19 10:32:43 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2014-04-19 10:59:48 +0200
commit34453d32958cc71cf08e932368952f98b46b7020 (patch)
tree34a7775559a0262e48cd20a02145797d9e0762fc /web/lib
parente582cfe1823617398657f1b46482f7c608b5aabe (diff)
downloadaur-34453d32958cc71cf08e932368952f98b46b7020.tar.gz
aur-34453d32958cc71cf08e932368952f98b46b7020.tar.xz
Handle pkgbase array overrides gracefully
Instead of overwriting arrays, such as depends, from the pkgbase section, new entries should be appended. Replace array_merge() with a mixture of array_merge_recursive() and array_replace_recursive() that merges array fields and replaces non-array fields. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/aur.inc.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index 16aa2619..b41b720c 100644
--- a/web/lib/aur.inc.php
+++ b/web/lib/aur.inc.php
@@ -572,3 +572,28 @@ function latest_pkgs($numpkgs) {
return $packages;
}
+
+/**
+ * Merge pkgbase and package options
+ *
+ * Merges entries of the first and the second array. If any key appears in both
+ * arrays and the corresponding value is an array itself, the arrays are
+ * merged. If a key appears in both arrays and the corresponding value is not
+ * an array, the second value replaces the first one.
+ *
+ * @param array $pkgbase_info Options from the pkgbase section
+ * @param array $section_info Options from the package section
+ *
+ * @return array Merged information from both sections
+ */
+function array_pkgbuild_merge($pkgbase_info, $section_info) {
+ $pi = $pkgbase_info;
+ foreach ($section_info as $opt_key => $opt_val) {
+ if (is_array($opt_val)) {
+ $pi[$opt_key] += $opt_val;
+ } else {
+ $pi[$opt_key] = $opt_val;
+ }
+ }
+ return $pi;
+}