Update filter module to use drupal_static()
JamesAn - June 3, 2009 - 03:22
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | filter.module |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | won't fix |
| Issue tags: | Novice |
Description
This is a child task for #422380: convert all core module to use new static caching API focusing on the filter module.

#1
#2
Not sure why htmlcorrectory needs the statics at all there, but looks good anyway.
#3
Shouldn't
+ $no_nesting = &drupal_static(__FUNCTION__, drupal_map_assoc(array('li', 'p')));be+ $no_nesting = &drupal_static(__FUNCTION__ . ":no_nesting", drupal_map_assoc(array('li', 'p')));for consistency?#4
Generally we've only been suffixing statics when we have to (i.e. http://api.drupal.org/api/function/taxonomy_get_tree/7 which was one of the first patches to go in), I can see arguments both ways though.
#5
Yes, the pattern seemed to not suffix the first static var.
#6
The reasoning for this is documented in the update docs: http://drupal.org/node/224333#static_variable_api
#7
The last submitted patch failed testing.
#8
Adding novice tag.
#9
Rerolled.
#10
The last submitted patch failed testing.
#11
This patch is re-rolled minus the changes to _filter_htmlcorrector, which has been rewritten to use PHP5 and no longer needs &drupal_static(__FUNCTION__).
#12
The last submitted patch failed testing.
#14
Patch re-work.
#15
The last submitted patch failed testing.
#16
Rerolled. Some of the changes were already made so the patch is smaller.
#17
+++ modules/filter/filter.module 28 Oct 2009 06:32:32 -0000@@ -1069,7 +1069,7 @@ function _filter_url_parse_partial_links
function _filter_url_trim($text, $length = NULL) {
- static $_length;
+ $_length = &drupal_static(__FUNCTION__);
if ($length !== NULL) {
This conversion makes no sense, because this function is an internal preg_replace callback for _filter_url(). No module has a chance to intercept the operation anyway.
However, while being there and reverting the change, please change the if condition to use isset($length) instead of this awkward NULL test.
This review is powered by Dreditor.
#18
#19
#562932: {filter_format}.cache is not saved will remove this static entirely.