@@ -115,6 +115,7 @@ |
||
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * Returns the basic shell command string. |
| 118 | + * @param string $alias |
|
| 118 | 119 | */ |
| 119 | 120 | function _drush_mongodb_connect($alias) { |
| 120 | 121 | $connections = variable_get('mongodb_connections', array()); |
@@ -90,9 +90,9 @@ |
||
| 90 | 90 | $db = $connection['db']; |
| 91 | 91 | |
| 92 | 92 | $query = $host; |
| 93 | - $query .= '/' . $db; |
|
| 93 | + $query .= '/'.$db; |
|
| 94 | 94 | |
| 95 | - $command = 'mongo ' . $query; |
|
| 95 | + $command = 'mongo '.$query; |
|
| 96 | 96 | return $command; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -319,6 +319,7 @@ |
||
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * Return the next id in a sequence. |
| 322 | + * @param string $name |
|
| 322 | 323 | */ |
| 323 | 324 | function mongodb_next_id($name, $existing_id = 0) { |
| 324 | 325 | // Atomitcaly get the next id in the sequence. |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | function mongodb_help($route_name, RouteMatchInterface $route_match) { |
| 14 | 14 | switch ($route_name) { |
| 15 | 15 | case 'help.page.mongodb': |
| 16 | - return '<p>' . t('The Drupal <a href="!project">MongoDB</a> project implements a generic interface to the <a href="!mongo">MongoDB</a> database server.', [ |
|
| 16 | + return '<p>'.t('The Drupal <a href="!project">MongoDB</a> project implements a generic interface to the <a href="!mongo">MongoDB</a> database server.', [ |
|
| 17 | 17 | '!project' => 'http://drupal.org/project/mongodb', |
| 18 | 18 | '!mongo' => 'http://www.mongodb.org/', |
| 19 | 19 | ]); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | if (!empty($GLOBALS['drupal_test_info']['test_run_id'])) { |
| 275 | 275 | $simpletest_prefix = $GLOBALS['drupal_test_info']['test_run_id']; |
| 276 | 276 | } |
| 277 | - return $simpletest_prefix . $name; |
|
| 277 | + return $simpletest_prefix.$name; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | /** |
| 53 | 53 | * Claim an item in the queue for processing. |
| 54 | 54 | * |
| 55 | - * @param string $lease_time |
|
| 55 | + * @param integer $lease_time |
|
| 56 | 56 | * How long the processing is expected to take in seconds, |
| 57 | 57 | * |
| 58 | 58 | * @return object/boolean |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | public function __construct($name) { |
| 18 | 18 | // @todo: make sure that $name is a valid collection name? |
| 19 | - $this->collection = 'queue.' . $name; |
|
| 19 | + $this->collection = 'queue.'.$name; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @param array $value |
| 142 | 142 | * Serialized array of the session data. |
| 143 | 143 | * |
| 144 | - * @return boolean |
|
| 144 | + * @return null|boolean |
|
| 145 | 145 | * This function will always return TRUE. |
| 146 | 146 | */ |
| 147 | 147 | function _drupal_session_write($sid, $value) { |
@@ -300,6 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | /** |
| 302 | 302 | * Return whether a session has been started. |
| 303 | + * @param boolean $set |
|
| 303 | 304 | */ |
| 304 | 305 | function drupal_session_started($set = NULL) { |
| 305 | 306 | static $session_started = FALSE; |
@@ -386,7 +387,7 @@ discard block |
||
| 386 | 387 | /** |
| 387 | 388 | * Deletes the session cookie. |
| 388 | 389 | * |
| 389 | - * @param sting $name |
|
| 390 | + * @param string $name |
|
| 390 | 391 | * Name of session cookie to delete. |
| 391 | 392 | * @param boolean $secure |
| 392 | 393 | * Force the secure value of the cookie. |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if (!function_exists('_drupal_session_open')) { |
| 3 | - include_once dirname(__FILE__) . '/../mongodb_module.php'; |
|
| 3 | + include_once dirname(__FILE__).'/../mongodb_module.php'; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * @file |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $user = db_query("SELECT * FROM {users} u WHERE uid = :uid", array(':uid' => $session['uid']))->fetchObject(); |
| 109 | 109 | // Add roles element to $user and insert an entry into fields_current.user |
| 110 | 110 | // so next time we get it from Mongo. |
| 111 | - include_once dirname(__FILE__) . '/mongodb_session.module'; |
|
| 111 | + include_once dirname(__FILE__).'/mongodb_session.module'; |
|
| 112 | 112 | $user->roles = array(); |
| 113 | 113 | $user->roles = mongodb_session_user_insert(array(), $user); |
| 114 | 114 | } |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | $old_insecure_session_id = $_COOKIE[$insecure_session_name]; |
| 323 | 323 | } |
| 324 | 324 | $params = session_get_cookie_params(); |
| 325 | - $session_id = drupal_hash_base64(uniqid(mt_rand(), TRUE) . drupal_random_bytes(55)); |
|
| 325 | + $session_id = drupal_hash_base64(uniqid(mt_rand(), TRUE).drupal_random_bytes(55)); |
|
| 326 | 326 | // If a session cookie lifetime is set, the session will expire |
| 327 | 327 | // $params['lifetime'] seconds from the current request. If it is not set, |
| 328 | 328 | // it will expire when the browser is closed. |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | _drupal_session_delete_cookie(substr(session_name(), 1), FALSE); |
| 380 | 380 | } |
| 381 | 381 | elseif (variable_get('https', FALSE)) { |
| 382 | - _drupal_session_delete_cookie('S' . session_name(), TRUE); |
|
| 382 | + _drupal_session_delete_cookie('S'.session_name(), TRUE); |
|
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | 385 | |
@@ -214,6 +214,8 @@ |
||
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | 216 | * Initialize the global pager variables for use in a mongodb_watchdog event list. |
| 217 | + * @param integer $element |
|
| 218 | + * @param integer $limit |
|
| 217 | 219 | */ |
| 218 | 220 | function mongodb_watchdog_pager_init($element, $limit, $total) { |
| 219 | 221 | global $pager_page_array, $pager_total, $pager_total_items; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | foreach ($cursor as $id => $value) { |
| 65 | 65 | if ($value['type'] == 'php' && $value['message'] == '%type: %message in %function (line %line of %file).') { |
| 66 | 66 | $collection = mongodb_collection(variable_get('mongodb_watchdog', 'watchdog')); |
| 67 | - $collection = $collection->db->selectCollection('watchdog_event_' . $value['_id']); |
|
| 67 | + $collection = $collection->db->selectCollection('watchdog_event_'.$value['_id']); |
|
| 68 | 68 | if ($result = $collection->find()->sort(array('$natural' => -1))->limit(1)->getNext()) { |
| 69 | 69 | $value['file'] = basename($result['variables']['%file']); |
| 70 | 70 | $value['line'] = $result['variables']['%line']; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | isset($value['count']) && $value['count'] > 1 ? $value['count'] : '', |
| 79 | 79 | t($value['type']), |
| 80 | 80 | empty($value['timestamp']) ? '' : format_date($value['timestamp'], 'short'), |
| 81 | - empty($value['file']) ? '' : truncate_utf8(basename($value['file']), 30) . (empty($value['line']) ? '' : ('+' . $value['line'])), |
|
| 81 | + empty($value['file']) ? '' : truncate_utf8(basename($value['file']), 30).(empty($value['line']) ? '' : ('+'.$value['line'])), |
|
| 82 | 82 | l($message, "admin/reports/mongodb/$id"), |
| 83 | 83 | ); |
| 84 | 84 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | ->find(mongodb_watchdog_build_filter_query()) |
| 97 | 97 | ->count(); |
| 98 | 98 | $pager_total[0] = ceil($pager_total_items[0] / $per_page); |
| 99 | - $pager_page_array[0] = max(0, min((int) $pager_page_array[0], ((int)$pager_total[0]) - 1)); |
|
| 99 | + $pager_page_array[0] = max(0, min((int) $pager_page_array[0], ((int) $pager_total[0]) - 1)); |
|
| 100 | 100 | $pager_limits[0] = $per_page; |
| 101 | 101 | $build['pager'] = array( |
| 102 | 102 | '#theme' => 'pager', |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | // @todo: the count is unreliable, so just get the actual number of entries. |
| 152 | 152 | //$total = min($dblog['count'], variable_get('mongodb_watchdog_items', 10000)); |
| 153 | 153 | $collection = mongodb_collection(variable_get('mongodb_watchdog', 'watchdog')); |
| 154 | - $collection = $collection->db->selectCollection('watchdog_event_' . $dblog['_id']); |
|
| 154 | + $collection = $collection->db->selectCollection('watchdog_event_'.$dblog['_id']); |
|
| 155 | 155 | $total = $collection->count(); |
| 156 | 156 | $limit = 20; |
| 157 | 157 | $pagenumber = mongodb_watchdog_pager_init(0, $limit, $total); |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | $rows[] = array( |
| 193 | 193 | format_date($event['timestamp'], 'short'), |
| 194 | - l($account['name'], 'user/' . $account['uid']), |
|
| 194 | + l($account['name'], 'user/'.$account['uid']), |
|
| 195 | 195 | $request_uri ? l(truncate_utf8(basename(($request_uri)), 20), $request_uri) : '', |
| 196 | 196 | $referer ? l(truncate_utf8(basename(($referer)), 20), $referer) : '', |
| 197 | 197 | check_plain($ip), |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | } |
| 227 | 227 | $pager_total_items[$element] = $total; |
| 228 | 228 | $pager_total[$element] = ceil($pager_total_items[$element] / $limit); |
| 229 | - $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element], ((int)$pager_total[$element]) - 1)); |
|
| 229 | + $pager_page_array[$element] = max(0, min((int) $pager_page_array[$element], ((int) $pager_total[$element]) - 1)); |
|
| 230 | 230 | return isset($pager_page_array[$element]) ? $pager_page_array[$element] : 0; |
| 231 | 231 | } |
| 232 | 232 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | '#collapsed' => empty($_SESSION), |
| 292 | 292 | '#attached' => array( |
| 293 | 293 | 'css' => array( |
| 294 | - drupal_get_path('module', 'mongodb_watchdog') . '/mongodb_watchdog.css', |
|
| 294 | + drupal_get_path('module', 'mongodb_watchdog').'/mongodb_watchdog.css', |
|
| 295 | 295 | )), |
| 296 | 296 | ); |
| 297 | 297 | |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | |
| 490 | 490 | // Find occurrences of error type. |
| 491 | 491 | $key = $template['_id']; |
| 492 | - $event_collection = mongodb_collection('watchdog_event_' . $key); |
|
| 492 | + $event_collection = mongodb_collection('watchdog_event_'.$key); |
|
| 493 | 493 | $reduce = <<<EOT |
| 494 | 494 | function (doc, accumulator) { |
| 495 | 495 | accumulator.count++; |
@@ -10,9 +10,7 @@ |
||
| 10 | 10 | use Drupal\Component\Utility\Unicode; |
| 11 | 11 | use Drupal\Core\DependencyInjection\ContainerInjectionInterface; |
| 12 | 12 | use Drupal\Core\Url; |
| 13 | -use Drupal\mongodb\Connection; |
|
| 14 | 13 | use Drupal\mongodb_watchdog\Logger; |
| 15 | -use Psr\Log\LoggerInterface; |
|
| 16 | 14 | use Symfony\Component\DependencyInjection\ContainerInterface; |
| 17 | 15 | |
| 18 | 16 | /** |
@@ -108,7 +108,7 @@ |
||
| 108 | 108 | isset($value['count']) && $value['count'] > 1 ? intval($value['count']) : 0, |
| 109 | 109 | t($value['type']), |
| 110 | 110 | empty($value['timestamp']) ? '' : format_date($value['timestamp'], 'short'), |
| 111 | - empty($value['file']) ? '' : Unicode::truncate(basename($value['file']), 30) . (empty($value['line']) ? '' : ('+' . $value['line'])), |
|
| 111 | + empty($value['file']) ? '' : Unicode::truncate(basename($value['file']), 30).(empty($value['line']) ? '' : ('+'.$value['line'])), |
|
| 112 | 112 | \Drupal::l($message, Url::fromRoute('mongodb_watchdog.detail', ['id' => $id])), |
| 113 | 113 | ); |
| 114 | 114 | } |
@@ -10,9 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | use Drupal\Component\Utility\Unicode; |
| 12 | 12 | use Drupal\Core\Logger\LogMessageParserInterface; |
| 13 | -use Drupal\Core\Logger\RfcLoggerTrait; |
|
| 14 | 13 | use Psr\Log\AbstractLogger; |
| 15 | -use Psr\Log\LoggerInterface; |
|
| 16 | 14 | |
| 17 | 15 | /** |
| 18 | 16 | * Class Logger is a PSR/3 Logger using a MongoDB data store. |
@@ -117,7 +117,7 @@ |
||
| 117 | 117 | * A collection object for the specified template id. |
| 118 | 118 | */ |
| 119 | 119 | public function eventCollection($template_id) { |
| 120 | - $collection_name = static::EVENT_COLLECTION_PREFIX . $template_id; |
|
| 120 | + $collection_name = static::EVENT_COLLECTION_PREFIX.$template_id; |
|
| 121 | 121 | assert('preg_match(static::EVENT_COLLECTIONS_PATTERN, $collection_name)'); |
| 122 | 122 | return $this->database->selectCollection($collection_name); |
| 123 | 123 | } |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | if (!function_exists('configure_mongodb')) { |
| 10 | - function configure_mongodb(\Drupal\Core\Site\Settings &$settings) { |
|
| 10 | + function configure_mongodb(\Drupal\Core\Site\Settings & $settings) { |
|
| 11 | 11 | $settings['mongodb'] = [ |
| 12 | 12 | 'clients' => [ |
| 13 | 13 | // Client alias => constructor parameters. |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * Replace your cache-backend file with this file. See README.txt for details. |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -include_once dirname(__FILE__) . '/../mongodb_module.php'; |
|
| 8 | +include_once dirname(__FILE__).'/../mongodb_module.php'; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * MonogoDB cache implementation. |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $collection = mongodb_collection($this->bin); |
| 25 | 25 | // Garbage collection necessary when enforcing a minimum cache lifetime. |
| 26 | 26 | $this->garbageCollection($this->bin); |
| 27 | - $cache = $collection->findOne(array('_id' => (string)$cid)); |
|
| 27 | + $cache = $collection->findOne(array('_id' => (string) $cid)); |
|
| 28 | 28 | return $this->prepareItem($cache); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | $collection = mongodb_collection($this->bin); |
| 58 | 58 | |
| 59 | 59 | // Garbage collection necessary when enforcing a minimum cache lifetime. |
| 60 | - $cache_flush = variable_get('cache_flush_' . $this->bin, 0); |
|
| 60 | + $cache_flush = variable_get('cache_flush_'.$this->bin, 0); |
|
| 61 | 61 | if ($cache_flush && ($cache_flush + variable_get('cache_lifetime', 0) <= REQUEST_TIME)) { |
| 62 | 62 | // Reset the variable immediately to prevent a meltdown in heavy load situations. |
| 63 | - variable_set('cache_flush_' . $this->bin, 0); |
|
| 63 | + variable_set('cache_flush_'.$this->bin, 0); |
|
| 64 | 64 | // Time to flush old cache data |
| 65 | 65 | |
| 66 | 66 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | return FALSE; |
| 89 | 89 | } |
| 90 | 90 | unset($cache['_id']); |
| 91 | - $cache = (object)$cache; |
|
| 91 | + $cache = (object) $cache; |
|
| 92 | 92 | // If the data is permanent or we are not enforcing a minimum cache lifetime |
| 93 | 93 | // always return the cached data. |
| 94 | 94 | if ($cache->expire == CACHE_PERMANENT || !variable_get('cache_lifetime', 0)) { |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | function set($cid, $data, $expire = CACHE_PERMANENT) { |
| 117 | 117 | $scalar = is_scalar($data); |
| 118 | 118 | $entry = array( |
| 119 | - '_id' => (string)$cid, |
|
| 120 | - 'cid' => (string)$cid, |
|
| 119 | + '_id' => (string) $cid, |
|
| 120 | + 'cid' => (string) $cid, |
|
| 121 | 121 | 'created' => REQUEST_TIME, |
| 122 | 122 | 'expire' => $expire, |
| 123 | 123 | 'serialized' => !$scalar, |
@@ -151,17 +151,17 @@ discard block |
||
| 151 | 151 | // cached data that was cached before the timestamp. |
| 152 | 152 | $user->cache = REQUEST_TIME; |
| 153 | 153 | |
| 154 | - $cache_flush = variable_get('cache_flush_' . $this->bin, 0); |
|
| 154 | + $cache_flush = variable_get('cache_flush_'.$this->bin, 0); |
|
| 155 | 155 | if ($cache_flush == 0) { |
| 156 | 156 | // This is the first request to clear the cache, start a timer. |
| 157 | - variable_set('cache_flush_' . $this->bin, REQUEST_TIME); |
|
| 157 | + variable_set('cache_flush_'.$this->bin, REQUEST_TIME); |
|
| 158 | 158 | } |
| 159 | 159 | elseif (REQUEST_TIME > ($cache_flush + variable_get('cache_lifetime', 0))) { |
| 160 | 160 | // Clear the cache for everyone, cache_lifetime seconds have |
| 161 | 161 | // passed since the first request to clear the cache. |
| 162 | 162 | |
| 163 | 163 | $collection->remove(array('expire' => array('$ne' => CACHE_PERMANENT, '$lte' => REQUEST_TIME)), mongodb_default_write_options(FALSE)); |
| 164 | - variable_set('cache_flush_' . $this->bin, 0); |
|
| 164 | + variable_set('cache_flush_'.$this->bin, 0); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | else { |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | $collection->remove(); |
| 176 | 176 | } |
| 177 | 177 | else { |
| 178 | - $collection->remove(array('cid' => new MongoRegex('/'. preg_quote($cid) .'.*/')), mongodb_default_write_options(FALSE)); |
|
| 178 | + $collection->remove(array('cid' => new MongoRegex('/'.preg_quote($cid).'.*/')), mongodb_default_write_options(FALSE)); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | elseif (is_array($cid)) { |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | while (count($cid)); |
| 188 | 188 | } |
| 189 | 189 | else { |
| 190 | - $collection->remove(array('_id' => (string)$cid), mongodb_default_write_options(FALSE)); |
|
| 190 | + $collection->remove(array('_id' => (string) $cid), mongodb_default_write_options(FALSE)); |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | } |