phpMyEdit - Rozšírené detaily chyby [ Späť ]
233 core / field option veľká vždy 2004-04-19 14:18 2006-01-23 01:45
jonw All  
nepto Debian Linux  
normálna 3  
uzavretý 5.4 (stable)  
vyriešený  
žiadny  
žiadny  
Sort order for phpMyEdit forms reversed after 'more' button used
Easiest explained with a test case (see file attachment).

Basically, using $opts['sort_field'] = array('-timestampfield') works fine when the phpMyEdit form is initially displayed, but when a record is added and the 'More' button clicked to add an additional record, then 'Cancel' clicked the original sort order for the form has been lost and the form contents are listed as if $opts['sort_field'] = array('timestampfield'); had been used instead (ascending date/time order instead of descending).
1. Use test.sql database from included file to create a new database 'testdb', adjust username/pass in testnews.php to suit database server.

2. Open testnews.php in a browser - notice that date order is correctly reverse-sorted (newest items first).

3. Click on 'Add', then fill in a date and some contents for the new news item.

4. Click 'More', then click 'Cancel'.

You are returned to the list, but the sort order has now been reversed and the newest item is now at the bottom of the list.
0000233-phpmyeditbug.zip.txt (1 KB) 1970-01-01 01:33
0000233-michal-patch.diff.txt (1 KB) 1970-01-01 01:33

Poznámky k chybe
jonw   
2004-04-19 14:24   
Forgot to say - the same appears to occur with current CVS version (as at 18th April '04) too.
michal   
2004-04-19 18:42   
after some test, try to move line
$this->sfn[] = '0'; // this last entry will be replaced in recreate_displayed()

to recreate_displayed(), before line
$this->sfn[count($this->sfn) - 1] = "$k"; // important quotes

for me it helped.

but changing to 'date' to array('date') helped too (in my first tests), so i'm not sure :)
jonw   
2004-04-20 01:45   
OK, patched the code as suggested and it fixes the case in my test database, will now retest against main code and see if it works there too.

Many thanks for the prompt responses and help Michal.

Will confirm here if it fixes the original code too.
jonw   
2004-04-20 06:58   
Confirmed - this has fixed the issue in my production code too, many thanks!

Maybe one to add to CVS ?
michal   
2004-04-20 09:11   
and to add some code efficiency, can you confirm changing
$this->sfn[] = '0';
$this->sfn[count($this->sfn) - 1] = "$k"; // important quotes

to
$this->sfn[] = "$k";

works ?
jonw   
2004-04-20 09:55   
Yup, that appears to be fine too, will need to test further but either way seems to fix the original problem.

Thanks again!
nepto   
2004-07-13 19:34   
Uploaded michal's patch, which seems to work OK.

Bug was fixed in CVS. It also fixes strange sorting dissapear after Apply button usage.

Thank you for your contribution and michal for the bugfixing idea. Feel free to reopen if problem still persists.