Jump to:

3433 Posts in 1058 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » dev/build weird behaviour, "build.php" download popup

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

Page: 1
Go to End
Author Topic: 1089 Views
  • mattconfusion
    Avatar
    Community Member
    48 Posts

    dev/build weird behaviour, "build.php" download popup Link to this post

    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!

  • mattconfusion
    Avatar
    Community Member
    48 Posts

    Re: dev/build weird behaviour, "build.php" download popup Link to this post

    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!

    1089 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.