Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joseph.olstad created an issue. See original summary.

joseph.olstad’s picture

Status: Needs review » Needs work

I'm not sure which file contains the regex or parsing logic that is implicated.

Worth looking at the regex / string parsing.

patrickd’s picture

joseph.olstad’s picture

ok, so change these two lines (line 152 and 153) from:

    // Remove special characters from the users name.
    $escaped_creator = preg_replace('/[^a-zA-Z0-9-_\.+!*\(\)\']/s', '', $data->creator);

to:

    // Remove special characters (including dots) from the users name.
    $escaped_creator = preg_replace('/[^a-zA-Z0-9-_+!*\(\)\']/s', '', $data->creator);
joseph.olstad’s picture

Status: Needs work » Needs review
joseph.olstad’s picture

I tested this in my local environment using my username
joseph.olstad

Before the change the output was joseph.olstad

after the change, the output becomes josepholstad

josepholstad is compatible with simplytest.me sandbox projects
whereas joseph.olstad is not.

joseph.olstad’s picture

patrickd’s picture

josepholstad is compatible with simplytest.me sandbox projects
whereas joseph.olstad is not.

hm.. that's odd because my manual fix for your sandbox project was actually adding the dot, not removing it..

patrickd’s picture

ah sorry, my fault, the issue is not when the git url is build after loading it from database. it happens after scrapping the data from the drupal.org url which happens here:
http://cgit.drupalcode.org/simplytest/tree/modules/simplytest_projects/s...

it fetches the project data from here:
https://www.drupal.org/api-d7/node.json?field_project_machine_name=2635830
and scraps the username from the URL contained in the response at list[0].url which is
https://www.drupal.org/sandbox/josepholstad/2635830

this is where the dot is *missing*

the only other mention of a user/author seems to be
https://www.drupal.org/api-d7/user/1321830
but that gives 404

yup, I'm starting to remember now, this is the same issue as 5 years ago, there seems to be no good way to fetch the author name :/

patrickd’s picture

Status: Needs review » Needs work

oh!

https://www.drupal.org/api-d7/user.json?uid=1321830

contains the field name:"joseph.olstad"

so it's possible to ensure the correct username by doing a second request based on the author.id from the first api request

joseph.olstad’s picture

Hmm, ok, sounds like comment #10 is where we need to start investigating. So the .json contains the information that could be used to provide the correct username, sounds like a good thing to do.

So what I would suggest, restore the database record in your database for my username to the original value prior to the workaround, then implement the json name field load and use that value as required. Then we can test broken vs after, hopefully fixed without having to change a db record for others.

patrickd’s picture

Not sure I understand why we should change yours back, it's working now, so let's just leave it at that and fix the fetch for future projects.
And if we want correct all existing projects we can simply truncate the database and reimport all projects from scratch.
Otherwise you'd have to fetch the name every time a project is selected which would be really bad for performance and send useless requests to d.o.

joseph.olstad’s picture

The idea of changing my record back to what it was yesterday is so that we can verify a permanent fix to the code base. Rather than a one-off fix for just me, we should fix the logic to handle the dot. In comment #10 it sounds like you have an idea how to use the json data to grab the username. Maybe there's other ways to fix the issue, probably several ways to fix this by the sounds of it however all we need is one way. I'd prefer a fix that works for all sandbox projects owned by users with dot rather than a record update one by one. Let me know how I can help if you want to continue.

Thanks, really like simplytest.me , just trying to give something back here.

patrickd’s picture

just trying to give something back here.

No worries, i'm just bad at explaining things because I keep assuming you know things that are obvious to me because i created this thing.

so that we can verify a permanent fix to the code base. Rather than a one-off fix for just me, we should fix the logic to handle the dot.

Yes, I think with that json data we can actually fix it for everyone and not just you *but* only for projects which are not in the database yet. As the problem lies in the function (simplytest_projects_fetch_project) adding *new* projects to the database.

What needs to be changed:
* The author should not be scrapped from the project URL anymore
* Instead a second d.o API request needs to be done to https://www.drupal.org/api-d7/user.json?uid=
* The UID can be found in list[0].author.id from the first api request
* From the response from there list[0].name should be used as author instead

I hope I explained it better :)

joseph.olstad’s picture

Sounds easy enough, just have to find a few spare cycles

rachel_norfolk’s picture

Status: Needs work » Postponed (maintainer needs more info)

Is this still an active issue? Trying to ensure the queue has relevant issues in it and this one has not seen activity since before major changes to the platform.

Please set to active if still relevant. Please set to Closed (outdated) if not.

joseph.olstad’s picture

I'd assume it's still an issue. I stopped using simplytest.me a long while ago because so many things stopped working I gave up. However I did test it once in 2023 and it seemed to have improved. I'll have to re-test installing a sandbox project from someone that has a dot in their username. I have a dot in my username

joseph.olstad

This isn't too hard to test.