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.

Customising the CMS /

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

Module which worked in 2.3.7 does not work in 2.4, 2.4.1


Go to End


1558 Views

Avatar
Victor

Community Member, 128 Posts

2 August 2010 at 1:07am

Edited: 02/08/2010 1:08am

There are two relevant php pages: in Module People

MathPublicPeoplePage.php

<?php

class MathPublicPeoplePage extends Page {
   static $db = array(
'lastname' => 'Text',
'position' => 'Text',
'position_senior'=> 'Text',
'position_junior'=> 'Text',
'position_pdf' => 'Text'
//'Classes' => 'Text'
   );

static $has_many = array(
      'CourseSections' => 'CourseSection'
   );


   function getCMSFields() {
        $fields = parent::getCMSFields();
        $fields->addFieldToTab('Root.Content.Main', new TextField('lastname'), 'Content');
        $fields->addFieldToTab('Root.Content.Main', new TextField('position'), 'Content');
        $fields->addFieldToTab('Root.Content.Main', new TextField('position_senior'), 'Content');
        $fields->addFieldToTab('Root.Content.Main', new TextField('position_junior'), 'Content');
        $fields->addFieldToTab('Root.Content.Main', new TextField('position_pdf'), 'Content');
        return $fields;
   }

}

class MathPublicPeoplePage_Controller extends Page_Controller {

}
?>

and in Module Courses

CourseSection.php

<?php

class CourseSection extends Page {
   static $db = array(
'CourseSection' => 'Text',
'DayTimeLocation1' => 'Text',
'DayTimeLocation2' => 'Text',
'DayTimeLocation3' => 'Text',
'DayTimeLocationOH1' => 'Text',
'DayTimeLocationOH2' => 'Text',
'DayTimeLocationOH3' => 'Text',
'SectionURL' => 'Text',
'Spring' => 'Text',
'Fall' => 'Text',
'Year' => 'Text'
   );
   static $has_one = array(
      'MyInstructor' => 'MathPublicPeoplePage'
   );



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

         $tablefield = new HasOneComplexTableField(
         $this,
         'MyInstructor',
         'MathPublicPeoplePage',
          array(
            'lastname' => 'Family Name'
         ),

         'getCMSFields_forPopup'
      );
//      $tablefield->setParentClass('CourseSection');
        $fields->addFieldToTab('Root.Content.Main', new TextField('CourseSection'), 'Content');
        $fields->addFieldToTab('Root.Content.Main', new TextField('Fall'), 'Content');
         $fields->addFieldToTab('Root.Content.Main', new TextField('Spring'), 'Content');
         $fields->addFieldToTab('Root.Content.Main', new TextField('Year'), 'Content');



         $fields->addFieldToTab( 'Root.Content.Instructor', $tablefield );
         $fields->addFieldToTab('Root.Content.Main', new TextField('SectionURL'), 'Content');
         $fields->addFieldToTab('Root.Content.Main', new TextField('DayTimeLocation1'), 'Content');
         $fields->addFieldToTab('Root.Content.Main', new TextField('DayTimeLocation2'), 'Content');
          $fields->addFieldToTab('Root.Content.Main', new TextField('DayTimeLocation3'), 'Content');
          $fields->addFieldToTab('Root.Content.Main', new TextField('DayTimeLocationOH1'), 'Content');
         $fields->addFieldToTab('Root.Content.Main', new TextField('DayTimeLocationOH2'), 'Content');
          $fields->addFieldToTab('Root.Content.Main', new TextField('DayTimeLocationOH3'), 'Content');

        return $fields;
   }
}

class CourseSection_Controller extends Page_Controller {

}
?>

Everything worked in 2.3.7 but if I activate the second module in 2.4.0 or 2.4.1 dev/build works but any attempt to access website returns

