Projet

Général

Profil

Révision 4eeb3b46

Ajouté par Assos Assos il y a presque 8 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/uuid/README.txt
11 11
 * Automatic UUID generation:
12 12
   UUIDs will be generated for all core entities. An API is provided for other
13 13
   modules to enable support for custom entities.
14
   See https://www.drupal.org/node/2387671
14 15
 * UUID API for entities, properties and fields:
15 16
   With this unified API you can load entities with entity_uuid_load() so that
16 17
   all supported properties and fields are made with UUID references. You can
drupal7/sites/all/modules/uuid/plugins/arguments/entity_uuid.inc
6 6
 */
7 7

  
8 8
/**
9
 * Plugins are described by creating a $plugin array which will be used
10
 * by the system that includes this file.
9
 * CTools UUID entity context plugin definition.
11 10
 */
12 11
$plugin = array(
13 12
  'title' => t("Entity: UUID"),
......
18 17
);
19 18

  
20 19
/**
21
 * @todo document me properly
20
 * Fetches the "child" information for a given parent entity.
21
 *
22
 * @todo document me properly.
23
 *
24
 * @return array
25
 *   The children.
22 26
 */
23 27
function uuid_entity_uuid_get_child($plugin, $parent, $child) {
24 28
  $plugins = uuid_entity_uuid_get_children($plugin, $parent);
......
26 30
}
27 31

  
28 32
/**
29
 * @todo document me properly
33
 * Fetches all children types for a given parent entity.
34
 *
35
 * @todo document me properly.
36
 *
37
 * @return array
38
 *   All the children.
30 39
 */
31 40
function uuid_entity_uuid_get_children($original_plugin, $parent) {
32 41
  $entities = entity_get_info();
drupal7/sites/all/modules/uuid/uuid.admin.inc
42 42
    // Get the keys for local ID and UUID.
43 43
    $uuid_key = $info['entity keys']['uuid'];
44 44
    $uuid_entities = entity_uuid_load($entity_type, array($entity->{$uuid_key}));
45
    // @codingStandardsIgnoreStart
45 46
    return kdevel_print_object(reset($uuid_entities), '$' . $entity_type . '->');
47
    // @codingStandardsIgnoreEnd
46 48
  }
47 49
  else {
48 50
    return t("This entity doesn't support UUID.");
drupal7/sites/all/modules/uuid/uuid.api.php
18 18
}
19 19

  
20 20
/**
21
 * Let modules transform their properties with local IDs to UUIDs when an
22
 * entity is loaded.
21
 * Transform entity properties from local IDs to UUIDs when they are loaded.
23 22
 */
24 23
function hook_entity_uuid_load(&$entities, $entity_type) {
25 24

  
26 25
}
27 26

  
28 27
/**
29
 * Let modules transform their fields with local IDs to UUIDs when an entity
30
 * is loaded.
28
 * Transform field values from local IDs to UUIDs when an entity is loaded.
31 29
 */
32 30
function hook_field_uuid_load($entity_type, $entity, $field, $instance, $langcode, &$items) {
33 31

  
34 32
}
35 33

  
36 34
/**
37
 * Let modules transform their properties with UUIDs to local IDs when an
38
 * entity is saved.
35
 * Transform entity properties from UUIDs to local IDs before entity is saved.
39 36
 */
40 37
function hook_entity_uuid_presave(&$entity, $entity_type) {
41 38

  
42 39
}
43 40

  
44 41
/**
45
 * Let modules transform their fields with UUIDs to local IDs when an entity
46
 * is saved.
42
 * Transform field values from UUIDs to local IDs before an entity is saved.
47 43
 */
48 44
function hook_field_uuid_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
49 45

  
50 46
}
51 47

  
52 48
/**
53
 * Let modules transform their properties when an entity is saved.
49
 * Transform entity properties after an entity is saved.
54 50
 */
