Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Don't trigger init if already redirected #1830

Merged
merged 5 commits into from
Oct 3, 2024

Conversation

lekoala
Copy link
Contributor

@lekoala lekoala commented Sep 24, 2024

Fixes #1829

See issue for context

Description

Manual testing steps

Issues

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
    • Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me.
I'm just running a CI run against 2.2 to double check if the CI failures are pre-existing.

@GuySartorelli
Copy link
Member

The CI failures aren't happening without this PR. Can you please take a look and see if you can resolve them?

@lekoala
Copy link
Contributor Author

lekoala commented Sep 25, 2024

The CI errors are a bit strange honestly

EDIT : ok I see the classes expect to have a default tab class even with an empty session, i'll fix this

I think these tests assume too much and should probably be fixed but I haven't had a deeper look at it

1) SilverStripe\Admin\Tests\ModelAdminTest::testExportFieldsDefaultIsSummaryFields
InvalidArgumentException: singleton() Called without a class

/home/runner/work/silverstripe-admin/silverstripe-admin/vendor/silverstripe/framework/src/includes/functions.php:28
/home/runner/work/silverstripe-admin/silverstripe-admin/code/ModelAdmin.php:377
/home/runner/work/silverstripe-admin/silverstripe-admin/tests/php/ModelAdminTest.php:81
/home/runner/work/silverstripe-admin/silverstripe-admin/vendor/bin/phpunit:122

2) SilverStripe\Admin\Tests\ModelAdminTest::testGetGridField
InvalidArgumentException: Call <classname>::get() instead of DataObject::get()

/home/runner/work/silverstripe-admin/silverstripe-admin/vendor/silverstripe/framework/src/ORM/DataObject.php:3320
/home/runner/work/silverstripe-admin/silverstripe-admin/code/ModelAdmin.php:401
/home/runner/work/silverstripe-admin/silverstripe-admin/code/ModelAdmin.php:2[94](https://github.com/silverstripe/silverstripe-admin/actions/runs/11013516566/job/30582087994?pr=1830#step:12:97)
/home/runner/work/silverstripe-admin/silverstripe-admin/tests/php/ModelAdminTest/OverridenModelAdmin.php:50
/home/runner/work/silverstripe-admin/silverstripe-admin/code/ModelAdmin.php:266
/home/runner/work/silverstripe-admin/silverstripe-admin/tests/php/ModelAdminTest.php:119
/home/runner/work/silverstripe-admin/silverstripe-admin/vendor/bin/phpunit:122

@lekoala
Copy link
Contributor Author

lekoala commented Sep 25, 2024

@GuySartorelli CI is green

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating so the tests pass!
It's a little less clear what's going on now though, so I've requested a change to the comment to make up for that.

code/ModelAdmin.php Outdated Show resolved Hide resolved
Co-authored-by: Guy Sartorelli <[email protected]>
@michalkleiner
Copy link
Contributor

I'm not sure if the // if we've hit the "landing" page code block now makes sense in the place where it is now, after the new check.

@lekoala
Copy link
Contributor Author

lekoala commented Sep 26, 2024

I'm not sure if the // if we've hit the "landing" page code block now makes sense in the place where it is now, after the new check.

i can update to "if we've hit the "landing" page or if the model is not valid"

i agree it still a bit odd, because you would expect and invalid model to do some kind of errors, but since the model admin class can be instantiated by itself, without a valid user (as designed in the unit tests at the moment), it should still properly return default summary fields for instance

@GuySartorelli
Copy link
Member

Probably updating that comment would do IMO, or else adding a 'reset so we use the "landing page"' comment when setting it to null in the new condition.
What do you think @michalkleiner?

@GuySartorelli
Copy link
Member

Given the change freeze corresponding with the 5.3.0-rc1 release is coming in the next few days (if all goes well), @lekoala can you please update the comment as mentioned above? I'll then merge it in if Michal doesn't respond before I click the button.

@lekoala
Copy link
Contributor Author

lekoala commented Oct 2, 2024

@GuySartorelli done

Copy link
Contributor

@michalkleiner michalkleiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good from my perspective now, thanks Thomas!

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for making that change.

@GuySartorelli GuySartorelli merged commit d14849a into silverstripe:2.2 Oct 3, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants