-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEW Update SS_ConfigStaticManifest to use Reflection #4148
NEW Update SS_ConfigStaticManifest to use Reflection #4148
Conversation
Look at all that no code that's no longer there. :) |
35eb82c
to
893a901
Compare
Tests failed on PHP 5.3 - damn syntaxes. |
Note: If merged then some of this stuff will need to have a deprecation warning in future ss 3 releases. |
if(class_exists($dataClass)) { | ||
$reflection = new ReflectionClass($dataClass); | ||
$dataClass = $reflection->name; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why has this been added? Did the old manifest fix case sensitivity issues that the new version doesn’t?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll get back to you XD (There is a reason but i'm not sure this is the right fix).
e4d8982
to
8be04c7
Compare
I found a bug in submitting this pull request. DataObject::has_own_table() doesn't work with class names which don't exactly match the class name (ie. they're case-sensitive). This is because the "class name" in Config::inst()->get("ClassName', 'blah') is case-sensitive. The following returns null for incorrectly cased class names: The thing that highlighted this was the failure of DataObjectTest::testGetCaseInsensitive().
This tries to prove that using a lowercase class name won't affect whether or not the result will be returned. The should have been failing, however reason this has passed up until this point is because the query is built incorrectly. DataObject::has_own_table()'s failure has a knock-on affect which prevents ClassInfo::ancestry($class, $tableOnly = true) working correctly. When only looking up class ancestors with tables, the lower-case table name will be ignored (DataObject::has_own_table() == false) and no SQL will be added to fetch data from that table. The given test has passed like so up until now:
What happens when you query the subclass is that it gets completely ignored and only the base class is queried:
The fix i've implemented is in DataObject::has_own_table() and in ClassInfo::ancestry() so that only correct case-sensitive class names are used. This fixes the issue because the config system is case-sensitive when looking up class names, which is the root cause of this bug. If you need me to split this out into 2 commits let me know. |
I see case-insensitivity has been suggested in #3381 - it would be good as long as performance doesn't take a hit. |
@micmania1 you probably need to refactor that classname normalisation code you added into ClassInfo into a new method, so that other parts of the codebase are able to access it. Normalising the table name from a class is one such case. |
I'd like to wait and see a response in #3381 before this is merged given that this is easier to make case-insensitive. @tractorcow I do agree, but I plan to tackle ClassInfo at some point so I'll give some proper thought to where that should belong then. |
@micmania1 PHP 5.5.18. No opcode caching, running in dev mode. tl;dr
Website A
Accessing / after 25 runs.Times:
Memory:
Performing a flush on the command line 5 times.Command line was used to avoid the token redirect. Times:
Memory:
Website B:SS 3.1.12 Accessing / after 25 runs.Times:
Memory:
Performing a flush on the command line 5 times.Times:
Memory:
So we can see a good speed up there with the flush! About 2.3~ seconds faster now. On the Website A there is a memory saving of 600k~ on general requests, on the larger site we are just over 1Mb. There seems to be no real speed change in general use of the site. Developing Website A with this patch has been great! It's so fast to flush and in many cases don't even need to. |
So, do we want to move this along? How about we rebase, please :) |
Yes please :) Would love to see it merged. |
Still waiting on #3381 @sminnee @hafriedlander |
1e5337f
to
4b1475b
Compare
4b1475b
to
9f91b47
Compare
Rebased!!! |
Woohoo! |
NEW Update SS_ConfigStaticManifest to use Reflection
This is the PR as discussed in #4029
It completely removes the static manifest and replaces the SS_ConfigStaticManifest implementation with Reflection.
Tests on PHP 5.5 showed no speed decrease but saved 0.5mb memory per page load on a base install, loading the home page.