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.

Data Model Questions /

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

dev/build weird behaviour, "build.php" download popup


Go to End


2 Posts   1974 Views

Avatar
mattconfusion

Community Member, 48 Posts

19 May 2011 at 8:09pm

Hi to all

I have been experiencing weird behaviour on my server (and oddly not locally) when running dev/build.
The server is running a few Silvertripe websites perfectly so I don't think it's a php configuration problem.
Instead of printing out the usual grey screen with "Creating database tables" and "Creating database records" the browser download popup appears, asking me if I want to download the nonsense file build.php, which is empty of course.

Instead, when running dev/build/ (notice the added slash at the end) the build starts, but does not perform the "Creating database records" task.
This behaviour seems to be linked to three code files. I guess it has somthing to do with database relations. I try to reproduce them here without having to explain the whole context of this big project i'm working on, it would take too much time and space.



class ResearchFieldsContainer extends Page {

	public static $db = array(
	);

	public static $has_one = array(
	);
	
	 static $has_many = array(
      
	  'ResearchFields' =>'ResearchFields'
   );
   
   
   
 class ResearchFields extends DataObject {

   
	static $db = array(
		'Name' => "varchar(200)",
		'Source' => "Enum('fromTechSpec,fromDescriptionPage')",
		'NameOfFieldOfDescriptionPage' => "varchar(200)",
		'Code' => "varchar(30)"
	);
   
    
   static $has_one = array(
   
		"TechSpec" => "TechSpec",
		"ResearchFieldsContainer" => "ResearchFieldsContainer"


   );  
   
   
   TechSpec is another DataObject who gets related to other pages in my system, it's an old file that has always worked. Anyway... 
   
   
   class TechSpec extends DataObject {

   
      static $db = array(
	  'Code' => 'varchar(30)',
      'Description' => 'varchar(400)',
	  'Measure' => 'varchar(20)',
	  'EditChoice' => "Enum('free_text,Predefined_values')"
   );
   
    
   static $has_one = array(
      'TechSpecPage' => 'TechSpecPage',
	  'Image' => 'Image'
   );

    static $has_many = array(
      'TechSpecPredefinedValue' => 'TechSpecPredefinedValue',
	  'ResearchFields' => 'ResearchFields'

   );
   
   
   class TechSpecPredefinedValue extends DataObject {

   
      static $db = array(
	  'Value' => 'varchar(255)'

   );
   
    
   static $has_one = array(
      'TechSpec' => 'TechSpec'
   );

Removing files ResearchFields and ResearchFieldsContainer solves the problem. But of course i need them and i need this relation model. HELP, Please!

Avatar
mattconfusion

Community Member, 48 Posts

19 May 2011 at 10:52pm

Just an update.
I found out two things. One is that the culprits of the weird behaviour are not the files listed, but other completely normal objects i will explain later. The second thing is that with a copy of the same site and code BUT WITHOUT the "translatable" code in config, there are no errors.
The config lines i'm referencing to are

Translatable::set_default_locale('it_IT');
Object::add_extension('SiteConfig', 'Translatable');



class ServiceCostPage extends Page {

	public static $db = array(
	
		"MinimumPostageCost" => "Currency",
		"PostageCostFactor" => "Float",
		"FixedInsurance" => "Currency",
		"InsuranceCostFactor" => "Float"
	);

	public static $has_one = array(
	);
	
	 static $has_many = array(
      
	  'WeightClass' =>'WeightClass', //simple dataobject containing numeric values and boolean 
	  'Shipment' => 'Shipment'    //The Other Culprit
   );
	
-----------------

class Shipment extends DataObject {

      static $db = array(
      'Name' => 'Varchar(50)',
	  'NameOfCalculatingClass' => 'Varchar(250)',
	  'Insured' => 'Boolean',
	  'Service' => 'Boolean'
  );
   
    
   static $has_one = array(
	  'Image' => 'Image',
	  'Holder' => 'ShipmentHolder',
	  'ServiceCostPage' => 'ServiceCostPage' //selected from a dropdownfield
   );

----

I post here the other files relation involved:

class WeightClass extends DataObject {

   
	static $db = array(
	
		'FromKgs' => 'float',
		'ToKgs' => 'float',
		'UseWeightFromProductProfile' => 'boolean',
		'Price' => 'Currency'
	);
   
    
   static $has_one = array(
   
		"ServiceCostPage" => "ServiceCostPage",

   );

ShipmentHolder is just an holder with a dataobject manager table holding the Shipment objects.

HELP Please!