Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Problem while rebuilding the database

Go to End

3 Posts   1793 Views


Community Member, 2 Posts

13 August 2009 at 10:22pm

Hello all,
Here is my problem: i have a stable version of my application with a fully filled database. Everything works fine, unless i want to modify the code of some of my php page files (inheritance within the sitetree).
More precisely, when i modify my pages.php on my dev computer, with almost no content in my database but some testing contents, i rebuild successfully.
But when i rebuild on the same application but this time using a filled database, an error occurs. Below the error generated by the build command.
Notice: i'm working with silverstripe 2.3.1 using the "i18n patch".

Environment Builder (formerly db/build)
dev→ build
Building Database
Creating database tables


[Notice] Undefined variable: alterList
GET /SilverStripe-v2.3.1/dev/build
Line 199 in D:\SNCM\wamp\www\SilverStripe-v2.3.1\sapphire\core\model\MySQLDatabase.php

190 * @param $newIndexes New indexes, a map of index name => index type
191 * @param $alteredFields Updated fields, a map of field name => field schema
192 * @param $alteredIndexes Updated indexes, a map of index name => index type
193 */
194 public function alterTable($tableName, $newFields = null, $newIndexes = null, $alteredFields = null, $alteredIndexes = null) {
195 $fieldSchemas = $indexSchemas = "";
197 if($newFields) foreach($newFields as $k => $v) $alterList[] .= "ADD `$k` $v";
198 if($newIndexes) foreach($newIndexes as $k => $v) $alterList[] .= "ADD " . $this->getIndexSqlDefinition($k, $v);
199 if($alteredFields) foreach($alteredFields as $k => $v) $alterList[] .= "CHANGE `$k` `$k` $v";
200 if($alteredIndexes) foreach($alteredIndexes as $k => $v) {
201 $alterList[] .= "DROP INDEX `$k`";
202 $alterList[] .= "ADD ". $this->getIndexSqlDefinition($k, $v);
203 }
205 $alterations = implode(",\n", $alterList);

Line 163 of Database.php
Line 193 of DatabaseAdmin.php
Line 100 of DatabaseAdmin.php
Line 130 of DevelopmentAdmin.php
Line 107 of RequestHandler.php
Line 122 of Controller.php
Line 277 of Director.php
Line 121 of Director.php
Line 115 of main.php


Community Member, 283 Posts

14 August 2009 at 6:39am

This is a bug with 2.3.1 that has been fixed in 2.3.3. The $alterList var was not declared before it was used. You can go in there around line 196 and add '$alterList = array();' and you'll be off and running.

The reason it works locally is your probably don't have any fields to alter on your dev box, but in production you do.


Community Member, 2 Posts

20 August 2009 at 10:50pm

Thank you very much for your help.
I'll try that out the next time i'll have to rebuild!

(what i did until now was to add the new type page in the enum of the type pages in the site tree table)