From 6a21094048cd160a81f351b7240880d1a0306fa8 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 20 Nov 2008 01:39:31 +0000 Subject: [PATCH] BUGFIX Improved reliability of LeftAndMain->CMSVersion() - not failing on empty $URL$ placeholder with subversion path to determine version numbers git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@66274 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/LeftAndMain.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index dc13b0d3..0551b83d 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -812,7 +812,11 @@ JS; } /** - * Return the version number of this application + * Return the version number of this application. + * Uses the subversion path information in /silverstripe_version + * (automacially replaced $URL$ placeholder). + * + * @return string */ public function CMSVersion() { $sapphireVersionFile = file_get_contents('../sapphire/silverstripe_version'); @@ -823,21 +827,21 @@ JS; $sapphireVersion = "trunk"; } else { preg_match("/sapphire\/(?:(?:branches)|(?:tags))(?:\/rc)?\/([A-Za-z0-9._-]+)\/silverstripe_version/", $sapphireVersionFile, $matches); - $sapphireVersion = $matches[1]; + $sapphireVersion = ($matches) ? $matches[1] : null; } if(strstr($jspartyVersionFile, "/jsparty/trunk")) { $jspartyVersion = "trunk"; } else { preg_match("/jsparty\/(?:(?:branches)|(?:tags))(?:\/rc)?\/([A-Za-z0-9._-]+)\/silverstripe_version/", $jspartyVersionFile, $matches); - $jspartyVersion = $matches[1]; + $jspartyVersion = ($matches) ? $matches[1] : null; } if(strstr($cmsVersionFile, "/cms/trunk")) { $cmsVersion = "trunk"; } else { preg_match("/cms\/(?:(?:branches)|(?:tags))(?:\/rc)?\/([A-Za-z0-9._-]+)\/silverstripe_version/", $cmsVersionFile, $matches); - $cmsVersion = $matches[1]; + $cmsVersion = ($matches) ? $matches[1] : null; } if($sapphireVersion == $jspartyVersion && $jspartyVersion == $cmsVersion) {