from comment #19 of #1567428: Active trail tests, in order to handle static variables in Drupal 8 we should convert every use of statics to instead be protected properties of proper objects. The result of this effort will be that we properly register objects into the Dependency Injection Container and perhaps do away with drupal_static() and drupal_static_reset().

Comments

cosmicdreams’s picture

Issue tags:+MN code sprint
Crell’s picture

This isn't a task unto itself per se, I think, but rather a side-effect of other work. Eg, the menu system needs to be turned into a proper set of objects (after routing it ripped out), and the statics eliminated as part of that. Simply creating objects somewhere that hold statics instead of them being inside functions buys us nothing.

sun’s picture

Title:Convert all statics to Object Properties» [meta] Remove all drupal_static()s + drupal_static() itself
Issue summary:View changes
Issue tags:-MN code sprint+@deprecated, +DIE

HEAD has 93 calls to drupal_static()

Most of them in legacy procedural code that is actively being converted into service classes right now. In essence, those calls should "magically vanish" ;-)

However, for some strange reason, some drupal_static()s were taken over as-is into object-oriented code that is clean otherwise. For example, Drupal\Core\Cache\DatabaseBackend still maintains the state of cache tags via drupal_static().

In any case, these drupal_static()s (1) prevent us from properly using and leveraging the kernel and (2) harm tests.

tim.plunkett’s picture

Priority:Normal» Major
Issue tags:+beta target

Spoke with @alexpott in IRC, he said this did not qualify for a beta or release blocker, but agreed it should be a beta target.

catch’s picture

The database backend should get fixed by #918538: Decouple cache tags from cache bins (it should have been converted to a static property of the class initially, but better to fix it properly in that issue).

Berdir’s picture

static does not work because static survives test tearDown(), I tried that :)

sidharrell’s picture

Issue summary:View changes

changed issue summary to better reflect how to do the replacement.