aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-20 22:13:45 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-20 22:13:45 +0000
commiteda716aaf2f50d58f487209c9ea1dd9ddbea74c1 (patch)
tree800a55cdfefd1e7a9ab709e3f3088ff161be47e0 /engine
parent443bb6ac1f476f247716c6a119b1ac59c97a3f71 (diff)
downloadelgg-eda716aaf2f50d58f487209c9ea1dd9ddbea74c1.tar.gz
elgg-eda716aaf2f50d58f487209c9ea1dd9ddbea74c1.tar.bz2
Fixed a few bugs with create_upgrade.php. It now also automatically increments version.php.
git-svn-id: http://code.elgg.org/elgg/trunk@8372 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/upgrades/create_upgrade.php44
1 files changed, 39 insertions, 5 deletions
diff --git a/engine/lib/upgrades/create_upgrade.php b/engine/lib/upgrades/create_upgrade.php
index 9575ada74..3652e18a2 100644
--- a/engine/lib/upgrades/create_upgrade.php
+++ b/engine/lib/upgrades/create_upgrade.php
@@ -57,13 +57,15 @@ if ($upgrade_inc < 10) {
$upgrade_inc = "0$upgrade_inc";
}
+$upgrade_version = $upgrade_date . $upgrade_inc;
+
// make filename
if (substr($release, 0, 3) == '1.7') {
// 1.7 upgrades are YYYYMMDDXX
- $upgrade_name = $upgrade_date . $upgrade_inc . '.php';
+ $upgrade_name = $upgrade_version . '.php';
} else {
// 1.8+ upgrades are YYYYMMDDXX-release-friendly_name-rnd
- $upgrade_name = $upgrade_date . $upgrade_inc . "-$upgrade_release-$name-$upgrade_rnd.php";
+ $upgrade_name = $upgrade_version . "-$upgrade_release-$name-$upgrade_rnd.php";
}
$upgrade_file = $upgrade_path . '/' . $upgrade_name;
@@ -75,8 +77,10 @@ if (is_file($upgrade_file)) {
$upgrade_code = <<<___UPGRADE
<?php
/**
- * Elgg $version upgrade $date$inc
+ * Elgg $release upgrade $upgrade_version
* $name
+ *
+ * Description
*/
// upgrade code here.
@@ -92,12 +96,42 @@ if (!$h) {
if (!fputs($h, $upgrade_code)) {
die("Could not write to $upgrade_file");
} else {
- echo "\nCreated file $upgrade_name. Add your upgrade code there.\n\n";
+ elgg_set_version_dot_php_version($upgrade_version);
+ echo <<<___MSG
+
+Created upgrade file and updated version.php.
+
+Upgrade file: $upgrade_name
+Version: $upgrade_version
+
+___MSG;
}
fclose($h);
+function elgg_set_version_dot_php_version($version) {
+ $file = '../../../version.php';
+ $h = fopen($file, 'r+b');
+
+ if (!$h) {
+ return false;
+ }
+
+ $out = '';
+
+ while (($line = fgets($h)) !== false) {
+ $find = "/\\\$version[ ]?=[ ]?[0-9]{10};/";
+ $replace = "\$version = $version;";
+ $out .= preg_replace($find, $replace, $line);
+ }
+
+ rewind($h);
+
+ fputs($h, $out);
+ fclose($h);
+}
+
/**
* Shows the usage for the create_upgrade script and dies().
*
@@ -114,4 +148,4 @@ Example:
___MSG;
die($text);
-} \ No newline at end of file
+}