Instead of creating a date object and calling format('t') we should use the built in PHP function cal_days_in_month();

I've included an XHProf comparison of the performance gains from using the core function.

A patch to follow.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

minorOffense’s picture

Status: Active » Needs review
FileSize
632 bytes

Patch as promised.

arlinsandbulte’s picture

Status: Needs review » Reviewed & tested by the community

looks reasonable to me.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 1933572-optimize-date_days_in_month.patch, failed testing.

tsyvs’s picture

tsyvs’s picture

Status: Needs work » Needs review

Patch #1 is ok.
The problem of testing is about incorrect $year and/or $month values that are passed to function.
So, when incorrect $year and/or $month issue is fixed, the patch will pass tests.

Status: Needs review » Needs work

The last submitted patch, 4: 1933572-optimize-date_days_in_month-v2.patch, failed testing.

tsyvs’s picture