Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
3.33 KB

Update.

damiankloip’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
3.44 KB

Rerolled, and also just removed the passing by reference in the validation method signature. Would do an interdiff by this is just one character/line :) Although the serialization would handle any of these characters that aren't allowed, consistency is better for sure.

Anything to excise these crazy random test failures is a win IMO, So Happy with this patch.

Status: Reviewed & tested by the community » Needs work
Issue tags: -VDC

The last submitted patch, 1892158-2.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review

#2: 1892158-2.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +VDC

The last submitted patch, 1892158-2.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
1.02 KB
3.56 KB

Maybe that? Alternative we could just hardcode the wrong characters.

Status: Needs review » Needs work

The last submitted patch, drupal-1892158-6.patch, failed testing.

olli’s picture

+    if (preg_match('@[^A-Za-z0-9_-]+@', $element['#value'])) {
...
+    // 32 to 64 is part of this::randomString() but not this::randomName() so
+    // this will be an invalid character.

32-64 includes 0-9 and - (48).

dawehner’s picture

Status: Needs work » Needs review
FileSize
3.61 KB

Does 91 to 96 work better?

Status: Needs review » Needs work

The last submitted patch, drupal-1892158-9.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
377 bytes
3.56 KB

The concentration seems to go away :)

klausi’s picture

Status: Needs review » Needs work
+++ b/core/modules/rest/lib/Drupal/rest/Plugin/views/row/DataFieldRow.php
@@ -82,12 +82,22 @@ public function buildOptionsForm(&$form, &$form_state) {
   /**
+   * Form element validation handler for \Drupal\rest\Plugin\views\row\DataFieldRow::buildOptionsForm().
+   */
+  public function validateAliasName($element, &$form_state) {
+    if (preg_match('@[^A-Za-z0-9_-]+@', $element['#value'])) {
+      form_error($element, t('The machine-readable name must contain only letters, numbers, dashes and underscores.'));
+    }

There is no validation function already for that in core? We cannot use form_validate_machine_name(), but is there nothing else? I suggest you add element_validate_machine_name() to form.inc.

+++ b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php
@@ -174,11 +176,17 @@ public function testUIFieldAlias() {
+    // 91 to 96 is part of this::randomString() but not this::randomName() so
+    // this will be an invalid character.
+    $random_name_2 = chr(rand(91, 96)) . $this->randomName();

$random_name_2 is a bad variable name, use $invalid_name instead?

dawehner’s picture

So the problem here is that we allow more then machine names, because you want to be able to configure more then machine names in the XML document,
just for example an xml document might want camelCase variables.

dawehner’s picture

Status: Needs work » Needs review
FileSize
1.9 KB
3.59 KB

Thanks for reviewing!

Fixed the second part of the review.

olli’s picture

_ = 95. Thanks for clarifying why not only machine name. Why only these characters then? I checked the previous issue but could not crack it.

dawehner’s picture

To be honest I just though that these kind of characters would make sense as XML tags, but I'm open for different ones.

olli’s picture

Ok. Tiny change in range to prevent random failures and we are good.

dawehner’s picture

FileSize
1.09 KB
3.52 KB

Decided to put just a single string in there, as it's much easier to read then.

damiankloip’s picture

Status: Needs review » Reviewed & tested by the community

Yeah, that is much better IMO. I tihnk this is ready again?

catch’s picture

Category: feature » task
Status: Reviewed & tested by the community » Fixed

Looks reasonable. Committed/pushed to 8.x. Not sure why this was posted as a feature request.

Automatically closed -- issue fixed for 2 weeks with no activity.

guilmour-asc’s picture

Issue summary: View changes

Excuse me, but I need to know if it would be too dangerous for the alias to allow dots [ . ] and colons [ : ].

I'm trying to expose my data in Dublin Core style, and its terms are segemented by dots or double-dots (ex.: dc.title, dc.identifier.uri).