Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nevets’s picture

Those filters which is disabled should not be listed sometimes. is not very specific about what part of the UI this would impact. If one does not list a disabled filter, how do they enable it?

@James’s picture

Yes, i understand your mean, but i won't change any other callers, except check_markup(), and with the new parameter.

nevets’s picture

Without any benchmarking, this is not a major issue. Changing check_markup() would be an API change.

@James’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -filter performance +filter performance issue
FileSize
1.83 KB
@James’s picture

Priority: Major » Normal
@James’s picture

Project: » Drupal core
Version: » 7.x-dev
Component: Code » filter.module
@James’s picture

Category: Support request » Bug report
@James’s picture

Status: Needs review » Needs work
@James’s picture

@James’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

Status: Needs work » Needs review

Status: Needs review » Needs work
@James’s picture

Why does the patch test failure?

@James’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
joachim’s picture

Issue tags: -filter performance issue
+++ b/modules/filter/filter.module
@@ -688,20 +688,25 @@ function _filter_format_is_cacheable($format) {
+function filter_list_format($format_id, $all = TRUE) {

This is a change to a function signature -- needs documentation change to match.

Also removing random tags.

@James’s picture

Status: Needs work » Needs review
FileSize
3.18 KB

Thanks @joachim. I have updated and improved something.

@James’s picture

Status: Needs review » Needs work
joachim’s picture

+++ b/modules/filter/filter.module
@@ -683,25 +685,34 @@ function _filter_format_is_cacheable($format) {
+  $filters = &drupal_static(__FUNCTION__.$all, array());

It's occurred to me that changing the name of a static is technically changing the API -- other parts of the core or contrib may be clearing this static. So I don't think that's going to work.

Overall, how much of a performance gain is this going to produce? How often, typically, are filters disabled in a format?

David_Rothstein’s picture

I don't understand the proposed performance gain either, especially since check_markup() already has code to avoid processing disabled filters (as it must; otherwise it would be a huge bug if disabled filters were being applied to the text):

  // Give filters the chance to escape HTML-like data such as code or formulas.
  foreach ($filters as $name => $filter) {
    if ($filter->status && isset($filter_info[$name]['prepare callback']) && function_exists($filter_info[$name]['prepare callback'])) {

(notice the $filter->status check in the if statement)

So doesn't that mean there is no real performance gain here except for making the foreach() loop a little shorter (which is a very tiny micro-optimization)? There would also be fewer filters loaded from the database, I suppose; however, that is offset by the fact that there are now two static caches within filter_list_format() rather than one, so in some cases there would be an extra database query per page request that was never there before.

@James’s picture

Status: Needs work » Needs review

Hi All,

Thanks for your feedbacks!

As I know this functionality is called frequently and I had checked it with XDebug, now i can not remember the calls but it is not small number. I'm not sure the patch would effect much for a simple Drupal project. but for us, we have a lot of fields in content type of our project.

To test it first step, we need clean static caches and memcache data, then try to access the edit page, you will see it in the debug log.

@James’s picture

Status: Needs review » Needs work
@James’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
@James’s picture

Status: Needs work » Needs review
FileSize
4.14 KB

Status: Needs review » Needs work
@James’s picture

Status: Needs work » Needs review
FileSize
4.13 KB

Status: Needs review » Needs work
@James’s picture

Status: Needs work » Needs review
FileSize
4.11 KB

How come i can not make this patch passed by simpletest? I have converted it for unix by dos2unix.