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
This commit is contained in:
Ingo Schommer 2008-11-20 01:39:31 +00:00 committed by Sam Minnee
parent 45c4d670b6
commit 6a21094048

View File

@ -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 <mymodule>/silverstripe_version
* (automacially replaced $URL$ placeholder).
*
* @return string
*/ */
public function CMSVersion() { public function CMSVersion() {
$sapphireVersionFile = file_get_contents('../sapphire/silverstripe_version'); $sapphireVersionFile = file_get_contents('../sapphire/silverstripe_version');
@ -823,21 +827,21 @@ JS;
$sapphireVersion = "trunk"; $sapphireVersion = "trunk";
} else { } else {
preg_match("/sapphire\/(?:(?:branches)|(?:tags))(?:\/rc)?\/([A-Za-z0-9._-]+)\/silverstripe_version/", $sapphireVersionFile, $matches); 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")) { if(strstr($jspartyVersionFile, "/jsparty/trunk")) {
$jspartyVersion = "trunk"; $jspartyVersion = "trunk";
} else { } else {
preg_match("/jsparty\/(?:(?:branches)|(?:tags))(?:\/rc)?\/([A-Za-z0-9._-]+)\/silverstripe_version/", $jspartyVersionFile, $matches); 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")) { if(strstr($cmsVersionFile, "/cms/trunk")) {
$cmsVersion = "trunk"; $cmsVersion = "trunk";
} else { } else {
preg_match("/cms\/(?:(?:branches)|(?:tags))(?:\/rc)?\/([A-Za-z0-9._-]+)\/silverstripe_version/", $cmsVersionFile, $matches); 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) { if($sapphireVersion == $jspartyVersion && $jspartyVersion == $cmsVersion) {