horst Posted November 15, 2015 Share Posted November 15, 2015 Hi, I try to avoid updating of the modified timestamp and modified user. It should be done with passing "quiet"=>true in an options array together with the save method(s): $page->setAndSave('sort', $mySortvalue, array('quiet' => true)); But regardless if I use setAndSave() or save(), it gets updated every time. What I'm missing? I use PW 2.7 stable. Link to comment Share on other sites More sharing options...
LostKobrakai Posted November 15, 2015 Share Posted November 15, 2015 If your using the quiet mode it's not ignoring the modified field, but just again setting it with the old values, so modified and modified_user need to be set to not be updated (see more here): $data['modified_users_id'] = (int) ($page->modified_users_id ? $page->modified_users_id : $userID); … if($page->modified > 0) $data['modified'] = date('Y-m-d H:i:s', $page->modified); else if($isNew) $sql = 'modified=NOW()'; Link to comment Share on other sites More sharing options...
horst Posted November 15, 2015 Author Share Posted November 15, 2015 Yes, I have seen this. But in my case it seems not to use the old values. I only want to change the sort value, and therefore it would be really good to not update the last modified timestamp. But when I inspect those pages in the pages finder, the modified time shows "before 2 seconds" or that like. I already have hacked into page::save and pages::savePageQuery with an debug function and saw that it retrieved the right values from the DB. So, I don't understand where it lost that or where it changes it or if it do another save after that ?? It shouldn't. My code is really simple, it is that piece to move pages down in the pagetree. Link to comment Share on other sites More sharing options...
LostKobrakai Posted November 15, 2015 Share Posted November 15, 2015 Did you try checking if the quiet setting is correctly delivered to the savePageQuery() func and if the other values are still correct there just before the if statement? Link to comment Share on other sites More sharing options...
horst Posted November 16, 2015 Author Share Posted November 16, 2015 yes, i have. Here is what is in the $options array when it reaches Line 1110, just before the if(empty($options['quiet']): $options array(6) { ["uncacheAll"] bool(true) ["resetTrackChanges"] bool(true) ["adjustName"] bool(false) ["forceID"] int(0) ["ignoreFamily"] bool(false) ["quiet"] bool(true) } $data array(5) { ["parent_id"] int(1011) ["templates_id"] int(44) ["name"] string(64) "sanierung-industriegebaeude-weiss-umwelttechnik-gmbh-reiskirchen" ["status"] int(1) ["sort"] int(999998749) } And after the if statement, $data looks like this: $data array(9) { ["parent_id"] int(1011) ["templates_id"] int(44) ["name"] string(64) "sanierung-industriegebaeude-weiss-umwelttechnik-gmbh-reiskirchen" ["status"] int(1) ["sort"] int(999998749) ["modified_users_id"] int(41) ["created_users_id"] int(1101) ["modified"] string(19) "2015-11-15 22:06:54" ["created"] string(19) "2015-09-25 08:18:44" } The info in the page, before executing the code is: Erstellt von peter am 2015-09-25 08:18:44 (vor 2 Monate)Zuletzt geändert von peter am 2015-11-15 22:06:54 (vor 10 Stunden)Published on 2015-09-25 08:18:44 (vor 2 Monate) After the execution, the info looks like this: Erstellt von peter am 2015-09-25 08:18:44 (vor 2 Monate)Zuletzt geändert von peter am 2015-11-16 07:45:50 (vor 10 Sekunden)Published on 2015-09-25 08:18:44 (vor 2 Monate) Link to comment Share on other sites More sharing options...
LostKobrakai Posted November 16, 2015 Share Posted November 16, 2015 Now that's interesting. The data array seems to be correct even after the if statement, so something in the lines below must be the culprit. Maybe some db query caching or such? That's maybe a bit to deep even for my knowledge of the core. 1 Link to comment Share on other sites More sharing options...
horst Posted November 16, 2015 Author Share Posted November 16, 2015 I have changed the line in my code that uses $page->setAndSave() with an own function that updates the values directly in the pages table. This way it works for me at the moment. But I think, we should send Ryan a link to this thread. databaseUpdateSortInPages($page->id, $sortValue); function databaseUpdateSortInPages($id, $sort) { $sql = "UPDATE pages SET sort = $sort WHERE id = $id"; $query = wire('database')->prepare($sql); $query->execute(); } 1 Link to comment Share on other sites More sharing options...
ryan Posted December 28, 2015 Share Posted December 28, 2015 Horst, I've not been able to duplicate this one here. The code I'm using to test: <pre><?php include("./index.php"); $test = $pages->get("/about/"); echo "$test->title - $test->sort - $test->modifiedStr\n"; $test->setAndSave('sort', $test->sort + 1, array('quiet' => true)); echo "$test->title - $test->sort - $test->modifiedStr\n"; Anything I'm missing with regard to reproducing it? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now