55 51
function hook_entity_uuid_save($entity, $entity_type) {
56 52

  
......
58 54

  
59 55
/**
60 56
 * Let modules act when an entity is deleted.
57
 *
58
 * Generally hook_entity_delete() should be used instead of this hook.
59
 *
60
 * @see hook_entity_delete()
61 61
 */
62 62
function hook_entity_uuid_delete($entity, $entity_type) {
63 63

  
64 64
}
65 65

  
66 66
/**
67
 * Let modules modify paths when they are being converted to UUID ones.
67
 * Modifies paths when they are being converted to UUID ones.
68 68
 */
69 69
function hook_uuid_menu_path_to_uri_alter($path, &$uri) {
70 70

  
71 71
}
72 72

  
73 73
/**
74
 * Let modules modify paths when they are being converted from UUID ones.
74
 * Modifies paths when they are being converted from UUID ones.
75 75
 */
76 76
function hook_uuid_menu_uri_to_path(&$path, $uri) {
77 77

  
drupal7/sites/all/modules/uuid/uuid.core.inc
32 32
  if ($entity_type == 'node') {
33 33
    entity_property_uuid_to_id($entity, 'user', array('uid', 'revision_uid'));
34 34
    entity_property_uuid_to_id($entity, 'node', 'tnid');
35

  
36
    // A node always must have an author.
37
    if (empty($entity->uid)) {
38
      global $user;
39
      $entity->uid = $user->uid;
40
    }
35 41
  }
36 42
}
37 43

  
......
39 45
 * Implements hook_entity_uuid_save().
40 46
 */
41 47
function node_entity_uuid_save(&$entity, $entity_type) {
42
  // When a node is translated, the source node's tnid is set to it's own nid. When deploying
43
  // the node for the first time the tnid can't be translated to an nid until after the node has been saved.
44
  // So if the entity's tnid is still a uuid at this point it needs to be translated to an nid.
48
  /*
49
   * When a node is translated, the source node's tnid is set to it's own nid.
50
   * When deploying the node for the first time the tnid can't be translated
51
   * to an nid until after the node has been saved. So if the entity's tnid
52
   * is still a uuid at this point it needs to be translated to an nid.
53
   */
45 54
  if ($entity_type == 'node' && uuid_is_valid($entity->tnid)) {
46 55
    entity_property_uuid_to_id($entity, 'node', 'tnid');
47 56
    db_update('node')
......
80 89
 * Implements hook_entity_uuid_presave().
81 90
 */
82 91
function user_entity_uuid_presave(&$entity, $entity_type) {
83
  if ($entity_type == 'user') {
84
    if (!empty($entity->picture)) {
85
      $uuids = entity_get_id_by_uuid('file', array($entity->picture['uuid']));
86
      $fid = current($uuids);
87
      if (!$entity->is_new) {
88
        $entity->picture = file_load($fid);
89
      }
90
      else {
91
        $entity->picture = $fid;
92
      }
93
    }
92
  if ($entity_type != 'user') {
93
    return;
94
  }
95

  
96
  /*
97
   * We need to ensure new user's passwords are encrypted. The Services module
98
   * transparently encrypts the password for new users. md5() is used by
99
   * users who's accounts were migrated from Drupal 6 and who haven't updated
100
   * their password.
101
   */
102
  if (isset($entity->pass)
103
    && (!('$S$D' == substr($entity->pass, 0, 4)) || preg_match('/^[a-f0-9]{32}$/', $entity->pass))) {
104
    // Ensure user's password is hashed.
105
    $entity->pass = user_hash_password($entity->pass);
106
  }
107

  
108
  if (empty($entity->picture)) {
109
    return;
110
  }
111

  
112
  $uuids = entity_get_id_by_uuid('file', array($entity->picture['uuid']));
113
  $fid = current($uuids);
114
  if (!$entity->is_new) {
115
    $entity->picture = file_load($fid);
116
  }
117
  else {
118
    $entity->picture = $fid;
94 119
  }
95 120
}
96 121

  
......
120 145
      break;
121 146

  
122 147
    case 'comment':
148
      // entity_make_entity_local() may have unset cid, add back if necessary.
149
      if (!isset($entity->cid)) {
150
        $entity->cid = NULL;
151
      }
123 152
      entity_property_uuid_to_id($entity, 'user', array('uid', 'u_uid'));
124 153
      entity_property_uuid_to_id($entity, 'node', 'nid');
125 154
      break;
......
140 169
 */
141 170
function file_entity_uuid_presave(&$entity, $entity_type) {
142 171
  if ($entity_type == 'file') {
172
    // entity_make_entity_local() may have unset fid, add back if necessary.
173
    if (!isset($entity->fid)) {
174
      $entity->fid = NULL;
175
    }
143 176
    entity_property_uuid_to_id($entity, 'user', 'uid');
144 177

  
145 178
    // Write the new file to the local filesystem.
146
    if (isset($entity->file_contents)) {
179
    if (isset($entity->file_contents) && !empty($entity->filesize)) {
147 180
      // Don't try to write it if it uses a stream wrapper that isn't writeable
148 181
      // (for example, if it is a remotely-hosted video).
149 182
      $scheme = file_uri_scheme($entity->uri);
......
185 218
      }
186 219

  
187 220
      $directory = drupal_dirname($uri);
188
      file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
189
      $entity->uri = file_unmanaged_save_data(base64_decode($entity->file_contents), $uri, $replace);
221
      if (!empty($directory) && file_prepare_directory($directory, FILE_CREATE_DIRECTORY)) {
222
        $entity->uri = file_unmanaged_save_data(base64_decode($entity->file_contents), $uri, $replace);
223
      }
190 224
    }
191 225
  }
192 226
}
......
230 264
 * Implements hook_entity_uuid_load().
231 265
 */
232 266
function field_entity_uuid_load(&$entities, $entity_type) {
233
  foreach ($entities as $i => $entity) {
267
  foreach ($entities as $entity) {
234 268
    list(, , $bundle_name) = entity_extract_ids($entity_type, $entity);
235 269
    $instances = field_info_instances($entity_type, $bundle_name);
236 270

  
......
327 361

  
328 362
/**
329 363
 * Implements hook_field_uuid_load().
364
 *
330 365
 * Kept here because it is in D8 core.
331 366
 */
332 367
function entityreference_field_uuid_load($entity_type, $entity, $field, $instance, $langcode, &$items) {
......
337 372

  
338 373
/**
339 374
 * Implements hook_field_uuid_presave().
375
 *
340 376
 * Kept here because it is in D8 core.
341 377
 */
342 378
function entityreference_field_uuid_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
......
358 394
 * Implements hook_uuid_entities_features_export_entity_alter().
359 395
 */
360 396
function node_uuid_entities_features_export_entity_alter(&$entity, $entity_type) {
361
  if ($entity_type == 'node') {
362
    foreach (array('data', 'name', 'picture', 'revision_uid', 'last_comment_timestamp') as $property) {
363
      if (property_exists($entity, $property)) {
364
        unset($entity->{$property});
365
      }
397
  if ('node' != $entity_type) {
398
    return;
399
  }
400

  
401
  $properties = array(
402
    'data',
403
    'name',
404
    'picture',
405
    'revision_uid',
406
    'last_comment_timestamp',
407
  );
408
  foreach ($properties as $property) {
409
    if (property_exists($entity, $property)) {
410
      unset($entity->{$property});
366 411
    }
367 412
  }
368 413
}
369 414

  
370 415
/**
371
 * Implementations hook_uuid_entities_features_export_entity_alter().
416
 * Implements hook_uuid_entities_features_export_entity_alter().
372 417
 */
373 418
function user_uuid_entities_features_export_entity_alter(&$entity, $entity_type) {
374
  if ($entity_type == 'user') {
375
    foreach (array('data', 'access', 'login') as $property) {
376
      if (property_exists($entity, $property)) {
377
        unset($entity->{$property});
378
      }
419
  if ('user' != $entity_type) {
420
    return;
421
  }
422

  
423
  foreach (array('data', 'access', 'login') as $property) {
424
    if (property_exists($entity, $property)) {
425
      unset($entity->{$property});
379 426
    }
380 427
  }
381 428
}
drupal7/sites/all/modules/uuid/uuid.drush.inc
6 6
 */
7 7

  
8 8
/**
9
 * Implementats hook_drush_command().
9
 * Implements hook_drush_command().
10 10
 */
11 11
function uuid_drush_command() {
12 12
  $items = array();
......
18 18
}
19 19

  
20 20
/**
21
 * Implementats of hook_drush_help().
21
 * Implements hook_drush_help().
22 22
 */
23 23
function uuid_drush_help($section) {
24 24
  switch ($section) {
drupal7/sites/all/modules/uuid/uuid.entity.inc
11 11
class UuidEntityException extends Exception {}
12 12

  
13 13
/**
14
 * Helper function that returns entity info for all supported core modules,
15
 * relevant for UUID functionality.
14
 * Returns entity info for all supported core entities.
16 15
 *
17 16
 * @see uuid_entity_info()
18 17
 * @see uuid_schema_alter()
......
98 97
 */
99 98
function uuid_entity_property_info_alter(&$info) {
100 99
  foreach (entity_get_info() as $entity_type => $entity_info) {
101
    if (isset($entity_info['uuid']) && $entity_info['uuid'] == TRUE 
100
    if (isset($entity_info['uuid']) && $entity_info['uuid'] == TRUE
102 101
      && !empty($entity_info['entity keys']['uuid'])
103 102
      && empty($info[$entity_type]['properties'][$entity_info['entity keys']['uuid']])) {
104 103
      $info[$entity_type]['properties'][$entity_info['entity keys']['uuid']] = array(
......
107 106
        'description' => t('The universally unique ID.'),
108 107
        'schema field' => $entity_info['entity keys']['uuid'],
109 108
      );
110
      if (!empty($entity_info['entity keys']['revision uuid']) 
109
      if (!empty($entity_info['entity keys']['revision uuid'])
111 110
        && empty($info[$entity_type]['properties'][$entity_info['entity keys']['revision uuid']])) {
112 111
        $info[$entity_type]['properties'][$entity_info['entity keys']['revision uuid']] = array(
113 112
          'label' => t('Revision UUID'),
......
341 340
    }
342 341
  }
343 342
  else {
344
    throw new UuidEntityException(t('Trying to operate on a @type entity, which doesn\'t support UUIDs.', array('@type' => $info['label'])));
343
    throw new UuidEntityException(t("Trying to operate on a @type entity, which doesn\'t support UUIDs.", array('@type' => $info['label'])));
345 344
  }
346 345
}
347 346

  
......
382 381
    return entity_delete($entity_type, $id);
383 382
  }
384 383
  else {
385
    throw new UuidEntityException(t('Trying to delete a @type entity, which doesn\'t support UUIDs.', array('@type' => $info['label'])));
384
    throw new UuidEntityException(t("Trying to delete a @type entity, which doesn\'t support UUIDs.", array('@type' => $info['label'])));
386 385
  }
387 386
}
388 387

  
......
392 391
 * @todo
393 392
 *   Limit the query.
394 393
 *
395
 * @param $entity_type
394
 * @param string $entity_type
396 395
 *   The entity type we should be dealing with.
397
 * @param $uuids
398
 *   An array of UUIDs for which we should find their entity IDs. If $revision
396
 * @param array $uuids
397
 *   List of UUIDs for which we should find their entity IDs. If $revision
399 398
 *   is TRUE this should be revision UUIDs instead.
400
 * @param $revision
399
 * @param bool $revision
401 400
 *   If TRUE the revision IDs is returned instead.
402
 * @return
403
 *   Array of entity IDs keyed by their UUIDs. If $revision is TRUE revision
401
 *
402
 * @return array
403
 *   List of entity IDs keyed by their UUIDs. If $revision is TRUE revision
404 404
 *   IDs and UUIDs are returned instead.
405 405
 */
406 406
function entity_get_id_by_uuid($entity_type, $uuids, $revision = FALSE) {
......
437 437
  $result = db_select($table, 't')
438 438
    ->fields('t', array($uuid_key, $id_key))
439 439
    ->condition($uuid_key, array_values($uuids), 'IN')
440
    ->execute();
441
    $result = $result->fetchAllKeyed();
440
    ->execute()
441
    ->fetchAllKeyed();
442 442
  $cache = &drupal_static('entity_uuid_id_cache', array());
443 443
  $cache[$entity_type][(int) $revision] += $result;
444 444
  return $result + $cached_ids;
......
462 462
 * @todo
463 463
 *   Limit the query.
464 464
 *
465
 * @param $entity_type
465
 * @param string $entity_type
466 466
 *   The entity type we should be dealing with.
467
 * @param $ids
468
 *   An array of entity IDs for which we should find their UUIDs. If $revision
467
 * @param array $ids
468
 *   List of entity IDs for which we should find their UUIDs. If $revision
469 469
 *   is TRUE this should be revision IDs instead.
470
 * @param $revision
470
 * @param bool $revision
471 471
 *   If TRUE the revision UUIDs is returned instead.
472
 * @return
473
 *   Array of entity UUIDs keyed by their IDs. If $revision is TRUE revision
472
 *
473
 * @return array
474
 *   List of entity UUIDs keyed by their IDs. If $revision is TRUE revision
474 475
 *   IDs and UUIDs are returned instead.
475 476
 */
476 477
function entity_get_uuid_by_id($entity_type, $ids, $revision = FALSE) {
......
511 512
    ->execute()
512 513
    ->fetchAllKeyed();
513 514
  $cache = &drupal_static('entity_uuid_id_cache', array());
514
  $cache[$entity_type][(int) $revision]+= array_flip($result);
515
  $cache[$entity_type][(int) $revision] += array_flip($result);
515 516
  return $result + $cached_ids;
516 517
}
517 518

  
......
525 526
 * @todo
526 527
 *   Add tests for this function.
527 528
 *
528
 * @param $objects
529
 *   An array of objects that should get $properties changed. Can be either an
529
 * @param array $objects
530
 *   List of objects that should get $properties changed. Can be either an
530 531
 *   entity object or a field items array.
531
 * @param $entity_type
532
 * @param string $entity_type
532 533
 *   The type of entity that all $properties refers to.
533
 * @param $properties
534
 * @param array $properties
534 535
 *   An array of properties that should be changed. All properties must refer to
535 536
 *   the same type of entity (the one referenced in $entity_type).
536 537
 */
......
581 582
 * @todo
582 583
 *   Add tests for this function.
583 584
 *
584
 * @param $objects
585
 *   An array of objects that should get $properties changed. Can be either an
585
 * @param array $objects
586
 *   List of objects that should get $properties changed. Can be either an
586 587
 *   entity object or a field items array.
587
 * @param $entity_type
588
 * @param string $entity_type
588 589
 *   The type of entity that all $properties refers to.
589
 * @param $properties
590
 * @param array $properties
590 591
 *   An array of properties that should be changed. All properties must refer to
591 592
 *   the same type of entity (the one referenced in $entity_type).
592 593
 */
drupal7/sites/all/modules/uuid/uuid.features.inc
84 84
      }
85 85
      // We unset some common timestamp properties, since those will change and
86 86
      // constantly leave the feature overidden.
87
      $keys = array('created', 'updated', 'changed', 'revision_timestamp', 'timestamp', 'stamp', 'current');
87
      $keys = array(
88
        'created',
89
        'updated',
90
        'changed',
91
        'revision_timestamp',
92
        'timestamp',
93
        'stamp',
94
        'current',
95
      );
88 96
      foreach ($keys as $key) {
89 97
        if (isset($entity->{$key})) {
90 98
          unset($entity->{$key});
......
121 129
      }
122 130
      uuid_entities_features_clean($entity);
123 131

  
124
      // Convert entities to array to avoid having them in JSON, returned from standard implementation of $entity->export().
132
      /*
133
       * Convert entities to array to avoid having them in JSON, returned
134
       * from standard implementation of $entity->export().
135
       */
125 136
      if (is_object($entity) && method_exists($entity, 'export')) {
126 137
        $entity = get_object_vars($entity);
127 138
      }
drupal7/sites/all/modules/uuid/uuid.inc
8 8
/**
9 9
 * Pattern for detecting a valid UUID.
10 10
 */
11
define('UUID_PATTERN', '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}');
11
define('UUID_PATTERN', '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}');
12 12

  
13 13
/**
14 14
 * Generates an universally unique identifier.
......
17 17
 * universally unique identifiers. If that doesn't exist, then it falls back on
18 18
 * PHP for generating that.
19 19
 *
20
 * @return
20
 * @return string
21 21
 *   An UUID, made up of 32 hex digits and 4 hyphens.
22 22
 */
23 23
function uuid_generate() {
......
37 37
  return $callback();
38 38
}
39 39

  
40
/**
41
 * Generates a version 5 compliant UUID.
42
 *
43
 * @param string $namespace
44
 *   Namespace UUID as a hex encoded string.
45
 * @param string $name
46
 *   The name for the generating the UUID.
47
 *
48
 * @return string
49
 *   UUID as a hex encoded string.
50
 *
51
 * @link http://www.php.net/manual/en/function.uniqid.php#94959 Code lifted from
52
 * PHP manual comment by Andrew Moore. @endlink
53
 */
54
function uuid_generate_v5($namespace, $name) {
55
  if (!uuid_is_valid($namespace)) {
56
    return FALSE;
57
  }
58

  
59
  // Get hexadecimal components of namespace.
60
  $nhex = str_replace(array('-', '{', '}'), '', $namespace);
61

  
62
  // Binary Value.
63
  $nstr = '';
64

  
65
  // Convert Namespace UUID to bits.
66
  for ($i = 0; $i < strlen($nhex); $i += 2) {
67
    $nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
68
  }
69

  
70
  // Calculate hash value.
71
  $hash = sha1($nstr . $name);
72

  
73
  return sprintf('%08s-%04s-%04x-%04x-%12s',
74

  
75
    // 32 bits for "time_low".
76
    substr($hash, 0, 8),
77

  
78
    // 16 bits for "time_mid".
79
    substr($hash, 8, 4),
80

  
81
    // 16 bits for "time_hi_and_version",
82
    // four most significant bits holds version number 5.
83
    (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
84

  
85
    // 16 bits, 8 bits for "clk_seq_hi_res",
86
    // 8 bits for "clk_seq_low",
87
    // two most significant bits holds zero and one for variant DCE1.1.
88
    (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
89

  
90
    // 48 bits for "node".
91
    substr($hash, 20, 12)
92
  );
93
}
94

  
40 95
/**
41 96
 * Generate all missing UUIDs.
42 97
 */
......
53 108
 *   The type of entity being used.
54 109
 *
55 110
 * @return string
56
 *  The generated UUID URI or normal URI if entity doesn't support UUIDs.
111
 *   The generated UUID URI or normal URI if entity doesn't support UUIDs.
57 112
 */
58 113
function uuid_entity_uuid_uri($entity, $entity_type) {
59 114
  $entity_info = entity_get_info($entity_type);
......
73 128
/**
74 129
 * Converts an ID URI string to an entity data array.
75 130
 *
76
 * @see uuid_id_uri_array_to_data()
77
 *
78 131
 * @param string $uri
79
 *  The URI to convert.
132
 *   The URI to convert.
80 133
 *
81 134
 * @return array
82
 *  The entity data.
135
 *   The entity data.
136
 *
137
 * @see uuid_id_uri_array_to_data()
83 138
 */
84 139
function uuid_id_uri_to_data($uri) {
85 140
  $parts = explode('/', $uri);
......
90 145
 * Converts a URI array to entity data array.
91 146
 *
92 147
 * @param array $uri
93
 *  The URI parts, often taken from arg().
148
 *   The URI parts, often taken from arg().
94 149
 *
95 150
 * @return array
96
 *  The entity data.
151
 *   The entity data.
97 152
 */
98 153
function uuid_id_uri_array_to_data($uri) {
99 154
  $data = array(
......
110 165
/**
111 166
 * Converts a UUID URI string to an entity data array.
112 167
 *
113
 * @see uuid_uri_array_to_data()
114
 *
115 168
 * @param string $uri
116
 *  The URI to convert.
169
 *   The URI to convert.
117 170
 *
118 171
 * @return array
119
 *  The entity data.
172
 *   The entity data.
173
 *
174
 * @see uuid_uri_array_to_data()
120 175
 */
121 176
function uuid_uri_to_data($uri, $strip_uuid = TRUE) {
122 177
  return uuid_uri_array_to_data(explode('/', $uri));
......
126 181
 * Converts a URI array to entity data array.
127 182
 *
128 183
 * @param array $uri
129
 *  The URI parts, often taken from arg().
184
 *   The URI parts, often taken from arg().
130 185
 *
131 186
 * @return array
132
 *  The entity data.
187
 *   The entity data.
133 188
 */
134 189
function uuid_uri_array_to_data($uri, $strip_uuid = TRUE) {
135 190
  if ($strip_uuid) {
......
138 193

  
139 194
  $data = array(
140 195
    'request' => $uri,
141
    'entity_type' => $uri[0],
142
    'uuid' => $uri[1],
196
    'entity_type' => isset($uri[0]) ? $uri[0] : NULL,
197
    'uuid' => isset($uri[1]) ? $uri[1] : NULL,
143 198
  );
144 199

  
145 200
  drupal_alter('uuid_uri_data', $data);
......
201 256
  );
202 257
}
203 258

  
204

  
205
// This is wrapped in an if block to avoid conflicts with PECL's uuid_is_valid().
259
// The if block avoids conflicts with PECL's uuid_is_valid().
206 260
if (!function_exists('uuid_is_valid')) {
261

  
207 262
  /**
208 263
   * Check that a string appears to be in the format of a UUID.
209 264
   *
210
   * @param $uuid
211
   *  The string to test.
265
   * @param string $uuid
266
   *   The string to test.
212 267
   *
213
   * @return
214
   *   TRUE if the string is well formed.
268
   * @return bool
269
   *    TRUE if the string is well formed.
215 270
   */
216 271
  function uuid_is_valid($uuid) {
217 272
    return preg_match('/^' . UUID_PATTERN . '$/', $uuid);
218 273
  }
274

  
219 275
}
drupal7/sites/all/modules/uuid/uuid.info
7 7
dependencies[] = node
8 8
dependencies[] = user
9 9

  
10
; Information added by Drupal.org packaging script on 2015-10-07
11
version = "7.x-1.0-beta1"
10
; Information added by Drupal.org packaging script on 2016-08-02
11
version = "7.x-1.0-beta2"
12 12
core = "7.x"
13 13
project = "uuid"
14
datestamp = "1444230890"
14
datestamp = "1470153540"
15 15

  
drupal7/sites/all/modules/uuid/uuid.install
31 31
/**
32 32
 * Implements hook_schema_alter().
33 33
 */
34
function uuid_schema_alter(&$schema = array()) {
35
  $field = uuid_schema_field_definition();
36
  foreach (uuid_get_core_entity_info() as $entity_type => $info) {
37
    $schema[$info['base table']]['fields'][$info['entity keys']['uuid']] = $field;
38
    if (!empty($info['revision table']) && !empty($info['entity keys']['revision uuid'])) {
39
      $schema[$info['revision table']]['fields'][$info['entity keys']['revision uuid']] = $field;
34
function uuid_schema_alter(array &$schema) {
35
  $field_info = uuid_schema_field_definition();
36
  $key_names = array(
37
    'base table' => 'uuid',
38
    'revision table' => 'revision uuid',
39
  );
40

  
41
  foreach (uuid_get_core_entity_info() as $entity_info) {
42
    foreach ($key_names as $table_type => $key_name) {
43
      if (isset($entity_info[$table_type], $entity_info['entity keys'][$key_name])) {
44
        $field_name = $entity_info['entity keys'][$key_name];
45
        $properties = array(
46
          'fields' => $field_info,
47
          'indexes' => array($field_name),
48
        );
49

  
50
        foreach ($properties as $property => $value) {
51
          $schema[$entity_info[$table_type]][$property][$field_name] = $value;
52
        }
53
      }
40 54
    }
41 55
  }
42 56
}
......
51 65
}
52 66

  
53 67
/**
54
 * Install the 'uuid' and 'vuuid' fields into Drupal core entity tables where needed.
68
 * Install the uuid and vuuid fields for Drupal core entity tables where needed.
55 69
 *
56
 * IMPORTANT:  This function is called both at install and update time.  If this method
57
 * is modified to add additional fields in the future, the update strategy must be
58
 * considered.  See the comment in uuid_update_7102.
70
 * IMPORTANT:  This function is called both at install and update time.  If this
71
 * method is modified to add additional fields in the future, the update
72
 * strategy must be considered.  See the comment in uuid_update_7102.
59 73
 */
60 74
function _uuid_install_uuid_fields() {
61 75
  $field = uuid_schema_field_definition();
62
  foreach (uuid_get_core_entity_info() as $entity_type => $info) {
76
  foreach (uuid_get_core_entity_info() as $info) {
63 77
    if (!db_field_exists($info['base table'], $info['entity keys']['uuid'])) {
64 78
      db_add_field($info['base table'], $info['entity keys']['uuid'], $field);
65 79
      db_add_index($info['base table'], $info['entity keys']['uuid'], array($info['entity keys']['uuid']));
......
77 91
 * Implements hook_uninstall().
78 92
 */
79 93
function uuid_uninstall() {
80
  foreach (uuid_get_core_entity_info() as $entity_type => $info) {
94
  foreach (uuid_get_core_entity_info() as $info) {
81 95
    if (db_field_exists($info['base table'], $info['entity keys']['uuid'])) {
82 96
      db_drop_field($info['base table'], $info['entity keys']['uuid']);
83 97
      db_drop_index($info['base table'], $info['entity keys']['uuid']);
......
113 127
}
114 128

  
115 129
/**
116
 * For each of out tables, drop the indexe on the UUID column and add a unique
117
 * key on that column.
130
 * Make all uuid columns unique keys instead of indexes.
118 131
 */
119 132
function uuid_update_6002() {
120 133
  $ret = array();
......
139 152
}
140 153

  
141 154
/**
142
 * Fix the column definitions for uuid columns in all tables
143
 * to use the more efficient char spec.
155
 * Change column definitions for uuid columns to more efficient char spec.
144 156
 */
145 157
function uuid_update_6004() {
146 158
  $ret = array();
......
159 171
}
160 172

  
161 173
/**
174
 * Support deleting node revision.
175
 *
162 176
 * Modify existing uuid_node_revisions table to support revision deletion, and
163 177
 * add in as much legacy data as possible.
164 178
 */
......
205 219
}
206 220

  
207 221
/**
208
 * Clear cache for installations that used alpha1. Modules that previously was
209
 * enabled in uuid_update_7100() doesn't exist anymore.
222
 * Clear cache for installations that used alpha1.
223
 *
224
 * Modules previously enabled in uuid_update_7100() don't exist any more. We
225
 * need to clear the cache so Drupal detects this change.
210 226
 */
211 227
function uuid_update_7101() {
212 228
  drupal_flush_all_caches();
213 229
}
214 230

  
215 231
/**
216
 * Insure that the uuid and vuuid fields are added where needed.
232
 * Ensure that the uuid and vuuid fields are added where needed.
217 233
 *
218 234
 * Note that update 7102 calls _uuid_install_uuid_fields(), which is an
219 235
 * idempotent function.  If _uuid_install_uuid_fields() is changed at some
......
221 237
 * will have run update 7102, and some will not.  A new uuid_update_7103()
222 238
 * function would would therefore be necessary to update all users to
223 239
 * the latest schema.  At the same time, uuid_update_7102() could become
224
 * an empty function, as it would not be necessary to call _uuid_install_uuid_fields()
225
 * twice.
240
 * an empty function, as it would not be necessary to call
241
 * _uuid_install_uuid_fields() twice.
226 242
 */
227 243
function uuid_update_7102() {
228 244
  // If the user have disabled the UUID module during upgrade (as UPGRADE.txt
......
233 249
}
234 250

  
235 251
/**
252
 * Clean up entities created by uuid_default_entities_example module.
253
 *
236 254
 * Modify the labels of all example entities created by the now removed
237
 * uuid_default_entities_example.module to make it clear they're examples.
238
 * Also remove the administrator role of any example user.
255
 * uuid_default_entities_example.module to make it clear they're examples. Also
256
 * remove the administrator role of any example user.
239 257
 */
240 258
function uuid_update_7103() {
241 259
  // These are UUIDs of all the example entities that might exist after having
......
250 268
      '7cf875e6-dc15-4404-f190-5a7c3e91d14c',
251 269
    ),
252 270
  );
253
  // we can't assume taxonomy is enabled
271
  // We can't assume taxonomy is enabled.
254 272
  if (isset($info['taxonomy_term'])) {
255 273
    $uuids['taxonomy_term'] = array(
256 274
      'bcb92ce8-2236-e264-65c8-0c163ae716d1',
drupal7/sites/all/modules/uuid/uuid.module
34 34
    'title' => 'UUID redirector',
35 35
    'description' => 'Redirects requests for UUID URIs to the referenced entity.',
36 36
    'page callback' => 'uuid_redirector',
37
    // The access check is handled in the page callback.
37 38
    'access callback' => TRUE,
38 39
    'type' => MENU_CALLBACK,
39 40
  );
......
44 45
    'page callback' => 'drupal_get_form',
45 46
    'page arguments' => array('uuid_admin_form'),
46 47
    'access arguments' => array('administer uuid'),
47
    'type' => MENU_NORMAL_ITEM,
48 48
    'file' => 'uuid.admin.inc',
49 49
  );
50 50

  
......
123 123
  return array_fill_keys($hook_names, array('group' => 'uuid'));
124 124
}
125 125

  
126

  
127 126
/**
128 127
 * Implements hook_views_api().
129 128
 */
......
155 154
 * Implements hook_uuid_sync().
156 155
 */
157 156
function uuid_uuid_sync() {
158
  foreach (entity_get_info() as $entity_type => $info) {
157
  foreach (entity_get_info() as $info) {
159 158
    if (isset($info['uuid']) && $info['uuid'] == TRUE && !empty($info['entity keys']['uuid'])) {
160 159
      _uuid_sync_table($info['base table'], $info['entity keys']['id'], $info['entity keys']['uuid']);
161 160
      if (!empty($info['entity keys']['revision uuid'])) {
......
231 230

  
232 231
  drupal_goto($uri['path'], $uri['options'], 301);
233 232
}
234

  
drupal7/sites/all/modules/uuid/uuid.test
6 6
 */
7 7

  
8 8
/**
9
 * Base class with some helper methods.
9
 * UUID test helper trait.
10
 *
11
 * Contains methods that assist with running UUID tests.
10 12
 */
11
class UUIDTestCase extends DrupalWebTestCase {
12

  
13
  /**
14
   * {@inheritdoc}
15
   */
16
  function setUp() {
17
    parent::setUp(func_get_args());
18
  }
13
trait UUIDTestHelper {
19 14

  
20 15
  /**
21 16
   * Helper function that asserts a UUID.
22 17
   */
23
  function assertUUID($uuid, $message = NULL) {
18
  protected function assertUuid($uuid, $message = NULL) {
24 19
    $this->assertTrue(uuid_is_valid($uuid), $message);
25 20
  }
21

  
22
}
23

  
24
/**
25
 * Base class with some helper methods.
26
 */
27
abstract class UUIDTestCase extends DrupalWebTestCase {
28

  
29
  use UUIDTestHelper;
30

  
26 31
}
27 32

  
28 33
/**
......
44 49
  /**
45 50
   * {@inheritdoc}
46 51
   */
47
  function setUp() {
48
    parent::setUp('uuid');
52
  protected function setUp() {
53
    parent::setUp(array('uuid'));
49 54
  }
50 55

  
51 56
  /**
52 57
   * Tests uuid function calls.
53 58
   */
54
  function testAPIFunctions() {
59
  public function testApiFunctions() {
55 60
    // This is a valid UUID, we know that.
56 61
    $valid_uuid = '0ab26e6b-f074-4e44-9da6-1205fa0e9761';
57 62
    // Test the uuid_is_valid() function.
58
    $this->assertUUID($valid_uuid, 'UUID validation works.');
63
    $this->assertUuid($valid_uuid, 'UUID validation works.');
59 64

  
60 65
    // The default generator is 'php'.
61 66
    $uuid = uuid_generate();
62
    $this->assertUUID($uuid, 'PHP generator works.');
67
    $this->assertUuid($uuid, 'PHP generator works.');
63 68

  
64 69
    // Test the 'mysql' generator.
65 70
    variable_set('uuid_generator', 'mysql');
66 71
    drupal_static_reset('uuid_generate');
67 72
    $uuid = uuid_generate();
68
    $this->assertUUID($uuid, 'MySQL generator works.');
73
    $this->assertUuid($uuid, 'MySQL generator works.');
74
  }
75

  
76
  /**
77
   * Checks that schema for tables of core entities is correctly defined.
78
   */
79
  public function testSchemas() {
80
    module_load_include('install', 'uuid');
81

  
82
    $schemas = drupal_get_schema();
83
    $field_info = uuid_schema_field_definition();
84
    $key_names = array(
85
      'base table' => 'uuid',
86
      'revision table' => 'revision uuid',
87
    );
88

  
89
    foreach (uuid_get_core_entity_info() as $entity_info) {
90
      // Test the fields in "base" and "revision" tables.
91
      foreach ($key_names as $table_type => $key_name) {
92
        // Table or field is not defined in entity.
93
        if (!isset($entity_info[$table_type], $entity_info['entity keys'][$key_name])) {
94
          // Not all entities have a revisions table.
95
          continue;
96
        }
97

  
98
        $field_name = $entity_info['entity keys'][$key_name];
99
        $table_name = $entity_info[$table_type];
100

  
101
        if (!isset($schemas[$table_name])) {
102
          $this->fail(sprintf('Database schema does not have a "%s" table.', $table_name));
103
          continue;
104
        }
105

  
106
        $properties = array(
107
          'field' => array('fields', $field_info),
108
          'index' => array('indexes', array($field_name)),
109
        );
110

  
111
        // Check integrity of the field and index definition.
112
        foreach ($properties as $type => $data) {
113
          list($property, $value) = $data;
114

  
115
          $message = sprintf('Definition of the "%s" %s in the "%s" schema', $field_name, $type, $table_name);
116

  
117
          if (isset($schemas[$table_name][$property][$field_name])) {
118
            $this->assertIdentical($schemas[$table_name][$property][$field_name], $value, "$message is correct.");
119
          }
120
          else {
121
            $this->fail("$message does not exist.");
122
          }
123
        }
124
      }
125
    }
126
  }
127

  
128
}
129

  
130
/**
131
 * Tests the UUID API functions.
132
 */
133
class UUIDV5TestCase extends UUIDTestCase {
134

  
135
  /**
136
   * {@inheritdoc}
137
   */
138
  public static function getInfo() {
139
    return array(
140
      'name' => 'UUID v5',
141
      'description' => 'Tests the UUID v5 function.',
142
      'group' => 'UUID',
143
    );
144
  }
145

  
146
  /**
147
   * {@inheritdoc}
148
   */
149
  protected function setUp() {
150
    parent::setUp(array('uuid'));
151
  }
152

  
153
  /**
154
   * Tests uuid function calls.
155
   */
156
  public function testV5Function() {
157
    // DNS namespace UUID.
158
    $dns_namespace = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
159

  
160
    // Valid DNS generation test.
161
    $uuid = uuid_generate_v5($dns_namespace, 'drupal.org');
162
    $this->assertUuid($uuid, 'UUID for drupal.org is valid.');
163
    $this->assertEqual($uuid, 'c809fd30-48df-52e3-a9f2-2cd78129b8b1', 'UUID for drupal.org is correct.');
164

  
165
    // Invalid namespace test.
166
    $invalid_namespace = '01234567-c7a9-feda-27e5-75d00dabc123';
167
    $uuid = uuid_generate_v5($invalid_namespace, 'drupal.org');
168
    $this->assertFalse($uuid, 'Invalid namespace UUID rejected.');
69 169
  }
170

  
70 171
}
71 172

  
72 173
/**
......
88 189
  /**
89 190
   * {@inheritdoc}
90 191
   */
91
  function setUp() {
92
    parent::setUp('uuid');
192
  protected function setUp() {
193
    parent::setUp(array('uuid'));
93 194
  }
94 195

  
95 196
  /**
96 197
   * Tests Entity API's UUID functions.
97 198
   */
98
  function testEntityAPIFunctions() {
199
  public function testEntityApiFunctions() {
99 200
    // Create some entities that we will work with.
100 201
    $user = $this->drupalCreateUser();
101 202
    $node = $this->drupalCreateNode(array('title' => 'original title', 'uid' => $user->uid));
......
112 213
    $vuuids = entity_get_uuid_by_id('node', array($node->vid), TRUE);
113 214
    $this->assertTrue(in_array($node->vuuid, $vuuids), 'Lookup of entity revision UUID works.');
114 215
  }
216

  
115 217
}
116 218

  
117 219
/**
......
133 235
  /**
134 236
   * {@inheritdoc}
135 237
   */
136
  function setUp() {
238
  protected function setUp() {
239
    $modules = array('uuid');
240

  
137 241
    // Some tests depends on the optional Entity API module.
138 242
    if (module_exists('entity')) {
139
      parent::setUp('uuid', 'entity');
140
    }
141
    else {
142
      parent::setUp('uuid');
243
      $modules[] = 'entity';
143 244
    }
245

  
246
    parent::setUp($modules);
144 247
  }
145 248

  
146 249
  /**
147 250
   * Test CRUD on users with UUID functions.
148 251
   */
149
  function testUserCRUD() {
252
  public function testUserCrud() {
150 253
    $user = $this->drupalCreateUser();
151
    $this->assertUUID($user->uuid, 'User UUID was generated.');
254
    $this->assertUuid($user->uuid, 'User UUID was generated.');
152 255

  
153 256
    // Test updating user.
154 257
    $user_test = clone $user;
......
178 281
      $this->assertFalse($user_test, 'Deleting user with UUID worked.');
179 282
    }
180 283
  }
284

  
181 285
}
182 286

  
183 287
/**
......
199 303
  /**
200 304
   * {@inheritdoc}
201 305
   */
202
  function setUp() {
306
  protected function setUp() {
307
    $modules = array('uuid');
308

  
203 309
    // Some tests depends on the optional Entity API module.
204 310
    if (module_exists('entity')) {
205
      parent::setUp('uuid', 'entity');
206
    }
207
    else {
208
      parent::setUp('uuid');
311
      $modules[] = 'entity';
209 312
    }
313

  
314
    parent::setUp($modules);
210 315
  }
211 316

  
212 317
  /**
......
215 320
   * @todo
216 321
   *   Break out into multiple test methods to loosen coupling between tests.
217 322
   */
218
  function testNodeCRUD() {
323
  public function testNodeCrud() {
219 324
    // Create some entities that we will work with.
220 325
    $user = $this->drupalCreateUser();
221 326
    $node = $this->drupalCreateNode(array('title' => 'original title', 'uid' => $user->uid));
222 327

  
223
    $this->assertUUID($node->uuid, 'Node UUID was generated.');
224
    $this->assertUUID($node->vuuid, 'Node revision UUID was generated.');
328
    $this->assertUuid($node->uuid, 'Node UUID was generated.');
329
    $this->assertUuid($node->vuuid, 'Node revision UUID was generated.');
225 330

  
226 331
    // Test node update, without creating new revision.
227 332
    $node_test = clone $node;
......
244 349
    $node_test = node_load($node->nid, FALSE, TRUE);
245 350
    $this->assertEqual($node_test->uuid, $node->uuid, 'Node UUID was intact after updating, when creating new revision.');
246 351
    $this->assertNotEqual($node_test->vuuid, $node->vuuid, 'A new node revision UUID was generated, when creating new revision.');
247
    $this->assertUUID($node_test->vuuid, 'The new node revision UUID was valid.');
352
    $this->assertUuid($node_test->vuuid, 'The new node revision UUID was valid.');
248 353

  
249 354
    // Test entity_uuid_load().
250 355
    // Save some variables that we will test against.
......
300 405
      $this->assertEqual($node_test->title, 'newer title', 'Saving node with UUID mapped to correct node, when creating new revision.');
301 406
      $this->assertEqual($node_test->uuid, $node->uuid, 'Node UUID was intact after saving with UUID, when creating new revision.');
302 407
      $this->assertNotEqual($node_test->vuuid, $node->vuuid, 'A new node revison UUID was generated after saving with UUID, when creating new revision.');
303
      $this->assertUUID($node_test->vuuid, 'New node revision UUID was valid.');
408
      $this->assertUuid($node_test->vuuid, 'New node revision UUID was valid.');
304 409
      $this->assertEqual($node_test->uid, $node->uid, "Node property 'uid' was intact after saving with UUID, when creating new revision.");
305 410

  
306 411
      // Test the same thing again, but now triggering a new revision from a
......
310 415
      $node_test = reset($nodes);
311 416
      // Store the current local revision ID to test with later.
312 417
      $vid_old1 = $node_test->vid;
313
      $vuuid_old1 = $node_test->vuuid;
314 418
      // Simulate this node coming from a remote environment by generating
315 419
      // IDs that won't match. Only the UUID match at this point.
316 420
      $node_test->uuid_services = TRUE;
317
      $nid_remote = rand();
318
      $vid_remote = rand();
319 421
      $vuuid_test = uuid_generate();
320 422
      $node_test->nid = $nid_test;
321 423
      $node_test->vid = $vid_test;
......
375 477
      $this->assertFalse($node_test, 'Deleting node with UUID worked.');
376 478
    }
377 479
  }
480

  
378 481
}
379 482

  
380 483
/**
......
385 488
 */
386 489
class UUIDCommentTestCase extends CommentHelperCase {
387 490

  
491
  use UUIDTestHelper;
492

  
388 493
  /**
389 494
   * {@inheritdoc}
390 495
   */
......
396 501
    );
397 502
  }
398 503

  
399
  /**
400
   * Helper function that asserts a UUID.
401
   *
402
   * We have duplicated this function from UUIDTestCase since we have to extend
403
   * CommentHelperCase instead.
404
   */
405
  function assertUUID($uuid, $message = NULL) {
406
    $this->assertTrue(uuid_is_valid($uuid), $message);
407
  }
408

  
409 504
  /**
410 505
   * Test CRUD on comments with UUID functions.
411 506
   */
412
  function testCommentCRUD() {
507
  public function testCommentCrud() {
413 508
    // This is sub optimal, but due to how CommentHelperCase::setUp() is
414 509
    // constructed we are enforced to do this. So unfortunately this test
415 510
    // depends on 'entity' module for now.
416
    module_enable(array('uuid', 'entity'), TRUE);
511
    module_enable(array('uuid', 'entity'));
417 512
    $user = $this->drupalCreateUser();
418 513
    $this->drupalLogin($user);
419 514
    $node = $this->drupalCreateNode();
420 515
    $return = $this->postComment($node, 'Lorem ipsum');
421 516

  
422 517
    $comment = comment_load($return->id);
423
    $this->assertUUID($comment->uuid, 'Comment UUID was generated.');
518
    $this->assertUuid($comment->uuid, 'Comment UUID was generated.');
424 519

  
425 520
    // Test updating comment.
426 521
    $comment_test = clone $comment;
......
456 551
      $this->assertFalse($comment_test, 'Deleting comment with UUID worked.');
457 552
    }
458 553
  }
554

  
459 555
}
460 556

  
461 557
/**
......
463 559
 */
464 560
class UUIDTaxonomyTestCase extends TaxonomyWebTestCase {
465 561

  
562
  use UUIDTestHelper;
563

  
466 564
  /**
467 565
   * {@inheritdoc}
468 566
   */
......
479 577
   *
480 578
   * A lot of code here is taken from TaxonomyTermTestCase::setUp().
481 579
   */
482
  function setUp() {
580
  protected function setUp() {
581
    $modules = array('taxonomy', 'uuid');
582

  
483 583
    // Some tests depends on the optional Entity API module.
484 584
    if (module_exists('entity')) {
485
      parent::setUp('taxonomy', 'uuid', 'entity');
486
    }
487
    else {
488
      parent::setUp('taxonomy', 'uuid');
585
      $modules[] = 'entity';
489 586
    }
490
  }
491 587

  
492
  /**
493
   * Helper function that asserts a UUID.
494
   *
495
   * We have duplicated this function from UUIDTestCase since we have to extend
496
   * TaxonomyWebTestCase instead.
497
   */
498
  function assertUUID($uuid, $message = NULL) {
499
    $this->assertTrue(uuid_is_valid($uuid), $message);
588
    parent::setUp($modules);
500 589
  }
501 590

  
502 591
  /**
503 592
   * Test CRUD on comments with UUID functions.
504 593
   */
505
  function testTaxonomyCRUD() {
506
    $user = $this->drupalCreateUser(array('administer taxonomy', 'administer nodes', 'bypass node access'));
594
  public function testTaxonomyCrud() {
595
    $perms = array(
596
      'administer taxonomy',
597
      'administer nodes',
598
      'bypass node access',
599
    );
600
    $user = $this->drupalCreateUser($perms);
507 601
    $this->drupalLogin($user);
508 602

  
509 603
    // Create a term by tagging a node. We'll use this node later too.
510
    $vocabulary = new stdClass;
604
    $vocabulary = new stdClass();
511 605
    $vocabulary->vid = 1;
512 606
    $term = $this->createTerm($vocabulary);
513
    $this->assertUUID($term->uuid, 'Term UUID was generated.');
607
    $this->assertUuid($term->uuid, 'Term UUID was generated.');
514 608

  
515 609
    // Test updating term.
516 610
    $term_test = clone $term;
......
542 636
      $this->assertFalse($term_test, 'Deleting term with UUID worked.');
543 637
    }
544 638
  }
639

  
545 640
}
546 641

  
547 642
/**
......
566 661
   * @todo
567 662
   *   There are something weird around this assertion.
568 663
   */
569
  function assertTableColumn($table, $column, $message) {
664
  protected function assertTableColumn($table, $column, $message) {
570 665
    $this->assertTrue(db_field_exists($table, $column), $message);
571 666
  }
572 667

  
573 668
  /**
574 669
   * Tests creating UUIDs for entities that don't have them.
575 670
   */
576
  function testSync() {
671
  public function testSync() {
577 672
    // These entities will not have UUID from the start, since the UUID module
578 673
    // isn't installed yet.
579 674
    $user = $this->drupalCreateUser();
......
600 695

  
601 696
    // Test if UUID was generated for nodes.
602 697
    $node_test = node_load($node->nid, FALSE, TRUE);
603
    $this->assertUUID($node_test->uuid, 'Node UUID was generated when clicking the sync button.');
604
    $this->assertUUID($node_test->vuuid, 'Node revision UUID was generated when clicking the sync button.');
698
    $this->assertUuid($node_test->uuid, 'Node UUID was generated when clicking the sync button.');
699
    $this->assertUuid($node_test->vuuid, 'Node revision UUID was generated when clicking the sync button.');
605 700

  
606 701
    // Test if UUID was generated for users.
607 702
    $user_test = user_load($user->uid, TRUE);
608
    $this->assertUUID($user_test->uuid, 'User UUID was generated when clicking the sync button.');
703
    $this->assertUuid($user_test->uuid, 'User UUID was generated when clicking the sync button.');
609 704
  }
705

  
610 706
}
drupal7/sites/all/modules/uuid/uuid.views.inc
1 1
<?php
2

  
2 3
/**
3 4
 * @file
4
 * Views Implementation for UUID
5
 * Views Implementation for UUID.
5 6
 */
6 7

  
7 8
/**
drupal7/sites/all/modules/uuid/uuid_path/uuid_path.info
5 5
dependencies[] = uuid
6 6

  
7 7

  
8
; Information added by Drupal.org packaging script on 2015-10-07
9
version = "7.x-1.0-beta1"
8
; Information added by Drupal.org packaging script on 2016-08-02
9
version = "7.x-1.0-beta2"
10 10
core = "7.x"
11 11
project = "uuid"
12
datestamp = "1444230890"
12
datestamp = "1470153540"
13 13

  
drupal7/sites/all/modules/uuid/uuid_path/uuid_path.module
2 2

  
3 3
/**
4 4
 * @file
5
 *   UUID path module functions.
5
 * UUID path module functions.
6 6
 */
7 7

  
8 8
/**
......
24 24
 */
25 25
function _uuid_path_load_url_aliases(&$entities, $entity_type) {
26 26
  $info = entity_get_info($entity_type);
27
  // we only care about entities with URLs.
27
  // We only care about entities with URLs.
28 28
  if (!isset($info['uri callback'])) {
29 29
    return;
30 30
  }
......
35 35
    $aliases = _uuid_path_url_alias_load($path['path']);
36 36

  
37 37
    // Ignore local IDs.
38
    foreach($aliases as &$alias) {
38
    foreach ($aliases as &$alias) {
39 39
      unset($alias->pid);
40 40
      unset($alias->source);
41 41
    }
......
50 50
function _uuid_path_save_url_aliases(&$entity, $entity_type) {
51 51
  $info = entity_get_info($entity_type);
52 52

  
53
  // We only care when there is a url callback
53
  // We only care when there is a url callback.
54 54
  if (!isset($info['uri callback'])) {
55 55
    return FALSE;
56 56
  }
......
63 63
  path_delete(array('source' => $path));
64 64

  
65 65
  // Continue if aliases are present.
66
  if(empty($entity->url_alias)) {
66
  if (empty($entity->url_alias)) {
67 67
    return FALSE;
68 68
  }
69 69

  
......
77 77
/**
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff