Jump to:

23575 Posts in 19403 Topics by 2893 members

General Questions

SilverStripe Forums » General Questions » Problem while rebuilding the database

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

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

Page: 1
Go to End
Author Topic: 1205 Views
  • FrenchDevelopper
    Community Member
    2 Posts

    Problem while rebuilding the database Link to this post

    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

  • dalesaurus
    Community Member
    283 Posts

    Re: Problem while rebuilding the database Link to this post

    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.

  • FrenchDevelopper
    Community Member
    2 Posts

    Re: Problem while rebuilding the database Link to this post

    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)

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.