Skip to content
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

Refactor active record meta data to be static field #2265

Conversation

klimov-paul
Copy link
Member

Active Record meta data has been refactored to be static field.
Note about overriding "CActiveRecord::__construct()" has been added.

Relates to #2251

@klimov-paul
Copy link
Member Author

This fix reduces memory usage a little.
Memory test:

$memoryBefore = memory_get_usage();
$models = Item::model()->findAll(); // 62 records
$memoryAfter = memory_get_usage();
var_dump($memoryAfter-$memoryBefore);

Original memory usage delta 966960.
After refactor memory usage delta 964152.

return $this->_md=self::model(get_class($this))->_md;
$className=get_class($this);
if(!array_key_exists($className,self::$_md))
self::$_md[$className]=new CActiveRecordMetaData($this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we change this, there shouldn't be a reference to the first model creating a MetaData object in CActiveRecordMetaData.
Should be refactored to store only the class name instead of the model as it is not needed there anyway.
See CActiveRecordMetaData line 2300, 2361 and constructor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

cebe and others added 4 commits March 27, 2013 23:47
* Rupert-RR-2131-add-accept-header-parsing:
  php doc adjustments after yiisoft#2132
  Yii code style correction
  Removed unnecessary spaces.
  Transferred data for unit tests from the test functions into data providers.
  Undo accidental permissions change on bootstrap.php
  Added unit test file for CHttpRequest for the methods parseAcceptHeader() and compareAcceptTypes(). Modified the regexp in parseAcceptHeader() to accept wildcards in the path. Modified the description of compareAcceptTypes() to better reflect the comparison result (higher preference returns lower value, so that most preferred is first in the array).
  parseAcceptHeader() function description tidy up.
  Typo corrections and code tidy up.
  Altered parseAcceptHeader() to use only one regexp. Thanks to Ka on StackExchange for this expression.
  Typo corrections
  Separated out parse and compare functions. Reduced regular expression count to 2 from 3. Modified MIME type array map structure.
  Added yiisoft#135 back in changelog, which got lost somehow..
  Moved position of line to follow numerical order.
  Enh yiisoft#2131: Added Accept header parsing to CHttpRequest to give an array of accepted types in order of preference
…imov-paul/yii into 2251-refactor-active-record-meta-data
@klimov-paul
Copy link
Member Author

PR update.
However it shows some Yii master commits as own changes.
I have no idea why this happens. Could it be a problem?

@samdark
Copy link
Member

samdark commented Mar 28, 2013

Possibly. This one should be merged manually it least with verifying that everything is OK.

@klimov-paul
Copy link
Member Author

Migrated to #2269

@cebe
Copy link
Member

cebe commented Mar 28, 2013

I have no idea why this happens. Could it be a problem?

Don't think there is a problem with it, git will handle it just right, only thing is a weird behavior of github which shows commits that do not belong here. reported it to GH support.

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

Successfully merging this pull request may close these issues.

None yet

4 participants