Skip to content

Conversation

@ddinchev
Copy link
Contributor

I've moved out the logic to persist and load persisted language in protected methods. This way they can be overridden - I needed that to integrate the component with an existing application i18n component that has its own storage.

PS: I'd be happy to break down all of the lengthy methods into smaller ones so they are more readable and extendable if you would accept such a change (no logic altered, just refactorings)?

UrlManager.php Outdated
}

/**
* Persists language in session and cookie.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be

@param string $language the language code to persist 
UrlManager.php Outdated
}

/**
* Attempts to load language from persistent storage. Returns null if not found.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could be combined into a single line:

@return string|null the persisted language code or null if none found 
@mikehaertl
Copy link
Collaborator

@ddinchev Yes, it seems to make sense. The library has grown over the years and the code has become bloated. But let's refactor one part at a time.

Sidenote: If you happen to find a quick solution for failing travis tests that would be great. I remember there was some issue about missing inputmask dependency at yiisoft, but I don't have time to look into it.

I want to make sure, that the tests pass before I merge this.

@mikehaertl
Copy link
Collaborator

@ddinchev Ah, thanks, much better :).

If you could check my two little code comments I'd merge.

@ddinchev
Copy link
Contributor Author

ddinchev commented Sep 29, 2017

@mikehaertl thanks for the blazing-fast responses! I've amended my changes. I've committed the composer.lock file as per composer recommendations which will improve and stabilize the dependency installation time.

@mikehaertl
Copy link
Collaborator

I've committed the composer.lock file as per composer recommendations which will improve and stabilize the dependency installation time.

Hmm, sorry, I think I disagree on this one. It may make sense for complete apps. But as this here is rather a library I don't want to force too specific version constraints on the user. The dependency configuration in composer.json should be fine. So could you reverse that change please?

If you really think this needs further discussion please open an issue for it.

@ddinchev
Copy link
Contributor Author

ddinchev commented Sep 29, 2017

TravisCI failed because GitHub blocks the tons of requests to resolve the dependencies, thus requiring an auth token to proceed. With a lock file, it installs the correct versions directly.

Could you read the documentation link I've added? They have articulated the arguments to do so better than I could. When the library is installed as a dependency, it does not install any of the dependencies specified in the composer file - with or without .lock one. However, when the CI server or the developer tries to install it locally, to develop or test - without a .lock file composer will install the latest versions that match the version range. And if by any reason a newer version causes a bug, it leads to really unpleasant debugging process.

Further, this is what Composer team says about .lock files for libraries:
https://getcomposer.org/doc/02-libraries.md#lock-file

However, this lock file will not have any effect on other projects that depend on it. It only has an effect on the main project.

@mikehaertl
Copy link
Collaborator

Hmm, isn't the problem rather something with fxp-assetplung (Did i mention how much I hate this thing?) and jquery inputmask? I think you even proposed some workaround in this issue here: yiisoft/yii2#14275 (comment)

We should try something similar maybe. But I'm still against having composer.lock. IMO the section you linked to is really targeted at concrete applications. We have a library here and having the version constraints defined in composer.json should be fine.

Put another way composer.json works great - unless we are forced to use this stupid fxp asset plugin which sucks big time.

@mikehaertl
Copy link
Collaborator

To speed things up a bit: I'll have a look at the broken travis tests myself. If you remove the corresponding commits here I'll merge the refactoring part. Please also remove the composer.lock again. As said before - if really we can discuss this in a dedicated issue or PR.

@mikehaertl
Copy link
Collaborator

@ddinchev I've fixed the travis tests now by adding the asset-packagist repo. This is the fix they also used with official yii2 plugins: yiisoft/yii2-bootstrap@e6a20fa#diff-b5d0ee8c97c7abd7e3fa29b9a27d1780

@ddinchev
Copy link
Contributor Author

Thanks @mikehaertl! I've removed my changes related to composer.lock.

I did point to the documentation that specifically said it's still a good idea to commit for libraries that are intended to be included in projects (like this one is) and does not have any side effects. Yii2 framework itself has the composer.lock committed. This being said, I think it should be up to you if you find it valuable and I don't believe it's worth continuing this discussion in an issue.

@mikehaertl
Copy link
Collaborator

Yii2 framework itself has the composer.lock committed.

Yes, but official yii2 libraries don't:

The main reason is, that you would have to update the composer.lock from time to time in order to use the latest depencies. Whereas with only the composer.json it will always fetch whatever latest dependecy version will meet the constraints when the tests run. It's too easy to forget to update composer.lock.

@mikehaertl mikehaertl merged commit 8b65782 into codemix:master Sep 30, 2017
@mikehaertl
Copy link
Collaborator

Just released 1.4.13 containing this change. Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants