Jump to content

Robin S

Members
  • Posts

    5,008
  • Joined

  • Days Won

    333

Everything posted by Robin S

  1. I was able to reproduce this issue. It seems to occur when any of the pages being cloned have file or image fields in their template. If the parent page has a file/image field but not the children then setting output formatting off before cloning the page seems to work. But if the child pages have a file/image field then setting output formatting off on those children doesn't work. But I don't think output formatting should need to be off when cloning a page - the clone() docs make no mention of output formatting and don't show it being set in the example code, and indeed it doesn't need to be off unless a file/image field is present. And seeing as setting output formatting off in the child pages still doesn't allow for a successful clone I'd say this is a bug. @simonsays, do you want to open an issue for this in the GitHub issues repo?
  2. I discovered the empty $input dump as soon as __debugInfo() was made the default dump in Tracy. Sorry, I should have raised it at the time but was in the middle of something so just changed back to the full dump setting and then forgot about it. Maybe it's just because I'm more used the full dump, but I still prefer that option. I like having more info in the dump rather than less and don't mind wading through it to find what I'm looking for.
  3. I just thought you might have some trick, because in this post you seemed to be able to use Tracy to dump inside Page::resetTrackChanges but when I tried bd() was undefined inside that method.
  4. Hi @tpr, any thoughts on this...
  5. Hi @adrian, Until Ryan adds core support for loading Tracy early, what do you think about adding some Tracy option to make it easier for users to load Tracy early if they don't mind making changes to the core index.php for that purpose? Something like Tracy checks if $config->earlyTracy is true and if so doesn't load files that will have been loaded in the modified index.php. So the user only has to modify core file(s) and not Tracy files. On a related note, I'm trying to follow the suggestions you made here to load Tracy early but I can't get it working. I have these extra lines in index.php... require_once $config->paths->siteModules.'TracyDebugger/tracy-master/src/tracy.php'; require_once $config->paths->siteModules.'TracyDebugger/includes/TD.php'; require_once $config->paths->siteModules.'TracyDebugger/includes/ShortcutMethods.php'; ...and have commented out their equivalents in TracyDebugger.module, but I get this error: Fatal error: Class 'TracyDebugger' not found in D:\_Websites\_www\1testing\site\modules\TracyDebugger\includes\TD.php on line 6 Could you explain again any tricks you know for how to load Tracy early? Thanks.
  6. @adrian, until a fix is found a workaround is to set one (or both) of the Page Reference fields to dereference as a PageArray. Related issue: https://github.com/processwire/processwire-issues/issues/152
  7. @adrian, is there a chance that somehow the value is in fact the user being edited? You could dump the ID of $value to check. Just a guess, but I'm wondering if the strict comparison here... $value !== $this ...doesn't catch a user page because it is a object of classname User rather than just a plain Page.
  8. I think you'll find it easier if you use a plain PHP array so that you can make it nested/multidimensional. You can't have nested PageArrays you see. I'm not sure I 100% understand your scenario, but hopefully this helps: // Get $allPlayers somehow $uniqueGroups = []; foreach($allPlayers as $player) { // Define the $groupId // Use an underscore (or other non-integer) in the $groupId to force it to be a string, not an integer // That way when array_multisort() is used later the keys will be preserved $groupId = $player->team->id . '_' . $player->group->id; // Optional: add $groupId to $player as a custom property in case you need it later $player->groupId = $groupId; // Add player to $uniqueGroups using $groupId as key $uniqueGroups[$groupId]['players'][] = $player; } bd($uniqueGroups, 'uniqueGroups'); // have a look at what's in $uniqueGroups foreach($uniqueGroups as $groupId => $data) { $uniqueGroups[$groupId]['karma'] = 0; // initialise to zero $uniqueGroups[$groupId]['bonus'] = 0; // initialise to zero // Tally up the group's karma foreach($data['players'] as $player) { $uniqueGroups[$groupId]['karma'] += $player->karma; } // Do the same for bonus //... } bd($uniqueGroups, 'uniqueGroups'); // have a look at what's in $uniqueGroups // Sort the $uniqueGroups by karma (for example) array_multisort(array_map(function($group) { return $group['karma']; // return the value you want to sort by }, $uniqueGroups), SORT_ASC, $uniqueGroups); bd($uniqueGroups, 'uniqueGroups'); // have a look at what's in $uniqueGroups See this article for a good introduction to array_multisort() - in the code above array_map() is used to get the sort values instead of another foreach().
  9. This CSS seems to be working well for me so far... #tracy-debug-bar { position:fixed !important; left:auto !important; top:auto !important; right:0 !important; bottom:0 !important; }
  10. That screencast is with the latest version (4.10.19).
  11. Hi @adrian, I'm experiencing an issue with Tracy in AdminThemeUikit (I don't remember it happening in AdminThemeDefault) where the debug bar forgets its position between page loads. I normally keep the debug bar at bottom right, but it forgets this and jumps up to the top left (sometimes other random locations too). It seems to be related to opening a modal window, with Tracy enabled for modals. See in the screencast below how after opening and closing the modal then reloading the page Tracy is now at the top left of the screen. Hopefully not too tricky to fix. If in fact it is tricky, I wouldn't mind an option that keeps the debug bar locked in the bottom right because personally I never move it from there. Edit: it does happen in AdminThemeDefault also. Funny, because I always have Tracy enabled for modals and I don't remember this occurring before. Maybe a side-effect of a recent update to the module?
  12. If the hook is removed then it will fix the issue I was seeing, because with the autocomplete attribute being on the password fields those fields aren't autofilled by Chrome. So if the extra condition you added to the JS prevents your generated password from being cleared and you can therefore remove the hook then it will be all good from my end. I guess if/when Firefox autofills the password field it doesn't affect the value attribute? I can't test it here because I can't get Firefox to autofill the password field anyway (or I just don't know what steps are required to reproduce the issue on that browser).
  13. I guess the issue is because of how you are assigning $r. When you assign like this $r gets the value of $p->repeater but is otherwise not connected to it. The PHP manual says: So when you add an item to $r you are not adding it to $p->repeater. Does the problem resolve if you assign $r by reference? $r = &$p->repeater;
  14. Sure, is now pending approval approved for the directory.
  15. Are you positive the   is not actually there in the source? Not sure what tool that screenshot is from but some tools will decode HTML entities in which case   would just display as a space between words. Also, I can see an inline color style in your screenshot - is that coming from Javascript perhaps? If so, disable all your Javascript to make sure it is not responsible for converting the   entity.
  16. A couple of things that might be relevant to the problem: 1. $cache is an API variable (WireCache) - better not overwrite it with something else. 2. WireCache provides everything that the MarkupCache module does plus more. Maybe consider using WireCache instead.
  17. Welcome to the PW forums @Jules Vau Probably silly question, but you are entering   right? It is working for me with the same settings as you show above (although I didn't enter anything in Extra Allowed Content as that shouldn't be needed in this case). I tested in 3.0.99 but I don't think anything has changed in this regard since 3.0.96.
  18. @adrian, looking at the commit that introduced the issue, it looks like removing the autocomplete attribute is an attempt to defeat this piece of InputfieldPassword.js. That piece of JS is a fairly old (and hacky) response to a browser-specific (Firefox) issue that probably no longer applies. The recent autofill fixes in InputfieldPassword and updates/bug-fixes to Firefox should have solved it without the need for that JS workaround (I tested quickly in the latest Firefox and couldn't see any issue with the JS removed). So you could raise a GitHub issue/request to see if Ryan will remove that JS. In the custom module I made for a project recently I took a different approach to auto-generated passwords. Rather than populate the core password field I manipulated the ProcessUser form to... 1. Hide the password field with CSS 2. Add a markup field to show the user the auto-generated password 3. Add a hidden field containing the auto-generated password Then in a before hook to InputfieldPassword::processInput I copy the password value from the hidden field to the password field in $input. That may not be an approach you'd want to take with your module, but just to show there might be other ways to tackle things if Ryan doesn't want to remove that problematic JS.
  19. The issue is exactly as you described it in the GitHub issue I linked to above. It is related to the browser autofilling the password field, so it depends on the form history that is saved in your browser. It's not the kind of thing that will always cause a problem, more one that can (but shouldn't) cause a problem. The fix that Ryan pushed to the core was to avoid that.
  20. The import/export of fields and templates has been around since PW v2.5 (2014), so I think you could consider the feature as stable as anything else in the stable branch. For reference, the blog posts that introduced the features... https://processwire.com/blog/posts/august-2014-core-updates-1/ https://processwire.com/blog/posts/august-2014-core-updates-3/ I think it would be wise to be extra vigilant when exporting/importing non-core fieldtypes, and complex fieldtypes that need to account for templates/fieldgroups such as Repeater, Repeater Matrix, and maybe PageTable. Support was added for import/export of Repeater fields in late 2017 but Ryan said at the time "Seems to be working well here, but definitely needs more testing."
  21. Hi @adrian, just a heads up: I was again experiencing this issue that you raised in the PW issues repo a while ago: https://github.com/processwire/processwire-issues/issues/432 It was a bit puzzling but I traced it back to the Email New User module which I was testing out. Due to this commit the module is undoing the fix that was applied in the PW core.
  22. Not a big problem, but the only other thing I would say is: imagine if every PW module developer did this. Would it be cool if there was an extra branding link in every MarkupSimpleNavigition menu? Maybe nobody would use that module then...
  23. I'm not an expert on software licenses, but I think this restriction is incompatible with the license you are releasing the module under (which seems to be the MIT license based on the code comment here). The MIT license allows for modification, so anyone can modify the code to remove the branding markup. Not sure what sort of license would be compatible with what you intend - I think all the common open source licenses permit modification.
  24. I have used the script below to do that, but must emphasise that this is destructive. The script does copy the original image to a "for_deletion" folder in the site root, but in case of disaster it would be a big PITA to go through and put the original images back to their relevant pages. So use at your own risk! // You could run this script manually, or put it on LazyCron if you have a lot of images // Maximum image dimensions $max_width = 1600; $max_height = 1600; // Images to process per operation $limit = 5; // Create array of large images $large_images = []; $i = 1; foreach($fields->find("type=FieldtypeImage") as $field) { if(!count($field->getFieldgroups())) continue; foreach($pages->find("{$field->name}.count>0") as $p) { foreach($p->getUnformatted($field->name) as $image) { if($i > $limit) break; if($image->width > $max_width || $image->height > $max_height) { $large_images[] = [ 'basename' => $image->basename, 'filename' => $image->filename, 'page' => $p->url, ]; $i++; } } } } // Iterate over images foreach($large_images as $large_image) { // Make backup copy of image (create the "for_deletion" folder first) $destination = $config->paths->root . 'for_deletion/' . $large_image['basename']; if(!file_exists($destination)) { $success = copy($large_image['filename'], $destination); // Don't carry on to the resizing stage if the copy wasn't successful if(!$success) continue; // Log file copy $log->save('resized_images', "Copied original image {$large_image['basename']} from {$large_image['page']} to /for_deletion/"); } /* @var ImageSizer $sizer */ $sizer = new ImageSizer($large_image['filename'], ['cropping' => false]); $sizer->resize($max_width, $max_height); // Log file resize $log->save('resized_images', "Resized image {$large_image['basename']} on page {$large_image['page']} to max width $max_width, max height $max_height"); } If you are using image field types besides the core FieldtypeImage you could modify the identification of image fields to something like this.
  25. You access it like any other property of the field... ...or am I misunderstanding your question?
×
×
  • Create New...