User Error] Couldn't run query: SELECT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", "SiteTree_Live"."LastEdited", "SiteTree_Live"."URLSegment", "SiteTree_Live"."Title", "SiteTree_Live"."MenuTitle", "SiteTree_Live"."Content", "SiteTree_Live"."MetaTitle", "SiteTree_Live"."MetaDescription", "SiteTree_Live"."MetaKeywords", "SiteTree_Live"."ExtraMeta", "SiteTree_Live"."ShowInMenus", "SiteTree_Live"."ShowInSearch", "SiteTree_Live"."HomepageForDomain", "SiteTree_Live"."ProvideComments", "SiteTree_Live"."Sort", "SiteTree_Live"."HasBrokenFile", "SiteTree_Live"."HasBrokenLink", "SiteTree_Live"."Status", "SiteTree_Live"."ReportClass", "SiteTree_Live"."CanViewType", "SiteTree_Live"."CanEditType", "SiteTree_Live"."ToDo", "SiteTree_Live"."Version", "SiteTree_Live"."Priority", "SiteTree_Live"."ParentID", "CourseSection_Live"."CourseSection_Live", "CourseSection_Live"."DayTimeLocation1", "CourseSection_Live"."DayTimeLocation2", "CourseSection_Live"."DayTimeLocation3", "CourseSection_Live"."DayTimeLocationOH1", "CourseSection_Live"."DayTimeLocationOH2", "CourseSection_Live"."DayTimeLocationOH3", "CourseSection_Live"."SectionURL", "CourseSection_Live"."Spring", "CourseSection_Live"."Fall", "CourseSection_Live"."Year", "CourseSection_Live"."MyInstructorID", "MathPublicPeoplePage_Live"."lastname", "MathPublicPeoplePage_Live"."position", "MathPublicPeoplePage_Live"."position_senior", "MathPublicPeoplePage_Live"."position_junior", "MathPublicPeoplePage_Live"."position_pdf", "ErrorPage_Live"."ErrorCode", "RedirectorPage_Live"."RedirectionType", "RedirectorPage_Live"."ExternalURL", "RedirectorPage_Live"."LinkToID", "VirtualPage_Live"."VersionID", "VirtualPage_Live"."CopyContentFromID", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName" FROM "SiteTree_Live" LEFT JOIN "CourseSection_Live" ON "CourseSection_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "MathPublicPeoplePage_Live" ON "MathPublicPeoplePage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "ErrorPage_Live" ON "ErrorPage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "RedirectorPage_Live" ON "RedirectorPage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "VirtualPage_Live" ON "VirtualPage_Live"."ID" = "SiteTree_Live"."ID" WHERE ("URLSegment" = 'home' AND "ParentID" = 0) ORDER BY "Sort" LIMIT 1 Unknown column 'CourseSection_Live.CourseSection_Live' in 'field list'
GET /department/

Line 536 in /Applications/MAMP/htdocs/department/sapphire/core/model/MySQLDatabase.php

Source

