Jump to:

23001 Posts in 11854 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » ArticlePage Database Problem in Tutorial 2

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: 1159 Views
  • rowlf
    Avatar
    Community Member
    3 Posts

    ArticlePage Database Problem in Tutorial 2 Link to this post

    Hi I get the following error when rebuilding the database in tutorial 2 after adding the db fields in the ArticlePage.php class

    Building Database
    Creating database tables

    PageComment
    SiteTree
    Email_BounceRecord
    QueuedEmail
    File
    Group
    LoginAttempt
    Member
    MemberPassword
    Permission
    Widget
    WidgetArea
    Page
    GhostPage
    ArticleHolder
    ArticlePage
    Table ArticlePage: created
    [Notice] Undefined index: ArticlePage
    GET /silverstripe/dev/build?flush=1
    Line 352 in C:\wamp\www\SilverStripe\sapphire\core\model\Database.php

    Source
    343
    344       if(!$newTable && !isset($this->fieldList[$table])) {
    345          $this->fieldList[$table] = $this->fieldList($table);
    346       }
    347       
    348       if(is_array($spec))
    349          $specValue=$spec['data_type'];
    350       else $specValue=$spec;
    351       
    352       if(is_array($this->fieldList[$table][$field]))
    353          $fieldValue=$this->fieldList[$table][$field]['data_type'];
    354       else $fieldValue=$this->fieldList[$table][$field];
    355
    356       if(is_array($spec_orig))
    357          $spec_orig=DB::getConn()->$spec_orig['type']($spec_orig['parts']);
    358       
    Trace

    Notice: Undefined offset: 0 in C:\wamp\www\SilverStripe\sapphire\dev\Debug.php on line 520

    Warning: Invalid argument supplied for foreach() in C:\wamp\www\SilverStripe\sapphire\dev\Debug.php on line 557

    Warning: Invalid argument supplied for foreach() in C:\wamp\www\SilverStripe\sapphire\dev\Debug.php on line 557

    Warning: Invalid argument supplied for foreach() in C:\wamp\www\SilverStripe\sapphire\dev\Debug.php on line 557

    Warning: Invalid argument supplied for foreach() in C:\wamp\www\SilverStripe\sapphire\dev\Debug.php on line 557

    Warning: Invalid argument supplied for foreach() in C:\wamp\www\SilverStripe\sapphire\dev\Debug.php on line 557

    AAA()
    Line A of A
    III()
    Line I of I
    iii()
    Line i of i

    iii()
    Line i of i
    iii()
    Line i of i

    If I comment out the entries for db
    <?php
    /**
    * Defines the ArticlePage page type
    */
    class ArticlePage extends Page {
    static $db = array(
    /* 'Date' => 'Date',
    'Author' => 'Text'*/
    );
    static $has_one = array(
    );

    function getCMSFields() {
    $fields = parent::getCMSFields();

    $fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');
    $fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');
       
    return $fields;
    }
    }

    class ArticlePage_Controller extends Page_Controller {

    }

    ?>

    Then the error goes away. I'm using the latest svn trunk (http://svn.silverstripe.com/open/phpinstaller/trunk) and wamp on windows xp.
    Any ideas as to what's causing this?

    Regards,
    Martin.

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: ArticlePage Database Problem in Tutorial 2 Link to this post

    why are the db entrys commented out? that could be messing with something.

  • rowlf
    Avatar
    Community Member
    3 Posts

    Re: ArticlePage Database Problem in Tutorial 2 Link to this post

    It's to highlight where I suspect the error is. When the lines are uncommented (as per the tutorial) I get the 'Undefined Index' error, if I comment them out the error goes away. I expect the reason it goes away is that as there are no database fields, it doesn't actually create the ArticlePage table.
    Is there any way of debugging the problem?

  • rowlf
    Avatar
    Community Member
    3 Posts

    Re: ArticlePage Database Problem in Tutorial 2 Link to this post

    After a bit of poking around it looks like if fails in the requireField function of database.php
    $this->fieldList[$table] fails as
    $this->fieldList["ArticlePage"] doesn't exist even though I get the message
    # ArticlePage
    # Table ArticlePage: created
    in the debug output
    hope this helps.

  • mobius
    Avatar
    Community Member
    54 Posts

    Re: ArticlePage Database Problem in Tutorial 2 Link to this post

    I'm also getting this kind of error when trying to build my own data objects. I'm using svn trunk.

  • mobius
    Avatar
    Community Member
    54 Posts

    Re: ArticlePage Database Problem in Tutorial 2 Link to this post

    I managed to work around this by copying an older version of Database.php that I had.

    http://open.silverstripe.com/changeset?old_path=%2Fmodules%2Fsapphire%2Fbranches%2Fnestedurls%2Fcore%2Fmodel%2FDatabase.php&old=72505&new_path=%2Fmodules%2Fsapphire%2Fbranches%2Fnestedurls%2Fcore%2Fmodel%2FDatabase.php&new=72514

    shows the difference between the two files. 72514 seems to be quite broken.

    (I copied from a site that had nestedurls to one that didn't, but I don't think that is too much of an issue)

    1159 Views
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.