[wp-trac] [WordPress Trac] #19486: Remove unneeded set_time_limit() calls from network/sites.php

WordPress Trac wp-trac at lists.automattic.com
Fri Dec 9 14:46:01 UTC 2011


#19486: Remove unneeded set_time_limit() calls from network/sites.php
---------------------------+-----------------------------
 Reporter:  dllh           |      Owner:  westi
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Network Admin  |    Version:  3.3
 Severity:  normal         |   Keywords:  has-patch
---------------------------+-----------------------------
 A call to set_time_limit() was introduced in
 http://mu.trac.wordpress.org/changeset/860/trunk/wp-admin/wpmu-edit.php
 and has made its way into wp-admin/network/sites.php. Since the call is
 adjacent to spam actions that could make a network call to akismet that
 could take some time to return, its intention is presumably to allow the
 code enough time to execute without timing out even if the network call
 takes a while.

 But set_time_limit() won't take network time into account, so it actually
 will not do what it seems designed to do. From php docs:

   The set_time_limit() function and the configuration directive
 max_execution_time only affect the execution time of the script itself.
 Any time spent on activity that happens outside the execution of the
 script such as system calls using system(), stream operations, database
 queries, etc. is not included when determining the maximum time that the
 script has been running.

 Further, calls to set_time_limit() can cause unexpected results in code
 that relies on any functions that call set_time_limit(). For example, if
 some code (in a cron job, say) sets the time limit to 0 (unlimited)
 because it knows it needs some time complete, then a subsequent call to a
 function that resets the time limit will halt the long-running execution
 once the new limit has been reached. Also from php docs:

   When called, set_time_limit() restarts the timeout counter from zero. In
 other words, if the timeout is the default 30 seconds, and 25 seconds into
 script execution a call such as set_time_limit(20) is made, the script
 will run for a total of 45 seconds before timing out.

 Since the call to set_time_limit() does not here do anything useful, it
 should be removed.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19486>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list