527 	}
528 	
529 	function databaseError($msg, $errorLevel = E_USER_ERROR) {
530 		// try to extract and format query
531 		if(preg_match('/Couldn\'t run query: ([^\|]*)\|\s*(.*)/', $msg, $matches)) {
532 			$formatter = new SQLFormatter();
533 			$msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
534 		}
535 		
536 		user_error($msg, $errorLevel);
537 	}
538 	
539 	/**
540 	 * Return a boolean type-formatted string
541 	 * 
542 	 * @param array $values Contains a tokenised list of info about this data type
Trace

Couldn't run query: SELECT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", "SiteTree_Live"."LastEdited", "SiteTree_Live"."URLSegment", "SiteTree_Live"."Title", "SiteTree_Live"."MenuTitle", "SiteTree_Live"."Content", "SiteTree_Live"."MetaTitle", "SiteTree_Live"."MetaDescription", "SiteTree_Live"."MetaKeywords", "SiteTree_Live"."ExtraMeta", "SiteTree_Live"."ShowInMenus", "SiteTree_Live"."ShowInSearch", "SiteTree_Live"."HomepageForDomain", "SiteTree_Live"."ProvideComments", "SiteTree_Live"."Sort", "SiteTree_Live"."HasBrokenFile", "SiteTree_Live"."HasBrokenLink", "SiteTree_Live"."Status", "SiteTree_Live"."ReportClass", "SiteTree_Live"."CanViewType", "SiteTree_Live"."CanEditType", "SiteTree_Live"."ToDo", "SiteTree_Live"."Version", "SiteTree_Live"."Priority", "SiteTree_Live"."ParentID", "CourseSection_Live"."CourseSection_Live", "CourseSection_Live"."DayTimeLocation1", "CourseSection_Live"."DayTimeLocation2", "CourseSection_Live"."DayTimeLocation3", "CourseSection_Live"."DayTimeLocationOH1", "CourseSection_Live"."DayTimeLocationOH2", "CourseSection_Live"."DayTimeLocationOH3", "CourseSection_Live"."SectionURL", "CourseSection_Live"."Spring", "CourseSection_Live"."Fall", "CourseSection_Live"."Year", "CourseSection_Live"."MyInstructorID", "MathPublicPeoplePage_Live"."lastname", "MathPublicPeoplePage_Live"."position", "MathPublicPeoplePage_Live"."position_senior", "MathPublicPeoplePage_Live"."position_junior", "MathPublicPeoplePage_Live"."position_pdf", "ErrorPage_Live"."ErrorCode", "RedirectorPage_Live"."RedirectionType", "RedirectorPage_Live"."ExternalURL", "RedirectorPage_Live"."LinkToID", "VirtualPage_Live"."VersionID", "VirtualPage_Live"."CopyContentFromID", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName" FROM "SiteTree_Live" LEFT JOIN "CourseSection_Live" ON "CourseSection_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "MathPublicPeoplePage_Live" ON "MathPublicPeoplePage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "ErrorPage_Live" ON "ErrorPage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "RedirectorPage_Live" ON "RedirectorPage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "VirtualPage_Live" ON "VirtualPage_Live"."ID" = "SiteTree_Live"."ID" WHERE ("URLSegment" = 'home' AND "ParentID" = 0) ORDER BY "Sort" LIMIT 1 Unknown column 'CourseSection_Live.CourseSection_Live' in 'field list' 
Line 536 of MySQLDatabase.php
MySQLDatabase->databaseError(Couldn't run query: SELECT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", "SiteTree_Live"."LastEdited", "SiteTree_Live"."URLSegment", "SiteTree_Live"."Title", "SiteTree_Live"."MenuTitle", "SiteTree_Live"."Content", "SiteTree_Live"."MetaTitle", "SiteTree_Live"."MetaDescription", "SiteTree_Live"."MetaKeywords", "SiteTree_Live"."ExtraMeta", "SiteTree_Live"."ShowInMenus", "SiteTree_Live"."ShowInSearch", "SiteTree_Live"."HomepageForDomain", "SiteTree_Live"."ProvideComments", "SiteTree_Live"."Sort", "SiteTree_Live"."HasBrokenFile", "SiteTree_Live"."HasBrokenLink", "SiteTree_Live"."Status", "SiteTree_Live"."ReportClass", "SiteTree_Live"."CanViewType", "SiteTree_Live"."CanEditType", "SiteTree_Live"."ToDo", "SiteTree_Live"."Version", "SiteTree_Live"."Priority", "SiteTree_Live"."ParentID", "CourseSection_Live"."CourseSection_Live", "CourseSection_Live"."DayTimeLocation1", "CourseSection_Live"."DayTimeLocation2", "CourseSection_Live"."DayTimeLocation3", "CourseSection_Live"."DayTimeLocationOH1", "CourseSection_Live"."DayTimeLocationOH2", "CourseSection_Live"."DayTimeLocationOH3", "CourseSection_Live"."SectionURL", "CourseSection_Live"."Spring", "CourseSection_Live"."Fall", "CourseSection_Live"."Year", "CourseSection_Live"."MyInstructorID", "MathPublicPeoplePage_Live"."lastname", "MathPublicPeoplePage_Live"."position", "MathPublicPeoplePage_Live"."position_senior", "MathPublicPeoplePage_Live"."position_junior", "MathPublicPeoplePage_Live"."position_pdf", "ErrorPage_Live"."ErrorCode", "RedirectorPage_Live"."RedirectionType", "RedirectorPage_Live"."ExternalURL", "RedirectorPage_Live"."LinkToID", "VirtualPage_Live"."VersionID", "VirtualPage_Live"."CopyContentFromID", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName" FROM "SiteTree_Live" LEFT JOIN "CourseSection_Live" ON "CourseSection_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "MathPublicPeoplePage_Live" ON "MathPublicPeoplePage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "ErrorPage_Live" ON "ErrorPage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "RedirectorPage_Live" ON "RedirectorPage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "VirtualPage_Live" ON "VirtualPage_Live"."ID" = "SiteTree_Live"."ID" WHERE ("URLSegment" = 'home' AND "ParentID" = 0) ORDER BY "Sort" LIMIT 1 | Unknown column 'CourseSection_Live.CourseSection_Live' in 'field list',256) 
Line 134 of MySQLDatabase.php
MySQLDatabase->query(SELECT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", "SiteTree_Live"."LastEdited", "SiteTree_Live"."URLSegment", "SiteTree_Live"."Title", "SiteTree_Live"."MenuTitle", "SiteTree_Live"."Content", "SiteTree_Live"."MetaTitle", "SiteTree_Live"."MetaDescription", "SiteTree_Live"."MetaKeywords", "SiteTree_Live"."ExtraMeta", "SiteTree_Live"."ShowInMenus", "SiteTree_Live"."ShowInSearch", "SiteTree_Live"."HomepageForDomain", "SiteTree_Live"."ProvideComments", "SiteTree_Live"."Sort", "SiteTree_Live"."HasBrokenFile", "SiteTree_Live"."HasBrokenLink", "SiteTree_Live"."Status", "SiteTree_Live"."ReportClass", "SiteTree_Live"."CanViewType", "SiteTree_Live"."CanEditType", "SiteTree_Live"."ToDo", "SiteTree_Live"."Version", "SiteTree_Live"."Priority", "SiteTree_Live"."ParentID", "CourseSection_Live"."CourseSection_Live", "CourseSection_Live"."DayTimeLocation1", "CourseSection_Live"."DayTimeLocation2", "CourseSection_Live"."DayTimeLocation3", "CourseSection_Live"."DayTimeLocationOH1", "CourseSection_Live"."DayTimeLocationOH2", "CourseSection_Live"."DayTimeLocationOH3", "CourseSection_Live"."SectionURL", "CourseSection_Live"."Spring", "CourseSection_Live"."Fall", "CourseSection_Live"."Year", "CourseSection_Live"."MyInstructorID", "MathPublicPeoplePage_Live"."lastname", "MathPublicPeoplePage_Live"."position", "MathPublicPeoplePage_Live"."position_senior", "MathPublicPeoplePage_Live"."position_junior", "MathPublicPeoplePage_Live"."position_pdf", "ErrorPage_Live"."ErrorCode", "RedirectorPage_Live"."RedirectionType", "RedirectorPage_Live"."ExternalURL", "RedirectorPage_Live"."LinkToID", "VirtualPage_Live"."VersionID", "VirtualPage_Live"."CopyContentFromID", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName" FROM "SiteTree_Live" LEFT JOIN "CourseSection_Live" ON "CourseSection_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "MathPublicPeoplePage_Live" ON "MathPublicPeoplePage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "ErrorPage_Live" ON "ErrorPage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "RedirectorPage_Live" ON "RedirectorPage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "VirtualPage_Live" ON "VirtualPage_Live"."ID" = "SiteTree_Live"."ID" WHERE ("URLSegment" = 'home' AND "ParentID" = 0) ORDER BY "Sort" LIMIT 1,256) 
Line 127 of DB.php
DB::query(SELECT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", "SiteTree_Live"."LastEdited", "SiteTree_Live"."URLSegment", "SiteTree_Live"."Title", "SiteTree_Live"."MenuTitle", "SiteTree_Live"."Content", "SiteTree_Live"."MetaTitle", "SiteTree_Live"."MetaDescription", "SiteTree_Live"."MetaKeywords", "SiteTree_Live"."ExtraMeta", "SiteTree_Live"."ShowInMenus", "SiteTree_Live"."ShowInSearch", "SiteTree_Live"."HomepageForDomain", "SiteTree_Live"."ProvideComments", "SiteTree_Live"."Sort", "SiteTree_Live"."HasBrokenFile", "SiteTree_Live"."HasBrokenLink", "SiteTree_Live"."Status", "SiteTree_Live"."ReportClass", "SiteTree_Live"."CanViewType", "SiteTree_Live"."CanEditType", "SiteTree_Live"."ToDo", "SiteTree_Live"."Version", "SiteTree_Live"."Priority", "SiteTree_Live"."ParentID", "CourseSection_Live"."CourseSection_Live", "CourseSection_Live"."DayTimeLocation1", "CourseSection_Live"."DayTimeLocation2", "CourseSection_Live"."DayTimeLocation3", "CourseSection_Live"."DayTimeLocationOH1", "CourseSection_Live"."DayTimeLocationOH2", "CourseSection_Live"."DayTimeLocationOH3", "CourseSection_Live"."SectionURL", "CourseSection_Live"."Spring", "CourseSection_Live"."Fall", "CourseSection_Live"."Year", "CourseSection_Live"."MyInstructorID", "MathPublicPeoplePage_Live"."lastname", "MathPublicPeoplePage_Live"."position", "MathPublicPeoplePage_Live"."position_senior", "MathPublicPeoplePage_Live"."position_junior", "MathPublicPeoplePage_Live"."position_pdf", "ErrorPage_Live"."ErrorCode", "RedirectorPage_Live"."RedirectionType", "RedirectorPage_Live"."ExternalURL", "RedirectorPage_Live"."LinkToID", "VirtualPage_Live"."VersionID", "VirtualPage_Live"."CopyContentFromID", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName" FROM "SiteTree_Live" LEFT JOIN "CourseSection_Live" ON "CourseSection_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "MathPublicPeoplePage_Live" ON "MathPublicPeoplePage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "ErrorPage_Live" ON "ErrorPage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "RedirectorPage_Live" ON "RedirectorPage_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "VirtualPage_Live" ON "VirtualPage_Live"."ID" = "SiteTree_Live"."ID" WHERE ("URLSegment" = 'home' AND "ParentID" = 0) ORDER BY "Sort" LIMIT 1,256) 
Line 386 of SQLQuery.php
SQLQuery->execute() 
Line 2883 of DataObject.php
DataObject->instance_get_one("URLSegment" = 'home' AND "ParentID" = 0,) 
Line 2807 of DataObject.php
DataObject::get_one(SiteTree,"URLSegment" = 'home' AND "ParentID" = 0) 
Line 99 of ModelAsController.php
ModelAsController->getNestedController() 
Line 64 of ModelAsController.php
ModelAsController->handleRequest(SS_HTTPRequest) 
Line 111 of RootURLController.php
RootURLController->handleRequest(SS_HTTPRequest) 
Line 281 of Director.php
Director::handleRequest(SS_HTTPRequest,Session) 
Line 124 of Director.php
Director::direct(/) 
Line 127 of main.php

It was tested on brand new installation of 2.4.1 and on old one, updated from 2.3.7

Any suggestions what should be modified?

Thanks. Victor