The node_type_get_types() function isshould be immutable. The test enviroment is attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nevergone’s picture

FileSize
1.39 KB
nevergone’s picture

Status: Active » Needs review
FileSize
1.36 KB

corrected patch (permission error)

chx’s picture

Title: node_type_get_types() is immutable » node_type_get_types() should be immutable
Status: Needs review » Reviewed & tested by the community
Dries’s picture

While technically correct, I wonder if this needs fixing. We probably return a lot of variables that probably should be made immutable. That said, I'm not opposed to this patch but it might warrant some extra discussion.

catch’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Agreed. As far as I know, every cloned variable leads to double memory consumption, also this is a duplicate of #154859: Document that cached entity objects are not necessarily cloned any more.

nevergone’s picture

simple test environment, create 5 node:

for ($i = 0; $i < 5; $i++) {
  $node = node_type_get_type('article');
  $node->language = LANGUAGE_NONE;
  $node->title = $i. '. title';
  $node->body[LANGUAGE_NONE][0]['format'] = 1; // plain text
  $node->body[LANGUAGE_NONE][0]['value'] = $i. '. body';
  $node = node_submit($node);
  node_save($node);
  unset($node);
}