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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   2115 Views

Avatar
FrenchDevelopper

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)
http://localhost/SilverStripe-v2.3.1/
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

Source
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 = "";
196
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 }
204
205 $alterations = implode(",\n", $alterList);

Trace
MySQLDatabase->alterTable(SiteTree,Array,Array,Array,Array)
Line 163 of Database.php
Database->endSchemaUpdate()
Line 193 of DatabaseAdmin.php
DatabaseAdmin->doBuild(,1)
Line 100 of DatabaseAdmin.php
DatabaseAdmin->build()
Line 130 of DevelopmentAdmin.php
DevelopmentAdmin->build(HTTPRequest)
Line 107 of RequestHandler.php
RequestHandler->handleRequest(HTTPRequest)
Line 122 of Controller.php
Controller->handleRequest(HTTPRequest)
Line 277 of Director.php
Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
Director::direct(/dev/build)
Line 115 of main.php

Avatar
dalesaurus

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.

Avatar
FrenchDevelopper

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)