From bc121d6e03d506cac2eb2614e661d1d1543fd8e6 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Mon, 9 Jan 2006 06:40:11 +0000
Subject: [PATCH] - Patch #42951 by Matt Westgate: bugfix: fixed migration path
 of primary links when using Xtemplate.

---
 database/updates.inc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/database/updates.inc b/database/updates.inc
index e7a1a24be937..6511ae9913cf 100644
--- a/database/updates.inc
+++ b/database/updates.inc
@@ -939,8 +939,16 @@ function system_update_151() {
     // Gather links from various settings into a single array.
     $phptemplate_links = variable_get("phptemplate_". $menus[$loop]['links_var'], array());
     $phptemplate_links_more = variable_get("phptemplate_". $menus[$loop]['links_var'] ."_more", array());
-    if (isset($ts) && is_array($ts) && is_array($ts[$menus[$loop]['links_var']])) {
-      $theme_links = $ts[$menus[$loop]['links_var']];
+    if (isset($ts) && is_array($ts)) {
+      if (is_array($ts[$menus[$loop]['links_var']])) {
+        $theme_links = $ts[$menus[$loop]['links_var']];
+      }
+      else {
+        // Convert old xtemplate style links.
+        preg_match_all('/<a\s+.*?href=[\"\'\s]?(.*?)[\"\'\s]?>(.*?)<\/a>/i', $ts[$menus[$loop]['links_var']], $urls);
+        $theme_links['text'] = $urls[2];
+        $theme_links['link'] = $urls[1];
+      }
     }
     else {
       $theme_links = array();
-- 
GitLab