-
Posts
1,554 -
Joined
-
Last visited
-
Days Won
48
Everything posted by gebeer
-
Don't think that many people will have a need for this. But would be nice for sure ? Reason why I need a separate module is also that it should be independent of other modules (aka TD). I am using Tracy on every install. But not all devs do that and the agency I am freelancing for would like to have it as a standalone tool.
-
Hi, bringing this up again because I found the reason. On install of MM, the children under Admin->MediaManager got named "media-manager--image", --audio etc. No idea how this happended, though. Guess I will rename them manually. Since on upload the parent is defined by those page names, no parent is defined and all media gets saved under Media Manage:Audio. A check in MediaManagerActions.php around L1575 for $parent instancof NullPage or the like would be great to at least issue a warning. Consequently the checks for duplicates on upload did not work. This is how I discovered the root cause.
-
@adrian Thank you for all the info. That will help a lot. will look through your code where Tracy gets started up. That should give me good pointers. Rollbar also uses set_error_handler. Their docs say to init Rollbar at the entry point of the application. I'll find the right place to do this. Great pointer. I need this as a standalone module because we want to have different targets to report to based on error levels.. But once I have that, we can add an option to Tracy as well. Thanks again for all those useful links.
-
Module Concept for Error Reporting via Email
gebeer replied to gebeer's topic in Module/Plugin Development
Thanks again @flydev I am still investigating this. In wire/core/Wire.php there is a hookable method trackException. This seems to be a good place to hook into for errors/exceptions. But for Warnings I'm still not 100% sure how to them. To me it seems like WireLog is only taking care of 'error' and 'exception'. Notices has a NoticeWarning class. That looks promising but they seem to only get logged when in debug mode. I will experiment with those findings. FYI: The module I am planning to build will most likely include an option to send errors to https://rollbar.com/ using https://docs.rollbar.com/docs/basic-php-installation-setup. But also an option to just email them to configurable addresses. -
Hi @adrian Tracy is acting on all Errors/Exceptions (and in strict mode also Warnings) while it is active. May I ask how your module achieves that? This question is related to Basically I want to catch all Errors/Exceptions (+ Warnings, if possible) and act upon them. And I'm struggling in finding a clever way to do so. In your module I see a hook to 'ProcessWire::trackException'. Would this be a good place to start for Exceptions? But what about Warnings? For example, if I wanted to use an external service for error reporting like https://docs.rollbar.com/docs/basic-php-installation-setup, where would I intercept PW Errors to init my custom error handler?
-
This might be helpful: https://korepov.pro/infobase/vs-code/23 Haven't tried it myself but looks promising.
-
Update: When I measured CPU and MEM usage, I used Linux top command. I just discovered that you need to switch the mode to correctly display multi-core CPU percentage ? https://unix.stackexchange.com/questions/34435/top-output-cpu-usage-100 After switching to Solaris mode the numbers look much better with around 100 open sessions ? mysqld: 0.1% php-fpm: 0.1%
-
Thanks for the input! File-Cache you mean then? Because https://processwire.com/api/ref/wire-cache/ is DB driven, I think.
-
Hi all, I'm currently working on a PW app that is expected to get a lot of traffic for a few days. Peak will be around 5000 requests/second. The app is hosted on a virtuel server within the client's network and has some quite impressive specs: - 32 core CPUs - 80 GB RAM Now I am wodering if the server will be able to handle high loads. ATM we have around 100 open sessions per second and mysqld process is already spiking around 10% and php-fpm around 2-5%. We did load tests with 5000 virtual users through https://loadforge.com/ and the server is starting to produce hangs at only around 50 requests/second. On the code side there is nothing really special. No expensive queries that I am aware of. Caching is not really an option because frontend views mostly depend on frequently changing data and most views have form submissions. There is one dashboard view with long polling XHR requests for JSON data. This data can also not be cached because it changes frequently so I think permamnently updating cache on data changes would be equally expensive as just not caching it. Unfortunately we have no server monitoring tools at our disposal. But I would think that a server with these specs should be able to easily handle hundreds of requests/s. The IT responsivle for the server do not seem to have a lot of experience with LAMP stack web servers. So I'm concerned there might be some MySQL missconfigurations. Anyways, if any of you have experience with high load PW apps, please share your expertise ?
-
Emails in IDN format do not get saved, cannot be entered
gebeer replied to gebeer's topic in General Support
It is odd that modern browsers do not support email validation following RFC 6530 out of the box. Popular PHP/JS libs like https://github.com/egulias/EmailValidator and https://www.npmjs.com/package/isemail/v/3.2.0 do support it. Seems like we would have to come up with a custom email input JS validator to make this work in the GUI. That is certainly something that @ryan would have to implement. Not sure how other CMS/Frameworks support this feature. But would be awesome if ProcessWire did. -
PHP Session the PW way at its most basic
gebeer replied to modifiedcontent's topic in General Support
Sorry if I was rude. I apologize. Had a bad day yesterday... From your other thread about Apache and suExec configuration it seems that most of the session stuff might also be user/permission related. -
PHP Session the PW way at its most basic
gebeer replied to modifiedcontent's topic in General Support
Session on the client side are stored in cookies. You can use your browser's dev tools to inspect those. HOw that happened, no idea. To confirm that SessionHandlerDB module is installed you can go to Modules->Core. If you see Session Handler Database listed with a green Settings Button, then it is installed. In the page tree under Admin->setup there should be a page "Sessions" When you edit that page, under Process there needs to be ProcessSessionDB set Same goes for Admin->Access->Sessions. If this is the case then you should be able to see the sessions when you go to either Setup->Sessions or Access->Sessions. The entries there have nothing to do with your session variables. If you don't have SessionHandlerDB module installed, they are stored in site/assets/sessions. Also there, your session variables will not be stored. No. The storage location of sessions (file system or DB) does not have anything to do with your script. See my answer in your other thread. On a side note, it would be better to keep this in one thread since it is the same underlying problem. Posting 4 different threads about 1 problem does not help and could be considered as spam. This tells me that something with your script might be wrong, not with how PW handles sessions. -
Emails in IDN format do not get saved, cannot be entered
gebeer replied to gebeer's topic in General Support
That is not true anymore since 3.0.208. Docs for https://processwire.com/api/ref/sanitizer/email/ options say: I have verified that sanitizer accepts with the allowIDN option set to 2. $sanitizer->email('hans.müller@müller.com', ['allowIDN' => 2]; But the occurences of $sanitizer->email() in InputfieldEmail.module and FieldtypeEmail.module need to be adjusted to allow saving of those values to the DB. We are working on an app for an international corporation and need to import around 15.000 email addresses, some of which have characters like ä, ø etc. Their mailservers support these, so we have to support them also. I'm totally not into reading RFCs, but doing some research I found that since RFC6532 (2012) internationalized email headers are a standard and even the local part of the email can be in UTF-8. For anyone who wants to dig deeper, here are some links to get you started: https://stackoverflow.com/questions/69855149/email-with-special-characters-rejected-rfc-6532-and-quoted-printable https://github.com/roundcube/roundcubemail/issues/5120 https://www.rfc-editor.org/rfc/rfc6532 -
Hi all, I'm on PW 3.0.209 and cannot save international Email strings (like "hans.müller@müller.com") to email fields through the GUI and also not through the API. Since 3.0.208 $sanitizer->email supports IDN with option "allowIDN". But the accepted values cannot be saved. As far as I can see from the code, this also applies to latest dev version. Can anyone confirm this behaviour? I opened an issue request with a proposed fix for the API side of things https://github.com/processwire/processwire-issues/issues/1680
-
I found the reason. It works if you only have 1 repeater matrix field. If you have multiple, you need to pass the field object as 2nd parameter: $field = $fields->get('content_product'); $repeaterMatrix = $modules->get('FieldtypeRepeaterMatrix'); $typeId = $repeaterMatrix->getMatrixTypeByName('teaser_gallery', $field); Same goes for $repeaterMatrix->getMatrixTypeLabel(string 'typename', Field $field)
-
Thanks for sharing. Your 2nd example can also be written like this $fieldName = 'content_product'; $typeName = 'product_downloads'; $pagesWithType = $pages->find("{$fieldName}.type={$typeName}"); db($pagesWithType); No need for looping through all pages. find() accepts the subselector .type. Only drawback with my solution: you don't get the label for the type. Actually when trying your example, $typeId returned false and $typeName returned null $repeaterMatrix = $modules->get('FieldtypeRepeaterMatrix'); $typeId = $repeaterMatrix->getMatrixTypeByName('product_downloads'); db($typeId, '$typeId'); // returns false $typeName = $repeaterMatrix->getMatrixTypeLabel($typeId); db($typeName, '$typeName'); // returns null Which version of Repeater Matrix are you using?
-
On Linux I'm using a combination of https://www.maartenbaert.be/simplescreenrecorder/ (available for most distros) https://www.openshot.org/ (also available for Windows/Mac) Have been looking for a all-in-one solution for a long time. https://obsproject.com/ is a complete solution but it is rather complex for the simple task of creating screencasts. SimpleScreenRecorder allows pause/resume and Openshot is a great easy to use tool for editing / adding captions etc.
-
Page Reference Field, custom selector string
gebeer replied to BrendonKoz's topic in General Support
Your problem might be related to Autocomplete and PageListSelect inputfields not allowing for custom selector strings. See Just a guess -
solved Need advice for more performant db query
gebeer replied to sz-ligatur's topic in General Support
Instead of the nested foreach you could do foreach ($tags as $tag) { $usage = $matches->find("tax_tag={$tag}")->count; $label = "{$tag->get('title')} {$usage}"; … } As for optimizing speed, how many pages are there potentially in $matches and in $tags, hundreds or thousands? To speed up queries, you can use $pages->findRaw() and only get the properties that you need for output and then work with those arrays in memory. Example: // find all pages with template document that have a tax_tag assigned // returns associative array indexed by page id with fields title, body and tax_tag where tax_tag is an associative array indexed by tax tag id with fields id and title // [ // 1234 => [ // 'title' => 'Page title', // 'body' => 'Page body content', // 'tax_tag' => [ // 4567 => [ // 'id' => 4567, // 'title' => 'Tax tag title', // ], // ... // ], // ], // ... // ] $matches = $pages->findRaw("template=document, tax_tag!=''", ['title', 'body', 'tax_tag' => ['id', 'title']]); Now you can use the resulting associative array $matches and do operations on it in memory without further DB calls. If you want to get a unique array of tags with usage count that are inside $matches, you could do something like this: // loop through matches to construct available tags array $tagsAvailable = array(); foreach($matches as $m) { // loop through tax_tags of each item foreach($m['tax_tag'] as $key => $tag) { // if key found in $tagsAvailable, tag is already there and we continue if(array_key_exists($key, $tagsAvailable)) continue; // get count of occurences of tax_tag id inside $matches items // and assign count as field 'usage' to the tag $tag['usage'] = count(array_filter(array_column($matches, 'tax_tag'), function($arr) use($key) { return in_array($key, array_keys($arr)); })); // add tag to available $tags $tagsAvailable[$key] = $tag; } } $tagsAvailable will look somewhat like this [ 1137 => [ 'id' => 1137, 'title' => 'Tag Title 1', 'usage' => 4, ], 1140 => [ 'id' => 1140, 'title' => 'Tag Title 2', 'usage' => 7, ], ] Now you can use $tagsAvailable to render your tags and $matches to render your result list. EDIT: I did this with $matches only containing 22 items and $tagsAvilable resulting in 5 items and the whole operation took 0.01ms and used 2.6kB of memory. So this should scale to hundreds or even thousands of matches. Though if you have that many matches you might consider chunk processing and paginating them.