Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Fix static variable caching of instances causing infinite nesting in JForm, #1355

Closed
wants to merge 1 commit into from

Conversation

klas
Copy link
Contributor

@klas klas commented Jul 12, 2012

@pasamio
Copy link
Contributor

pasamio commented Jul 13, 2012

Sounds like a good case for a unit test as well to verify that we don't break things going forwards either.

@LouisLandry
Copy link
Contributor

@klas The reason we moved away from having method statics is because it is impossible to test with them because you cannot access the array in any way to modify it -- even from within the class or it's children. Is it possible what you are seeing is a side-effect of late static binding or something? The code definitely seems to work as it is now. Can you put together a small POC gist or something that shows things not working we can look at?

@klas
Copy link
Contributor Author

klas commented Oct 4, 2012

Hi,

I don't think it is a sideeffect - it makes sense as class static variable has the same value across instances so when you create an instance and store it inside a class you start an indefinite loop.

I found this as my debugger (XDebug) kept on crashing - I presume debugger tries to trace all variables independently while PHP interpreter obviously has a way to break such loops as I haven't found any noticeable differences in memory usage or timings.

As I see it, the way to properly solve it is to either use method scoped static variable or - this would be much better imho - for now use factory class to create and store instances for all platform methods and in the future add abstract factory class to avoid modifying factory each time new classes are addded.

@eddieajau
Copy link
Contributor

Thanks for looking into the problem. I'm going to close this PR for now since we don't have a mergable solution.

@klas
Copy link
Contributor Author

klas commented May 31, 2014

@dongilbert @mbabker @phproberto this issue still exist (in all major classes, not just JForm). My proposal in the PR comment was to create a generic factory - just for creating and storing joomla class instances, something like code here #1354 (comment)

Could any of you take another look at this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants