INFRA-132 - Change "else if" to "elseif"
[civicrm-core.git] / CRM / Core / Lock.php
index 87c267b01d92d1d21ecb474d2177fdd2be376d32..eb42b3c20715dd1a8f8c3bd3a16ff05d7155ed4a 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -35,7 +35,7 @@
 class CRM_Core_Lock {
 
   // lets have a 3 second timeout for now
-  CONST TIMEOUT = 3;
+  const TIMEOUT = 3;
 
   protected $_hasLock = FALSE;
 
@@ -44,17 +44,20 @@ class CRM_Core_Lock {
   /**
    * Initialize the constants used during lock acquire / release
    *
-   * @param string $name name of the lock. Please prefix with component / functionality
+   * @param string $name
+   *   Name of the lock. Please prefix with component / functionality.
    *                      e.g. civimail.cronjob.JOB_ID
-   * @param int $timeout the number of seconds to wait to get the lock. 1 if not set
-   * @param boolean $serverWideLock should this lock be applicable across your entire mysql server
+   * @param int $timeout
+   *   The number of seconds to wait to get the lock. 1 if not set.
+   * @param bool $serverWideLock
+   *   Should this lock be applicable across your entire mysql server.
    *                                this is useful if you have multiple sites running on the same
    *                                mysql server and you want to limit the number of parallel cron
    *                                jobs - CRM-91XX
    *
    * @return \CRM_Core_Lock the lock object
    */
-  function __construct($name, $timeout = NULL, $serverWideLock = FALSE) {
+  public function __construct($name, $timeout = NULL, $serverWideLock = FALSE) {
     $config = CRM_Core_Config::singleton();
     $dsnArray = DB::parseDSN($config->dsn);
     $database = $dsnArray['database'];
@@ -80,14 +83,14 @@ class CRM_Core_Lock {
     $this->acquire();
   }
 
-  function __destruct() {
+  public function __destruct() {
     $this->release();
   }
 
   /**
    * @return bool
    */
-  function acquire() {
+  public function acquire() {
     if (defined('CIVICRM_LOCK_DEBUG')) {
       CRM_Core_Error::debug_log_message('acquire lock for ' . $this->_name);
     }
@@ -108,7 +111,7 @@ class CRM_Core_Lock {
   /**
    * @return null|string
    */
-  function release() {
+  public function release() {
     if ($this->_hasLock) {
       $this->_hasLock = FALSE;
 
@@ -121,7 +124,7 @@ class CRM_Core_Lock {
   /**
    * @return null|string
    */
-  function isFree() {
+  public function isFree() {
     $query = "SELECT IS_FREE_LOCK( %1 )";
     $params = array(1 => array($this->_name, 'String'));
     return CRM_Core_DAO::singleValueQuery($query, $params);
@@ -130,7 +133,7 @@ class CRM_Core_Lock {
   /**
    * @return bool
    */
-  function isAcquired() {
+  public function isAcquired() {
     return $this->_hasLock;
   }
 
@@ -147,7 +150,7 @@ class CRM_Core_Lock {
    * @throws CRM_Core_Exception
    * @return boolean
    */
-  function hackyHandleBrokenCode($jobLog) {
+  public function hackyHandleBrokenCode($jobLog) {
     if (stristr($this->_name, 'job')) {
       throw new CRM_Core_Exception('lock aquisition for ' . $this->_name . 'attempted when ' . $jobLog . 'is not released');
     }
@@ -158,4 +161,3 @@ class CRM_Core_Lock {
     return TRUE;
   }
 }
-