-
Notifications
You must be signed in to change notification settings - Fork 23
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
FilteredBehavior and CakePHP 2.3.x #10
Comments
Hi there, Would it be possible for you to create a small unit test for this? I'm curious to see what kind of data will recreate this bug. |
Sure, I'm enjoing web-design, which means that I'm learning it, just form In the meantime I ran the testsuite of cake, with the following results Running All FilterPlugin tests Running FilterTestCase
Test case: FilteredTestCase(testFilteringBelongsTo)
Test case: FilteredTestCase(testFilteringBelongsToTextField)
Test case: FilteredTestCase(testFilteringBelongsToFilterFieldTest)
Test case: FilteredTestCase(testFilteringBelongsToDifferentConditions)
Test case: FilteredTestCase(testFilteringBelongsToAndHasMany)
Test case: FilteredTestCase(testCustomJoinConditions)
Test case:
Test case: FilteredTestCase(testHasOneAndHasManyWithTextSearch)
Test case: FilteredTestCase(testHasOneWithContainable)
Test case: FilteredTestCase(testJoinAlreadyPresent)
Test case: FilteredTestCase(testNofilterFindParam) 33/33 test methods complete: 17 passes, 16 fails, 38 assertions and *0
Time: 2.2565364837646 seconds Peak memory: 14,554,024 bytes Run more testshttp://localhost/myKGM/webroot/test.php?show=cases&plugin=Filter| 1<?php FilterComponent.php Code coverage: 77.23% 1<?php bootstrap.php Code coverage: 0% 1url('/', true)); 39 } 40 41 42 /_ 43 set true if new registrations are allowed 44 _/ 45 if (!defined("SITE_REGISTRATION")) { 46 define("SITE_REGISTRATION", true); 47 } 48 49 /_ 50 set true if you want send registration mail to user 51 _/ 52 /_ if(!defined("SEND_REGISTRATION_MAIL")) { 53 define("SEND_REGISTRATION_MAIL", true); 54 } _/ 55 if (!defined("SEND_REGISTRATION_MAIL")) { 56 define("SEND_REGISTRATION_MAIL", false); 57 } 58 59 /_ 60 set true if you want verify user's email id, site will send email confirmation link to user's email id 61 sett false you do not want verify user's email id, in this case user becomes active after registration with out email verification 62 _/ 63 /_ if(!defined("EMAIL_VERIFICATION")) { 64 define("EMAIL_VERIFICATION", true); 65 } 66 _/ 67 if (!defined("EMAIL_VERIFICATION")) { 68 define("EMAIL_VERIFICATION", false); 69 } 70 /_ 71 set email address for sending emails 72 _/ 73 if (!defined("EMAIL_FROM_ADDRESS")) { 74 define("EMAIL_FROM_ADDRESS", '[email protected]'); 75 } 76 77 /_ 78 set site name for sending emails 79 _/ 80 if (!defined("EMAIL_FROM_NAME")) { 81 define("EMAIL_FROM_NAME", 'User Management Plugin'); 82 } 83 84 /_ 85 set login redirect url, it means when user gets logged in then site will redirect to this url. 86 _/ 87 if (!defined("LOGIN_REDIRECT_URL")) { 88 //define("LOGIN_REDIRECT_URL", '/viewUser'); 89 define("LOGIN_REDIRECT_URL", '/'); 90 } 91 92 /_ 93 set logout redirect url, it means when user gets logged out then site will redirect to this url. 94 _/ 95 if (!defined("LOGOUT_REDIRECT_URL")) { 96 define("LOGOUT_REDIRECT_URL", '/login'); 97 } 98 99 /_ 100 set true if you want to enable permissions on your site 101 _/ 102 if (!defined("PERMISSIONS")) { 103 define("PERMISSIONS", true); 104 } 105 106 /_ 107 set true if you want to check permissions for admin also 108 _/ 109 if (!defined("ADMIN_PERMISSIONS")) { 110 define("ADMIN_PERMISSIONS", false); 111 } 112 113 /_ 114 set default group id here for registration 115 _/ 116 if (!defined("DEFAULT_GROUP_ID")) { 117 define("DEFAULT_GROUP_ID", 2); 118 } 119 120 /_ 121 set Admin group id here 122 _/ 123 if (!defined("ADMIN_GROUP_ID")) { 124 define("ADMIN_GROUP_ID", 1); 125 } 126 127 /_ 128 set Guest group id here 129 _/ 130 if (!defined("GUEST_GROUP_ID")) { 131 define("GUEST_GROUP_ID", 3); 132 } 133 /_ 134 set true if you want captcha support on register form 135 _/ 136 if (!defined("USE_RECAPTCHA")) { 137 define("USE_RECAPTCHA", false); 138 } 139 /_ 140 set Admin group id here 141 _/ 142 if (!defined("PRIVATE_KEY_FROM_RECAPTCHA")) { 143 define("PRIVATE_KEY_FROM_RECAPTCHA", ''); 144 } 145 /_ 146 set Admin group id here 147 _/ 148 if (!defined("PUBLIC_KEY_FROM_RECAPTCHA")) { 149 define("PUBLIC_KEY_FROM_RECAPTCHA", ''); 150 } 151 /_ 152 set login cookie name 153 */ 154 if (!defined("LOGIN_COOKIE_NAME")) { 155 define("LOGIN_COOKIE_NAME", 'UsermgmtCookie'); 156 } 157 Cache::config('UserMgmt', array( 158 'engine' => 'File', 159 'duration' => '+3 months', 160 'path' => CACHE, 161 'prefix' => 'UserMgmt_'.'myKGM_' 162 )); 163} 164?> MockObjects.php Code coverage: 71.43% 1<?php FilteredBehavior.php Code coverage: 95.59% 2013/6/17 dr. Hannibal Lecter [email protected]
|
I ran the tests with Cake 2.3.6 and PHP 5.3.3 (unfortunately, no PHP 5.4.x at the moment), and all the tests are passing on my machine. Can you confirm that you are running unmodified version of the plugin? This may be happening because of the PHP difference, but it's difficult to tell without a real test. If you still have the will to write a test, you can look at the existing tests in the plugin, and simply copy and modify one of them to reproduce the error you're getting. It's either that, or waiting until I upgrade my OS and test it myself (which may take a while!). |
CakePHP v2.3, PHP v5.4
The FilteredBehavior returns an empty $query['conditions']-array.
A little research learned me this:
function beforeFind(Model $Model, $query)
{
...
$settings = $this->settings[$Model->alias];
$values = $this->_filterValues[$Model->alias];
Inhere, the methodcall
$this->addFieldToFilter($Model, $query, $settings, $values, $field, $options); returns an empty $query['conditions']-array.
Some new investigations:
protected function buildFilterConditions(array $query, $field, $options, $value)
{
...
The method creates the $query['conditions'] well, but after the transfer to beforeFind, it is empty. The only place where the $query['conditions']-array is properly set is after switch{ ... }.
any suggestions?
The text was updated successfully, but these errors were encountered: