Hi Aaron

Given that this problem has only turned up in the the last release of 
1.1 (the site was working happily prior to that), moving to 1.2 would be 
overkill (just refactoring alone would take weeks of work).  For now I 
am moving back to an earlier release, but I would rather find the bug 
and fix it thus improving Cake.

Regards,
Langdon




aaron bauman wrote:
> I'm using cake 1.2 and i have many 2 or 3 word models with abundant
> belongsTo relationships and I haven't run into this problem.
> 
> jump on the bandwagon
> 
> /a
> 
> 
> On Apr 22, 8:27 pm, Langdon Stevenson <[EMAIL PROTECTED]>
> wrote:
>> I have finally nailed down the issue and am pleased to find that I am
>> not going mad after all.
>>
>> It appears that when a model with a two word name (like FooBar1) is
>> loaded by a hasMany relationship and has a belongsTo relationship to the
>> parent that loaded it then PHP will fail and return a blank page.
>>
>> If you run the same test with the same name but make it one word (like
>> Foobar2) then it works fine.
>>
>> Another interesting point to note is that if you have models called
>> FooBar and Foobar together then it works too.
>>
>> Ultimately it appears that Cake is not handling the belongsTo
>> relationship with names with two words.
>>
>> I have set up a completely new copy of Cake and reproduced the problem
>> with it.  This has (mostly) ruled out anything in my application or its
>> setup as being the problem (I haven't tried it on another server).
>>
>> The error is reproducible using the following process:
>>
>> 1. Configure a clean copy of Cake 1.1.19.6261 to use a database (doesn't
>> matter which)
>>
>> 2. Create:
>>
>> app/controllers/trials_controller.php
>> -------------------------------------
>> <?php
>> Class trialsController extends Controller
>> {
>>         var $uses = array('FooBar1', 'Foobar2');
>>
>>         function index ()
>>         {
>>
>>         }}
>>
>> ?>
>>
>> app/model/foo_bar1.php
>> ----------------------
>> <?php
>> Class FooBar1 extends Model
>> {
>>         var $name = 'FooBar1'
>>         var $useTable = 'some_table1';
>>         var $hasMany = array('EenyMeeny');}
>>
>> ?>
>>
>> app/model/eeny_meeny1.php
>> -------------------------
>> <?php
>> Class EenyMeeny1 extends Model
>> {
>>         var $name = 'EenyMeeny1'
>>         var $useTable = 'some_table2';
>>         var $belongsTo = array('FooBar1');}
>>
>> ?>
>>
>> app/model/foobar2.php
>> ---------------------
>> <?php
>> Class Foobar2 extends Model
>> {
>>         var $name = 'Foobar2'
>>         var $useTable = 'some_table1';
>>         var $hasMany = array('Eenymeeny2');}
>>
>> ?>
>>
>> app/model/eenymeeny2.php
>> ------------------------
>> <?php
>> Class Eenymeeny2 extends Model
>> {
>>         var $name = 'Eenymeeny2'
>>         var $useTable = 'some_table2';
>>         var $belongsTo = array('Foobar2');}
>>
>> ?>
>>
>> app/views/trials/index.thtml
>> ----------------------------
>> Some text.
>>
>> Try to view:
>>
>> http://<yourserver>/trials/index
>>
>> The result will be a blank screen.
>>
>> However if you remove the hasMany entry for FooBar1
>>
>> <?php
>> Class trialsController extends Controller
>> {
>>         var $uses = array('Foobar2');
>>
>>         function index ()
>>         {
>>
>>         }}
>>
>> ?>
>>
>> and try again, you will get the default layout with "Some text." Displayed.
>>
>> I think that this demonstrates the problem effectively.  The next
>> question is: how to fix it?  I am assuming that this is a bug in the
>> core model code.  I have spent some time looking, but don't know enough
>> about the core code it to be able to see where the problem is occurring.
>>
>> Any suggestions welcome.  If I can identify where the problem is
>> occurring, then I will look into submitting a patch.
>>
>> Regards,
>> Langdon
>>
>> Langdon Stevenson wrote:
>>> I have a very strange problem appeared with a site that I have been
>>> working on for some time.
>>> This site is built with Cake version 1.1.19.6305 running on
>>> Apache/MySQL/Linux with PHP 5.
>>> The site has about 30 models, most have multiple hasMany relationships.
>>> Each of those relationships have a corresponding belongsTo from the
>>> child to the parent.  This has all worked fine with no problem in the
>>> past.
>>> I went to test some functionality today that I haven't touched for a
>>> while and discovered that any model that is loaded that has a belongsTo
>>> relationship with a model that has already been loaded caused a blank
>>> page to be returned.
>>> No Cake debug output, no error in Apache logs, just nothing at all.
>>> Eventually I removed all of the belongsTo relationships in the chain of
>>> models for one of the pages with the problem.  The page now loads fine.
>>>    But if I add back in any belongsTo relationship it breaks again.
>>> I am stumped by this.  I have reviewed all of the models to make sure
>>> that one isn't corrupt (trailing space issue for instance).  Can't find
>>> anything of that nature.
>>> If anyone can suggest anything I would be very grateful.
>>> Regards,
>>> Langdon
> > 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to