Jump to content

gebeer

Members
  • Posts

    1,514
  • Joined

  • Last visited

  • Days Won

    45

Everything posted by gebeer

  1. Time to revive this 8 year old thread ? I'm using vscodium as editor and recently for code formatting I moved from the excellent https://intelephense.com/ extension to an extension that uses https://github.com/PHP-CS-Fixer/PHP-CS-Fixer which is based on https://github.com/squizlabs/PHP_CodeSniffer. This allows custom style definitions (rulesets) https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file PW coding style guide says: Has anybody ever gone through the trouble of creating a custom PW ruleset.xml? Just asking before I start spending my time on that. Other CMSs/Frameworks do have their ruleset files. See https://github.com/WordPress/WordPress-Coding-Standards https://www.drupal.org/docs/contributed-modules/code-review-module/installing-coder-sniffer https://github.com/fossbarrow/laravel-phpcs Would be great if we had one for ProcessWire, too. Maybe @ryan already uses one and can share it? If not, we could start a community effort to produce such ruleset. It would help tremendously for PRs to the PW core or for module development.
  2. Just installed Tabnine and went on coding as usual on PW projects. It seems that it is not aware of all the PW specific classes, methods, API variables etc. Or do you experience differently? Maybe it takes some time until it picks up PW specific stuff. It surely was not trained on PW core code because the PW licensing model is not permissive by Tabnine's definition since it uses MPL 2.0 alongside MIT and others. Maybe GHs Copilot has an advantage there?
  3. I've been working further on the module concept and found a (mostly reliable) way to react on all error types in PW. Just wanted to share my findings before a release. Looking through PW core, I found that nowhere PW registers custom error or exception handlers. So I decided to use set_error_handler() for warnings/notices and set_exception_handler() for exceptions. To also cover fatal errors, I hook into WireShutdown::fatalError instead of registering my own shutdown function. Gladly Ryan provides that hook ? So the basis for my operations looks like this in the module's init(): $this->originalErrorHandler = set_error_handler(array($this, 'errorHandler'), E_NOTICE|E_USER_NOTICE|E_WARNING|E_USER_WARNING); $this->originalExceptionHandler = set_exception_handler(array($this, 'exceptionHandler')); $this->wire->addHookAfter('WireShutdown::fatalError', $this, 'fatalHandler'); Note, how I save the original error and exception handlers, so I can set them back once I've finished my operations so that my module doesn't interfere with other modules that use their own handlers (like TracyDebugger). For now I'm only doing the send email based on error type part. The https://rollbar.com/ part will most likely go into a separate module. I still need to test some on a production site until there will be an alpha/beta release. Related question: does anybody know how to deliberately cause an E_NOTICE error, other than using trigger_error('My error', E_USER_NOTICE) in PHP > 8? I couldn't find or think of a real world example. Before PHP 8 we could use "echo $undeclaredVariable". But since 8 those notices are converted to warnings.
  4. @kongondo Where are messages from MM actions like uploads etc are supposed to appear in the GUI? I mean messages that are generated during executeAjax(). I can see them as JSON response in the dev tools for requests to e.g. /processwire/media-manager/ajax/ like { "files": [ { "name": "csm_us_ziehmvisionrfdhybridedition-usa-forweb_1080x1080px_7c9dea3ab6.jpg", "size": 34682 } ], "count_total": 1, "count_success": 1, "count_fail": 0, "message": "error", "notice": "Media Manager: No valid media found to add to Media Library. If replacing media, check that they are not locked.", "nothingAddedYet": "Nothing added yet.", "action": "upload", "currentPageID": 0, "mediaManagerFieldID": 0, "insertAndClose": 0, "galleryID": "", "notice2": "Media Manager: Some media were not added because names already in use (csm_us_ziehmvisionrfdhybridedition-usa-forweb_1080x1080px_7c9dea3ab6.jpg)." } But there is no message output in the GUI after upload. In this case a duplicate image was ignored for upload. Are these JSON responses supposed to be shown as messages in the GUI? If not, it would be awesome if they could be shown to the user.
  5. Just to recap in case anyone else experienced this: After MM install I ended up with pages with wrong names (media-manager--audio, --document, --image, --video) under Admin->Media Manager. As a consequence all created media pages got saved under parent Admin->Media Manager->Media Manager:Audio. This also had an impact on duplicate media pages. They could not be detected. So no matter what the settings for duplicate media, all media got uploaded even if it was duplicates. I used this code to rename pages under Admin->Media Manager to have correct names like (media-manager-audio, -document, -image, -video) and move all media pages to live under their correct parent pages: // FIX wrong Media Manager page names under Admin -> Media Manager and sort media pages under correct parent $types = ['audio', 'document', 'image', 'video']; // fix page names from "media-manager--$type" to "media-manager-$type" foreach($types as $type) { $pID = $this->wire->pages->getId("parent.name=media-manager, name=media-manager--{$type}"); if($pID) { $this->wire->pages->get($pID)->setAndSave('name', "media-manager-{$type}"); } } // move media pages from wrong parent media-manager-audio to correct parent "media-manager-$type" foreach($types as $type) { // get all media pages under media-manager-audio parent $ids = $this->wire->pages->findIDs("parent.name=media-manager-audio, media_manager_{$type}!="); // put them under correct parent if(count($ids)) { $parentID = $this->wire->pages->getID("parent.name=media-manager, name=media-manager-{$type}"); if($parentID) { foreach($ids as $id) { $p = $this->wire->pages->get($id); $p->setAndSave('parent', $parentID); } } } }
  6. You can make URLs to PDFs look nicer Further up in that thread, you can see how you can implement output.
  7. I moved from Joomla/Seblod to ProcessWire about 10 years ago. It was the best decision I ever made in my developer life. Happy coding with PW :-)
  8. Installation went smoothly with 3.1.0. Thank you!
  9. Hi @bernhardjust installed a brandnew PW with https://github.com/processwire/site-regular/blob/main/README.md site profile on a local ddev with PHP 8.1. First thing I wanted to install was RockMigrations. After going to Modules->Site->Add New and pasting in the class name and clicking on Get Module Info, I got an exception: DEBUG MODE BACKTRACE ($config->debug == true): #0 /var/www/html/wire/core/Modules.php(688): ProcessWire\ProcessPageEditImageSelect->init() #1 /var/www/html/wire/core/Modules.php(1455): ProcessWire\Modules->initModule(Object(ProcessWire\ProcessPageEditImageSelect), Array) #2 /var/www/html/wire/core/Modules.php(1262): ProcessWire\Modules->getModule('ProcessPageEdit...') #3 /var/www/html/wire/core/Modules.php(1712): ProcessWire\Modules->get('ProcessPageEdit...') #4 /var/www/html/wire/core/WireArray.php(1789): ProcessWire\Modules->find('alsosetincompos...') #5 /var/www/html/wire/core/WireArray.php(583): ProcessWire\WireArray->findOne('alsosetincompos...') #6 /var/www/html/wire/core/Modules.php(1913): ProcessWire\WireArray->get('alsosetincompos...') #7 /var/www/html/wire/modules/Process/ProcessModule/ProcessModule.module(1166): ProcessWire\Modules->isInstalled('alsosetincompos...') #8 /var/www/html/wire/core/Wire.php(419): ProcessWire\ProcessModule->___buildDownloadConfirmForm(Array, false) #9 /var/www/html/wire/core/WireHooks.php(952): ProcessWire\Wire->_callMethod('___buildDownloa...', Array) #10 /var/www/html/wire/core/Wire.php(484): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessModule), 'buildDownloadCo...', Array) #11 /var/www/html/wire/modules/Process/ProcessModule/ProcessModule.module(1080): ProcessWire\Wire->__call('buildDownloadCo...', Array) #12 /var/www/html/wire/modules/Process/ProcessModule/ProcessModule.module(340): ProcessWire\ProcessModule->downloadConfirm('RockMigrations') #13 /var/www/html/wire/core/Wire.php(413): ProcessWire\ProcessModule->___execute() #14 /var/www/html/wire/core/WireHooks.php(952): ProcessWire\Wire->_callMethod('___execute', Array) #15 /var/www/html/wire/core/Wire.php(484): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessModule), 'execute', Array) #16 /var/www/html/wire/core/ProcessController.php(350): ProcessWire\Wire->__call('execute', Array) #17 /var/www/html/wire/core/Wire.php(413): ProcessWire\ProcessController->___execute() #18 /var/www/html/wire/core/WireHooks.php(952): ProcessWire\Wire->_callMethod('___execute', Array) #19 /var/www/html/wire/core/Wire.php(484): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessController), 'execute', Array) #20 /var/www/html/wire/core/admin.php(160): ProcessWire\Wire->__call('execute', Array) #21 /var/www/html/site/templates/admin.php(16): require('/var/www/html/w...') #22 /var/www/html/wire/core/TemplateFile.php(328): require('/var/www/html/s...') #23 /var/www/html/wire/core/Wire.php(413): ProcessWire\TemplateFile->___render() #24 /var/www/html/wire/core/WireHooks.php(952): ProcessWire\Wire->_callMethod('___render', Array) #25 /var/www/html/wire/core/Wire.php(484): ProcessWire\WireHooks->runHooks(Object(ProcessWire\TemplateFile), 'render', Array) #26 /var/www/html/wire/modules/PageRender.module(575): ProcessWire\Wire->__call('render', Array) #27 /var/www/html/wire/core/Wire.php(416): ProcessWire\PageRender->___renderPage(Object(ProcessWire\HookEvent)) #28 /var/www/html/wire/core/WireHooks.php(952): ProcessWire\Wire->_callMethod('___renderPage', Array) #29 /var/www/html/wire/core/Wire.php(484): ProcessWire\WireHooks->runHooks(Object(ProcessWire\PageRender), 'renderPage', Array) #30 /var/www/html/wire/core/WireHooks.php(1060): ProcessWire\Wire->__call('renderPage', Array) #31 /var/www/html/wire/core/Wire.php(484): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Page), 'render', Array) #32 /var/www/html/wire/modules/Process/ProcessPageView.module(184): ProcessWire\Wire->__call('render', Array) #33 /var/www/html/wire/modules/Process/ProcessPageView.module(114): ProcessWire\ProcessPageView->renderPage(Object(ProcessWire\Page), Object(ProcessWire\PagesRequest)) #34 /var/www/html/wire/core/Wire.php(416): ProcessWire\ProcessPageView->___execute(true) #35 /var/www/html/wire/core/WireHooks.php(952): ProcessWire\Wire->_callMethod('___execute', Array) #36 /var/www/html/wire/core/Wire.php(484): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessPageView), 'execute', Array) #37 /var/www/html/index.php(55): ProcessWire\Wire->__call('execute', Array) #38 {main} Other module installs I tested (ProcessWireUpgrade, ProcessDatabaseBackups), went fine. Don't know if this is related to the site profile or your module. Just wanted to let you know.
  10. Rollbar can be initiated without setting it's own error handler. https://docs.rollbar.com/docs/basic-php-installation-setup But thanks for your concern.
  11. 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.
  12. 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.
  13. @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.
  14. 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.
  15. 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?
  16. This might be helpful: https://korepov.pro/infobase/vs-code/23 Haven't tried it myself but looks promising.
  17. 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%
  18. Thanks for the input! File-Cache you mean then? Because https://processwire.com/api/ref/wire-cache/ is DB driven, I think.
  19. 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 ?
  20. 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.
  21. 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.
  22. 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.
  23. I don't think a PHP update can have an impact on folder permissions. More likely this is an Apache and/or PHP-FPM missconfiguration issue. File/Folder permissions are documented here https://processwire.com/docs/security/file-permissions/
  24. 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
  25. 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
×
×
  • Create New...