-
Notifications
You must be signed in to change notification settings - Fork 183
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
Switch key and value in listing #6
Comments
Hmm. I haven't thought of this yet. Glad you raised the issue here at least for discussion. It sounds like it might be a wise idea. My only concern would be how do we warn users of the library of the change in behavior? I assume a change like this would require the user of the library to adjust their code to release the key is now the int id and not project name. Where else did you see this issue? It wasn't too clear to me from the post. Thanks for reporting it. |
Oh! That's a good point indeed. Although as it really happen to you before that you named 2 Versions or Projects the same way? @wsuff : how about renaming the listing method "listingById()" and correcting all the listing() method with the changes proposed by @Eighke ? The change would then be almost transparent to anybody using the listing(). This is not a stable version anyway, so i would say this BC breaks are ok at such an early stage. What do you think? |
@kbsali yes I have some sub Projects with the same name. Something like :
@wsuff , well good question. I checked, only Version and Project is affected. In the other class the name is unique. listingById() isn't a bad idea or maybe something like : public function listing($project, $forceUpdate = false, $reverse = true)
{
if (true === $forceUpdate || empty($this->versions)) {
$this->all($project);
}
$ret = array();
foreach ($this->versions['versions'] as $e) {
$ret[$e[(int) 'id']] = $e['name'];
}
return $reverse ? array_flip($ret) : $ret;
} Dunno which one is the best option. |
Ah. It makes more sense now. This wasn't a case I've noticed on my own install of Redmine yet since getting people to use a system after having none has been enough of challenge. =) listById() sounds ok to me. I can't really see any major downside to either proposed solution tho. Perhaps just a matter of preference and keeping consistence in the library. Just realized this project is only month 1/2 old or so. Guess I lucked out that it was available when I went looking for one. |
@Eighke thanks for pointing out this solution, |
Tested and approved. :) Thanks. |
Fatal error: Uncaught TypeError: Cannot assign int to property Redmine\Client\NativeCurlClient::$lastResponseContentType of type string in D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\libs\Redmine\Client\NativeCurlClient.php:235 Stack trace: #0 D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\libs\Redmine\Client\NativeCurlClient.php(81): Redmine\Client\NativeCurlClient->request('get', '/users/current....') kbsali#1 D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\libs\Redmine\Api\AbstractApi.php(49): Redmine\Client\NativeCurlClient->requestGet('/users/current....') kbsali#2 D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\libs\Redmine\Api\User.php(121): Redmine\Api\AbstractApi->get('/users/current....') kbsali#3 D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\libs\Redmine\Api\User.php(66): Redmine\Api\User->show('current', Array) kbsali#4 D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\cloodo.php(27): Redmine\Api\User->getCurrentUser(Array) kbsali#5 D:\xampp-v8\htdocs\wordpress\wp-settings.php(391): include_once('D:\\xampp-v8\\htd...') kbsali#6 D:\xampp-v8\htdocs\wordpress\wp-config.php(90): require_once('D:\\xampp-v8\\htd...') kbsali#7 D:\xampp-v8\htdocs\wordpress\wp-load.php(37): require_once('D:\\xampp-v8\\htd...') kbsali#8 D:\xampp-v8\htdocs\wordpress\wp-admin\admin.php(34): require_once('D:\\xampp-v8\\htd...') kbsali#9 {main} thrown in D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\libs\Redmine\Client\NativeCurlClient.php on line 235
* Fix $lastResponseContentType of type string Fatal error: Uncaught TypeError: Cannot assign int to property Redmine\Client\NativeCurlClient::$lastResponseContentType of type string in D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\libs\Redmine\Client\NativeCurlClient.php:235 Stack trace: #0 D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\libs\Redmine\Client\NativeCurlClient.php(81): Redmine\Client\NativeCurlClient->request('get', '/users/current....') #1 D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\libs\Redmine\Api\AbstractApi.php(49): Redmine\Client\NativeCurlClient->requestGet('/users/current....') #2 D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\libs\Redmine\Api\User.php(121): Redmine\Api\AbstractApi->get('/users/current....') #3 D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\libs\Redmine\Api\User.php(66): Redmine\Api\User->show('current', Array) #4 D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\cloodo.php(27): Redmine\Api\User->getCurrentUser(Array) #5 D:\xampp-v8\htdocs\wordpress\wp-settings.php(391): include_once('D:\\xampp-v8\\htd...') #6 D:\xampp-v8\htdocs\wordpress\wp-config.php(90): require_once('D:\\xampp-v8\\htd...') #7 D:\xampp-v8\htdocs\wordpress\wp-load.php(37): require_once('D:\\xampp-v8\\htd...') #8 D:\xampp-v8\htdocs\wordpress\wp-admin\admin.php(34): require_once('D:\\xampp-v8\\htd...') #9 {main} thrown in D:\xampp-v8\htdocs\wordpress\wp-content\plugins\wordpress-cloodo-plugins\libs\Redmine\Client\NativeCurlClient.php on line 235 * Create test for handling of missing content type Co-authored-by: Art4 <art4@wlabs.de>
Hi,
In Version, the listing() function uses the name as key. But the name isn't unique and if you used a name twice or more, only the last is sent back. This also is a problem in Project.
Would it not be better to use the ID as key?
And for getIdByName()
The text was updated successfully, but these errors were encountered: