We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 813 ☆ A M B ☆
    • 326 Posts
    Very strange problem that I've never had before...

    I have a custom plugin that triggers on the OnPageNotFound event...or at least it's supposed to. It was working fine a few days ago, and now it just suddenly is not executing at all. I've stripped it down to the point of only having the following in my plugin code:

    die('test');


    Some things I've tried or checked:


    • The plugin is enabled (checked the plugin setting and also the column in the actual database)
    • OnPageNotFound event is checked
    • Cleared the cache, flushed permissions and sessions
    • Disabled all other plugins
    • Tried outputting to the error log -- got nothing

    I'm perplexed. This is 2.2.4-pl(advanced). It's a multi-context site that uses a first-subdirectory plugin (courtesy of Jason Coward) to handle routing, but disabling this routing had no impact on the problem, so I don't think it's related. Any ideas? [ed. note: aladage last edited this post 14 years, 1 month ago.]
      • 11055 ☆ A M B ☆
      • 3,112 Posts
      it'd be much better if you show part of your plugin code.
        Rico
        Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
        MODx is great, but knowing how to use it well makes it perfect!

        www.virtudraft.com

        Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

        Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

        Maintainter/contributor of Babel

        Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
        • 813 ☆ A M B ☆
        • 326 Posts
        I would, but that's what I'm saying -- there's literally nothing else in the plugin code but an opening PHP tag and die('test'); On the system events tab, OnPageNotFound is checked. There's nothing in the error logs, even if I try to write to it (like it's not triggering at all). It's like it's being ignored completely, regardless of what I do. Have you ever heard of it doing that before?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Just tried it, and indeed I do get a page with nothing on it but "test". Although if it turns out to be some kind of context issue, that's another matter.

            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 3749
            • 24,544 Posts
            Is it possible that your host is catching page not found and redirecting to their own 404 page before your code can execute?


            ------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using.
            MODX info for everyone: http://bobsguides.com/modx.html
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 813 ☆ A M B ☆
              • 326 Posts
              Bob: I'm not sure how to tell for sure, but maybe. I just noticed it's also not respecting the error_page system or context setting. Does that help troubleshoot what could be going on? I've got some crazy context stuff going on, so it could be related to that, too.
                • 39932
                • 483 Posts
                Ah ha! I've been waiting for a tricky Plugin question. Unfortunately I've already experienced this issue.

                Check all of your Plugins with OnPageNotFound. Make sure each has a unique priority. And make sure they are consecutive from 0. If there are gaps, sometimes MODx won't fire the later ones. If they share a priority, which one MODx calls is based on which is loaded first (which is not entirely deterministic).

                Plugins to watch out for: ArchivistFurl and ArticlesPlugin often come with the same priority. If you make a custom Plugin or install others like a mobile redirector or custom aliasing, most often they are not placed in the correct run order.
                  Website: Extended Dialog Development Blog: on Extended Dialog
                  Add-ons: AJAX Revolution, RO.IDEs Editor & Framework (in works) Utilities: Plugin Compatibility List
                  Tutorials: Create Cross-Context Resources, Cross-Context AJAX Login, Template-Based Actions, Remove Extensions from URLs

                  Failure is just another word for saying you didn't want to try. "It can't be done" means "I don't know how".
                  • 813 ☆ A M B ☆
                  • 326 Posts
                  That's a really really good suggestion and I'll try to remember this in the future, but unfortunately, I checked and it's the only OnPageNotFound plugin I have. Maybe this still is your chance at a tricky Plugin question!

                  Honestly, I have a feeling I'm doing some silly, but I can not figure it out for the life of me. My guess is an issue with a rather complex contexts setup, but I still can't pinpoint it.
                    • 3749
                    • 24,544 Posts
                    If you have Articles installed, Fuzzicallogic probably hit the nail on the head. The Articles plugin responds to the OnPageNotFound event and calls its own router.



                    ------------------------------------------------------------------------------------------
                    PLEASE, PLEASE specify the version of MODX you are using.
                    MODX info for everyone: http://bobsguides.com/modx.html
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 813 ☆ A M B ☆
                      • 326 Posts
                      Nope, no Articles here. Just complex context routing that I'd be glad to go into, if anyone can help with that area.