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.

All other Modules

Discuss all other Modules here.

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

Undefined variable: alterList


Reply

3 Posts   1516 Views

Avatar
faraway

27 July 2009 at 2:25am Community Member, 1 Post

Hi comunity, I'm very exiting with silverstripe but as a newbie I have some problems with certain things.
When I try to install any module I get the following error on db/build process: Undefined variable: alterList.

Can you help me please?
Thanks a lot

More details here:

http://localhost/SilverStripe-test1/db/build

Building Database SS_mysite_test1

Creating database tables
# PageComment
# CalendarDateTime
# ICSFeed
# RecurringDayOfMonth
# RecurringDayOfWeek
# RecurringException
# SiteTree
# Field SiteTree.ClassName: changed to enum('SiteTree','Page','GhostPage','Calendar','CalendarEvent','ErrorPage','RedirectorPage','VirtualPage') character set utf8 collate utf8_general_ci default 'SiteTree' (from enum('SiteTree','Page','GhostPage','ErrorPage','RedirectorPage','VirtualPage') character set utf8 collate utf8_general_ci default 'SiteTree')
# Field SiteTree_Live.ClassName: changed to enum('SiteTree','Page','GhostPage','Calendar','CalendarEvent','ErrorPage','RedirectorPage','VirtualPage') character set utf8 collate utf8_general_ci default 'SiteTree' (from enum('SiteTree','Page','GhostPage','ErrorPage','RedirectorPage','VirtualPage') character set utf8 collate utf8_general_ci default 'SiteTree')
# Field SiteTree_versions.ClassName: changed to enum('SiteTree','Page','GhostPage','Calendar','CalendarEvent','ErrorPage','RedirectorPage','VirtualPage') character set utf8 collate utf8_general_ci default 'SiteTree' (from enum('SiteTree','Page','GhostPage','ErrorPage','RedirectorPage','VirtualPage') character set utf8 collate utf8_general_ci default 'SiteTree')
# Email_BounceRecord
# QueuedEmail
# File
# Group
# LoginAttempt
# Member
# MemberPassword
# Permission
# Widget
# WidgetArea
# Page
# GhostPage
# Calendar
# Table Calendar: created
# Field Calendar.ID: created as int(11) not null auto_increment
# Field Calendar.DefaultEventDisplay: created as int(11) not null default '0'
# Field Calendar.DefaultDateHeader: created as varchar(50) character set utf8 collate utf8_general_ci
# Field Calendar.OtherDatesCount: created as int(11) not null default '0'
# Table Calendar_Live: created
# Field Calendar_Live.ID: created as int(11) not null auto_increment
# Field Calendar_Live.DefaultEventDisplay: created as int(11) not null default '0'
# Field Calendar_Live.DefaultDateHeader: created as varchar(50) character set utf8 collate utf8_general_ci
# Field Calendar_Live.OtherDatesCount: created as int(11) not null default '0'
# Table Calendar_versions: created
# Field Calendar_versions.ID: created as int(11) not null auto_increment
# Field Calendar_versions.RecordID: created as int(11) not null default '0'
# Field Calendar_versions.Version: created as int(11) not null default '0'
# Field Calendar_versions.WasPublished: created as tinyint(1) unsigned not null default '0'
# Field Calendar_versions.AuthorID: created as int(11) not null default '0'
# Field Calendar_versions.PublisherID: created as int(11) not null default '0'
# Field Calendar_versions.DefaultEventDisplay: created as int(11) not null default '0'
# Field Calendar_versions.DefaultDateHeader: created as varchar(50) character set utf8 collate utf8_general_ci
# Field Calendar_versions.OtherDatesCount: created as int(11) not null default '0'
# Index Calendar_versions.RecordID_Version: created as (RecordID,Version)
# Index Calendar_versions.RecordID: created as (RecordID)
# Index Calendar_versions.Version: created as (Version)
# Index Calendar_versions.AuthorID: created as (AuthorID)
# Index Calendar_versions.PublisherID: created as (PublisherID)
# CalendarEvent
# Table CalendarEvent: created
# Field CalendarEvent.ID: created as int(11) not null auto_increment
# Field CalendarEvent.Recursion: created as tinyint(1) unsigned not null default '0'
# Field CalendarEvent.CustomRecursionType: created as int(11) not null default '0'
# Field CalendarEvent.DailyInterval: created as int(11) not null default '0'
# Field CalendarEvent.WeeklyInterval: created as int(11) not null default '0'
# Field CalendarEvent.MonthlyInterval: created as int(11) not null default '0'
# Field CalendarEvent.MonthlyRecursionType1: created as int(11) not null default '0'
# Field CalendarEvent.MonthlyRecursionType2: created as int(11) not null default '0'
# Field CalendarEvent.MonthlyIndex: created as int(11) not null default '0'
# Field CalendarEvent.MonthlyDayOfWeek: created as int(11) not null default '0'
# Field CalendarEvent.CalendarID: created as int(11) not null default '0'
# Index CalendarEvent.CalendarID: created as (CalendarID)
# Table CalendarEvent_RecurringDaysOfWeek: created
# Field CalendarEvent_RecurringDaysOfWeek.ID: created as int(11) not null auto_increment
# Field CalendarEvent_RecurringDaysOfWeek.CalendarEventID: created as int(11) not null default '0'
# Field CalendarEvent_RecurringDaysOfWeek.RecurringDayOfWeekID: created as int(11) not null default '0'
# Index CalendarEvent_RecurringDaysOfWeek.CalendarEventID: created as (CalendarEventID)
# Index CalendarEvent_RecurringDaysOfWeek.RecurringDayOfWeekID: created as (RecurringDayOfWeekID)
# Table CalendarEvent_RecurringDaysOfMonth: created
# Field CalendarEvent_RecurringDaysOfMonth.ID: created as int(11) not null auto_increment
# Field CalendarEvent_RecurringDaysOfMonth.CalendarEventID: created as int(11) not null default '0'
# Field CalendarEvent_RecurringDaysOfMonth.RecurringDayOfMonthID: created as int(11) not null default '0'
# Index CalendarEvent_RecurringDaysOfMonth.CalendarEventID: created as (CalendarEventID)
# Index CalendarEvent_RecurringDaysOfMonth.RecurringDayOfMonthID: created as (RecurringDayOfMonthID)
# Table CalendarEvent_Live: created
# Field CalendarEvent_Live.ID: created as int(11) not null auto_increment
# Field CalendarEvent_Live.Recursion: created as tinyint(1) unsigned not null default '0'
# Field CalendarEvent_Live.CustomRecursionType: created as int(11) not null default '0'
# Field CalendarEvent_Live.DailyInterval: created as int(11) not null default '0'
# Field CalendarEvent_Live.WeeklyInterval: created as int(11) not null default '0'
# Field CalendarEvent_Live.MonthlyInterval: created as int(11) not null default '0'
# Field CalendarEvent_Live.MonthlyRecursionType1: created as int(11) not null default '0'
# Field CalendarEvent_Live.MonthlyRecursionType2: created as int(11) not null default '0'
# Field CalendarEvent_Live.MonthlyIndex: created as int(11) not null default '0'
# Field CalendarEvent_Live.MonthlyDayOfWeek: created as int(11) not null default '0'
# Field CalendarEvent_Live.CalendarID: created as int(11) not null default '0'
# Index CalendarEvent_Live.CalendarID: created as (CalendarID)
# Table CalendarEvent_versions: created
# Field CalendarEvent_versions.ID: created as int(11) not null auto_increment
# Field CalendarEvent_versions.RecordID: created as int(11) not null default '0'
# Field CalendarEvent_versions.Version: created as int(11) not null default '0'
# Field CalendarEvent_versions.WasPublished: created as tinyint(1) unsigned not null default '0'
# Field CalendarEvent_versions.AuthorID: created as int(11) not null default '0'
# Field CalendarEvent_versions.PublisherID: created as int(11) not null default '0'
# Field CalendarEvent_versions.Recursion: created as tinyint(1) unsigned not null default '0'
# Field CalendarEvent_versions.CustomRecursionType: created as int(11) not null default '0'
# Field CalendarEvent_versions.DailyInterval: created as int(11) not null default '0'
# Field CalendarEvent_versions.WeeklyInterval: created as int(11) not null default '0'
# Field CalendarEvent_versions.MonthlyInterval: created as int(11) not null default '0'
# Field CalendarEvent_versions.MonthlyRecursionType1: created as int(11) not null default '0'
# Field CalendarEvent_versions.MonthlyRecursionType2: created as int(11) not null default '0'
# Field CalendarEvent_versions.MonthlyIndex: created as int(11) not null default '0'
# Field CalendarEvent_versions.MonthlyDayOfWeek: created as int(11) not null default '0'
# Field CalendarEvent_versions.CalendarID: created as int(11) not null default '0'
# Index CalendarEvent_versions.RecordID_Version: created as (RecordID,Version)
# Index CalendarEvent_versions.RecordID: created as (RecordID)
# Index CalendarEvent_versions.Version: created as (Version)
# Index CalendarEvent_versions.AuthorID: created as (AuthorID)
# Index CalendarEvent_versions.PublisherID: created as (PublisherID)
# Index CalendarEvent_versions.CalendarID: created as (CalendarID)
# ErrorPage
# RedirectorPage
# VirtualPage
# Image
# Folder
# Image_Cached


[Notice] Undefined variable: alterList
GET /SilverStripe-test1/db/build

Line 199 in C:\wamp\www\SilverStripe-test1\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 197 of DatabaseAdmin.php
* DatabaseAdmin->doBuild(,1)
Line 100 of DatabaseAdmin.php
* DatabaseAdmin->build(HTTPRequest)
Line 162 of Controller.php
* Controller->handleAction(HTTPRequest)
Line 129 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(/db/build)
Line 118 of main.php

Avatar
dbeaugez

27 July 2009 at 5:30am Community Member, 1 Post

That just happened to me also. It looks like there's a fix already in SVN -- one line of code. Just open the module, MySQLDatabase.php, in your editor.

Find the alterTable function and add $alterList = array(); after $fieldSchemas = $indexSchemas = "";

That worked for me.

Avatar
Hour6

6 August 2009 at 3:13pm Community Member, 1 Post

Thanks, same thing just happened to me after updating to PHP 5.3, the fix worked like a charm.