Jump to content

Recommended Posts

Progress Update:

I'd like to drop debug mode in favor of a testing tab that I'm quite sure has been brought up before. The idea is to not have to throw your entire site in to JL debug mode just to test one thing in production. I've added this tab now, seems to work well.

image.thumb.png.3454a92c3710f8ffbe27017e615e742c.png

  • Like 2

Share this post


Link to post
Share on other sites

Hi @Mike Rockett - just had a: PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'referrer' at row 1 #22001 in /var/www/html/site/assets/cache/FileCompiler/site/modules/ProcessJumplinks/ProcessJumplinks.module.php:534

because someone was trying to hack in with this link:

/plus/download.php?open=1&arrs1[]=99&arrs1[]=102&arrs1[]=103&arrs1[]=95&arrs1[]=100&arrs1[]=98&arrs1[]=112&arrs1[]=114&arrs1[]=101&arrs1[]=102&arrs1[]=105&arrs1[]=120&arrs2[]=109&arrs2[]=121&arrs2[]=116&arrs2[]=97&arrs2[]=103&arrs2[]=96&arrs2[]=32&arrs2[]=40&arrs2[]=97&arrs2[]=105&arrs2[]=100&arrs2[]=44&arrs2[]=101&arrs2[]=120&arrs2[]=112&arrs2[]=98&arrs2[]=111&arrs2[]=100&arrs2[]=121&arrs2[]=44&arrs2[]=110&arrs2[]=111&arrs2[]=114&arrs2[]=109&arrs2[]=98&arrs2[]=111&arrs2[]=100&arrs2[]=121&arrs2[]=41&arrs2[]=32&arrs2[]=86&arrs2[]=65&arrs2[]=76&arrs2[]=85&arrs2[]=69&arrs2[]=83&arrs2[]=40&arrs2[]=57&arrs2[]=48&arrs2[]=49&arrs2[]=51&arrs2[]=44&arrs2[]=64&arrs2[]=96&arrs2[]=92&arrs2[]=39&arrs2[]=96&arrs2[]=44&arrs2[]=39&arrs2[]=123&arrs2[]=100&arrs2[]=101&arrs2[]=100&arrs2[]=101&arrs2[]=58&arrs2[]=112&arrs2[]=104&arrs2[]=112&arrs2[]=125&arrs2[]=102&arrs2[]=105&arrs2[]=108&arrs2[]=101&arrs2[]=95&arrs2[]=112&arrs2[]=117&arrs2[]=116&arrs2[]=95&arrs2[]=99&arrs2[]=111&arrs2[]=110&arrs2[]=116&arrs2[]=101&arrs2[]=110&arrs2[]=116&arrs2[]=115&arrs2[]=40&arrs2[]=39&arrs2[]=39&arrs2[]=57&arrs2[]=48&arrs2[]=115&arrs2[]=101&arrs2[]=99&arrs2[]=46&arrs2[]=112&arrs2[]=104&arrs2[]=112&arrs2[]=39&arrs2[]=39&arrs2[]=44&arrs2[]=39&arrs2[]=39&arrs2[]=60&arrs2[]=63&arrs2[]=112&arrs2[]=104&arrs2[]=112&arrs2[]=32&arrs2[]=101&arrs2[]=118&arrs2[]=97&arrs2[]=108&arrs2[]=40&arrs2[]=36&arrs2[]=95&arrs2[]=80&arrs2[]=79&arrs2[]=83&arrs2[]=84&arrs2[]=91&arrs2[]=103&arrs2[]=117&arrs2[]=105&arrs2[]=103&arrs2[]=101&arrs2[]=93&arrs2[]=41&arrs2[]=59&arrs2[]=63&arrs2[]=62&arrs2[]=39&arrs2[]=39&arrs2[]=41&arrs2[]=59&arrs2[]=123&arrs2[]=47&arrs2[]=100&arrs2[]=101&arrs2[]=100&arrs2[]=101&arrs2[]=58&arrs2[]=112&arrs2[]=104&arrs2[]=112&arrs2[]=125&arrs2[]=39&arrs2[]=41&arrs2[]=32&arrs2[]=35&arrs2[]=32&arrs2[]=64&arrs2[]=96&arrs2[]=92&arrs2[]=39&arrs2[]=96

I'm not sure the best approach to preventing this exception - not sure if you should change the field type for the referrer column to support larger entries, or if you should just truncate the referrer if it's longer than allowed.

Share this post


Link to post
Share on other sites
3 hours ago, adrian said:

I'm not sure the best approach to preventing this exception - not sure if you should change the field type for the referrer column to support larger entries, or if you should just truncate the referrer if it's longer than allowed.

Collecting super long referrer values seems pointless (they're likely spam anyway), so truncating seems like a good approach. And the same applies to UA string as well 🙂

--

Edit: just checked a few log files, and I've got similar errors there... and some of these:

Exception: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'user_agent' at row 1 (in /site/modules/ProcessJumplinks/ProcessJumplinks.module.php line 534)

 

  • Like 1

Share this post


Link to post
Share on other sites
On 1/28/2016 at 8:40 PM, ceberlin said:
  • If I use the 404 monitor to fix a link the link should be removed from the 404 monitor so I do not fix it twice

@Mike Rockett has this been addressed yet? I have a customer complaining about this. Would be really nice if those 404 entries got removed. Any plans on implementing this? And thousand thanks for this great module!

Share this post


Link to post
Share on other sites

@gebeer – Thanks 🙂 This hasn't been addressed in v1, as the plan was to carry the behaviour into v2 (sorry it's taken so long…) by way of the separate module. I picked up the project again recently and was giving it some thought. I might just include the 404 logger in JL v2, but am still 50/50 on it.

@teppo @adrian – You know, I should have truncated that alongside truncation of the request_uri. Going to see if I can squeeze this in over the weekend while I work on v2’s frontend.

  • Like 3

Share this post


Link to post
Share on other sites
On 9/11/2020 at 6:14 AM, Mike Rockett said:

Thanks 🙂 This hasn't been addressed in v1, as the plan was to carry the behaviour into v2 (sorry it's taken so long…) by way of the separate module. I picked up the project again recently and was giving it some thought. I might just include the 404 logger in JL v2, but am still 50/50 on it.

Thanks for clarifying. Which hook would you use to trigger deletion of logger entries, ___executeEntity or ___executeCommit?

Share this post


Link to post
Share on other sites

@gebeer It'll likely be executeCommit as executeEntity returns the view. However, the 'routes' will be split out in v2 (namely, executeStore, executeUpdate, executeDisable, executeEnable, the first two of which will probably be used to trigger a cleanup).

  • Like 1

Share this post


Link to post
Share on other sites

If you are using v1 of this module and you want to auto-remove entries from the 404 monitor when you create a jumplink from an entry there, you can use this simple hook in site/templates/admin.php

$this->addHookBefore('ProcessJumplinks::executeCommit', function(Hookevent $event){
    $input = $this->input->post;
    $sourcePath = $input->sourcePath;

    if($sourcePath) {
        $statement = "DELETE FROM process_jumplinks_nf WHERE request_uri = :sourcePath";
        try {
            $this->database->prepare($statement)->execute([
                'sourcePath' => $sourcePath
            ]);
            $this->message("Eintrag '$sourcePath' wurde aus 404 Monitor Liste entfernt");
        } catch (\Throwable $th) {
            $this->error("Fehler beim Entfernen des Eintrags '$sourcePath' aus der 404- Monitor Liste: " . $th->getMessage());
        }
    }
});

and adapt the messages to your liking :-)

Share this post


Link to post
Share on other sites
On 5/15/2020 at 7:33 PM, Mike Rockett said:

@a-ok Jumplinks 1 doesn't have built in support for automatically dealing with query strings. This is planned for Jumplinks 2, but I simply haven't had the time to complete it. For the time being, I'd be inclined to use the {all} wildcard on the end.

Source: chance-to-dance[/]{all}
Destination: somewhere/{all} or {!all} to skip wildcard cleaning

Hey @Mike Rockett, and sorry to bother you with this again, but just wanted to run something by you.

I've tried the solution above, but at least in my case it doesn't seem to be quite that simple. For some background, in this case the source path is "tilaukset" (orders in Finnish), and it should always link to a specific target URL. This works fine as-is, but when it's shared on Facebook, following the link from there results in 404 due to added query string.

Going step by step:

  1. If I append [/] to the end, it works with or without slash at the end — so far so good.
  2. If I also append {all} or {!all}, the redirect only seems to work if there's content there, i.e. plain "tilaukset" or "tilaukset/" no longer work.

I'm not sure if this is intentional or not, but I guess the question is if there's a way to specify that "I don't care what comes after this, it could contain nothing or it could contain content, either way ignore it"? 😄

I'm using <tilaukset|tilaukset?{all}> for now, but that seems pretty complicated when what I really want is (in terms of regex) "tilaukset.*" (or alternatively "tilaukset/?.*"). This also keeps the query string intact; I'd prefer it to be dropped, but that's not by any means a major issue.

Am I missing something?

Share this post


Link to post
Share on other sites

FWIW, we needed to preserve query string parameters (mostly UTM params for campaign tracking) with a lot of permutations, and after trying a few different things, we ended up adding this bit to init.php. It seems to be working well for our particular use case.

	// Hook the 404 routine to catch valid URLs with UTM params.
	$this->addHookBefore('ProcessPageView::pageNotFound', function($event){	
		// Get the originally requested URL and its query string.
		// $_SERVER['QUERY_STRING'] is not reliable in this environment.
		$source_url = parse_url($_SERVER['REQUEST_URI']);
		$source_path = $source_url['path'];
		$source_querystring = $source_url['query'];	
		
		// Do nothing if there is no query string. Jumplinks can manage that.
		if(!isset($source_querystring)) return;

		// See if we have a jumplinks entry for the source path WITHOUT the query string.
		$db = wire('database');
		$source_string = trim($source_path, '/');
		$sql = "SELECT source, destination FROM process_jumplinks WHERE source = '".$source_string."/?'";
		$result = $db->query($sql);
		$match = $result->fetch(\PDO::FETCH_ASSOC);
		
		// If any matches are found, try redirecting to it, appending the original query string.
		$target = $match['destination'];
			
		if($target != ''){
			// is this a path or a page ID?
			if((strpos($target, 'page:') !== false)){
				$id = (int) ltrim($target, 'page:');
				$page = wire('pages')->get($id);
				$target_url = $page->url.'?'.$source_querystring;
			}else{
				$target_url = '/'.str_replace('{!all}','',$target);
				$target_url .= '?'.$source_querystring;
			}

			// wire('log')->save('querystrings', 'Source: '.$source_path.', Target: '.$target_url);		
			wire('session')->redirect($target_url);
		}
	});

Maybe others will find it helpful.

 

  • Like 2

Share this post


Link to post
Share on other sites

@teppo @Jason Huck – In JL1, this unfortunately requires two jumplinks – one for including the query string, and the other for excluding it. I know, it really sucks, but JL2 solves this problem by using optional parameters and a little bit of internal trickery. I do still need to add in a boolean flag on jumplinks to indicate whether or not they should even care about the query string. I would prefer to not implement this flag, but sometimes it's useful when you don't care about it so much that you'd rather not even make mention of it in the source.

  • Like 1

Share this post


Link to post
Share on other sites

Hi Folks
I wonder if I could strip with Jumplinks from certain URL's like
https://www.site.com/de/produkte/kuehlgeraete-fuer-schaltschraenke/kg_4304/43042001/#prodDescription
just the last part #prodDescription. Could also be a general thing, that whenever this #prodDescription appears, it would be removed.
The client uses those links into a tab on an other System, which means there would several hundert links to be changed.

Your help is much appreciated!

Share this post


Link to post
Share on other sites

 

2 minutes ago, bbeer said:

I wonder if I could strip with Jumplinks from certain URL's like
https://www.site.com/de/produkte/kuehlgeraete-fuer-schaltschraenke/kg_4304/43042001/#prodDescription
just the last part #prodDescription.

I'm pretty sure those anchor hashes never reach the server and are evaluated by the browser only.

Share this post


Link to post
Share on other sites

sorry you're right they got to the browser as %23prodDescription. So we would need to strip %23prodDescription this.

Share this post


Link to post
Share on other sites
1 minute ago, bbeer said:

sorry you're right they got to the browser as %23prodDescription. So we would need to strip %23prodDescription this.

I think what I meant to say was that the hash (#prodDescription) is never sent to the server. ProcessWore doesn't know about it. Any redirects that are dependent on the presence or absence of a hash need to be done in JavaScript on the client.

Share this post


Link to post
Share on other sites

when you call the page with those # it opens the correct page. The Problem is, that they copied all those links with the # and use them in the CRM. So when they generate Quotes the link to this pages form a generated PDF Quote. Therefor it would be helpful if we could remove this particular part %23prodDescription of the url, then the Link would work perfectly. Else you just get an 404.

Share this post


Link to post
Share on other sites

@bbeer – if you are getting URLs with the encoded %23, then I think that htaccess would be your best bet until JL2 is ready (working on it as I write this). It must be that the CRM is encoding the hash when storing the URL (bad move, CRM), which the browser then sends to the server, which sees it as part of the actual URI. The browser will never send it if it is not encoded. 

If htaccess is too messy, then you could perhaps append the source with {all}, which would catch everything after the last 'segment' – the destination could then just ignore this. Not the best solution I know, but seems like it could work for the time being…

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By d'Hinnisdaël
      Format Datetime fields as Carbon instances.
      You can find the latest release and the complete readme on Github.
      Installation
      composer require daun/datetime-carbon-format Usage
      All Datetime fields will now be formatted as Carbon instances instead of strings. Some examples:
      // $page->date is a Datetime field // Output format: j/n/Y echo $page->date; // 20/10/2020 echo $page->date->add('7 days'); // 27/10/2020 echo $page->date->format('l, F j'); // Monday, October 20 echo $page->date->year; // 2020 echo $page->date->diffForHumans(); // 28 minutes ago Frontend only
      The ProcessWire admin seems to expect datetime fields to be strings. This module will only return Carbon instances on frontend page views.
      Date output format
      When casting a Carbon instance to a string (usually when outputting the field in a template), the field's date output format will be respected.
      Links
      GitHub • Readme • Carbon docs
       
       
      PS. I remember reading about a Carbon module in a recent newsletter, but couldn't find it anywhere. Was that you, @bernhard?
    • By MoritzLost
      TrelloWire
      This is a module that allows you to automatically create Trello cards for ProcessWire pages and update them when the pages are updated. This allows you to setup connected workflows. Card properties and change handling behaviour can be customized through the extensive module configuration. Every action the module performs is hookable, so you can modify when and how cards are created as much as you need to. The module also contains an API-component that makes it easy to make requests to the Trello API and build your own connected ProcessWire-Trello workflows.
      Warning: This module requires ProcessWire 3.0.167 which is above the current stable master release at the moment.
      Features
      All the things the module can do for you without any custom code: Create a new card on Trello whenever a page is added or published (you can select applicable templates). Configure the target board, target list, name and description for new cards. Add default labels and checklists to the card. Update the card whenever the page is updated (optional). When the status of the card changes (published / unpublished, hidden / unhidden, trashed / restored or deleted), move the card to a different list or archive or delete it (configurable). You can extend this through hooks in many ways: Modifiy when and how cards are created. Modify the card properties (Target board & list, title, description, et c.) before they are sent to Trello. Create your own workflows by utilizing an API helper class with many convenient utility methods to access the Trello API directly. Feedback & Future Plans
      Let me know what you think! In particular:
      If you find any bugs report them here or on Github, I'll try to fix them. This module was born out of a use-case for a client project where we manage new form submissions through Trello. I'm not sure how many use-cases there are for this module. If you do use it, tell me about it! The Trello API is pretty extensive, I'll try to add some more helper methods to the TrelloWireApi class (let me know if you need anything in particular). I'll think about how the module can support different workflows that include Twig – talk to me if you have a use-case! Next steps could be a dashboard to manage pages that are connected to a Trello card, or a new section in the settings tab to manage the Trello connection. But it depends on whether there is any interest in this 🙂 Links
      Repository on Github Complete module documentation (getting started, configuration & API documentation) TrelloWire in the modules directory Module configuration

    • By David Karich
      ProcessWire InputfieldRepeaterMatrixDuplicate
      Thanks to the great ProModule "RepeaterMatrix" I have the possibility to create complex repeater items. With it I have created a quite powerful page builder. Many different content modules, with many more possible design options. The RepeaterMatrix module supports the cloning of items, but only within the same page. Now I often have the case that very design-intensive pages and items are created. If you want to use a content module on a different page (e.g. in the same design), you have to rebuild each item manually every time.
      This module extends the commercial ProModule "RepeaterMatrix" by the function to duplicate repeater items from one page to another page. The condition is that the target field is the same matrix field from which the item is duplicated. This module is currently understood as proof of concept. There are a few limitations that need to be considered. The intention of the module is that this functionality is integrated into the core of RepeaterMatrix and does not require an extra module.
      Check out the screencast
      What the module can do
      Duplicate multible repeater items from one page to another No matter how complex the item is Full support for file and image fields Multilingual support Support of Min and Max settings Live synchronization of clipboard between multiple browser tabs. Copy an item and simply switch the browser tab to the target page and you will immediately see the past button Support of multiple RepeaterMatrix fields on one page Configurable which roles and fields are excluded Configurable dialogs for copy and paste Duplicated items are automatically pasted to the end of the target field and set to hidden status so that changes are not directly published Automatic clipboard update when other items are picked Automatically removes old clipboard data if it is not pasted within 6 hours Delete clipboard itself by clicking the selected item again Benefit: unbelievably fast workflow and content replication What the module can't do
      Before an item can be duplicated in its current version, the source page must be saved. This means that if you make changes to an item and copy this, the old saved state will be duplicated Dynamic loading is currently not possible. Means no AJAX. When pasting, the target page is saved completely No support for nested repeater items. Currently only first level items can be duplicated. Means a repeater field in a repeater field cannot be duplicated. Workaround: simply duplicate the parent item Dynamic reloading and adding of repeater items cannot be registered. Several interfaces and events from the core are missing. The initialization occurs only once after the page load event Attention, please note!
      Nested repeaters cannot be supported technically. Therefore a check is made to prevent this. However, a nested repeater can only be detected if the field name ends for example with "_repeater1234". For example, if your MatrixRepeater field is named like this: "content_repeater" or "content_repeater123", this field is identified as nested and the module does not load. In version 2.0.1 the identification has been changed so that a field ending with the name repeater is only detected as nested if at least a two-digit number sequence follows. But to avoid this problem completely, make sure that your repeater matrix field does NOT end with the name "repeater".
      Changelog
       
      2.0.1
      Bug fix: Thanks to @ngrmm I could discover a bug which causes that the module cannot be loaded if the MatrixRepeater field ends with the name "repeater". The code was adjusted and information about the problem was provided 2.0.0
      Feature: Copy multiple items at once! The fundament for copying multiple items was created by @Autofahrn - THX! Feature: Optionally you can disable the copy and/or paste dialog Bug fix: A fix suggestion when additional and normal repeater fields are present was contributed by @joshua - THX! 1.0.4
      Bug fix: Various bug fixes and improvements in live synchronization Bug fix: Items are no longer inserted when the normal save button is clicked. Only when the past button is explicitly clicked Feature: Support of multiple repeater fields in one page Feature: Support of repeater Min/Max settings Feature: Configurable roles and fields Enhancement: Improved clipboard management Enhancement: Documentation improvement Enhancement: Corrected few typos #1 1.0.3
      Feature: Live synchronization Enhancement: Load the module only in the backend Enhancement: Documentation improvement 1.0.2
      Bug fix: Various bug fixes and improvements in JS functions Enhancement: Documentation improvement Enhancement: Corrected few typos 1.0.1
      Bug fix: Various bug fixes and improvements in the duplication process 1.0.0
      Initial release Support this module
      If this module is useful for you, I am very thankful for your small donation: Donate 5,- Euro (via PayPal – or an amount of your choice. Thank you!)
      Download this module (Version 2.0.1)
      > Github: https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDuplicate
      > PW module directory: https://modules.processwire.com/modules/inputfield-repeater-matrix-duplicate/
      > Old stable version (1.0.4): https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDuplicate/releases/tag/1.0.4
    • By picarica
      so i am trying to put CustomHooksForVariations.module, a custom module, i am placing it into site/modules direcotry yet my modules page in admin panel gives me errors
      so this is the screen show when i refresh modules, i dont know why the shole hook is written on top of the page :||

      and this next image is when i try to install it, i saw that it is not defiuned modules.php but it shouldnt need to be ?, any ways i dont want to edit site's core just to make one moulde work there has to be a way

    • By Robin S
      A new module that hasn't had a lot of testing yet. Please do your own testing before deploying on any production website.
      Custom Paths
      Allows any page to have a custom path/URL.
      Note: Custom Paths is incompatible with the core LanguageSupportPageNames module. I have no experience working with LanguageSupportPageNames or multi-language sites in general so I'm not in a position to work out if a fix is possible. If anyone with multi-language experience can contribute a fix it would be much appreciated!
      Screenshot

      Usage
      The module creates a field named custom_path on install. Add the custom_path field to the template of any page you want to set a custom path for. Whatever path is entered into this field determines the path and URL of the page ($page->path and $page->url). Page numbers and URL segments are supported if these are enabled for the template, and previous custom paths are managed by PagePathHistory if that module is installed.
      The custom_path field appears on the Settings tab in Page Edit by default but there is an option in the module configuration to disable this if you want to position the field among the other template fields.
      If the custom_path field is populated for a page it should be a path that is relative to the site root and that starts with a forward slash. The module prevents the same custom path being set for more than one page.
      The custom_path value takes precedence over any ProcessWire path. You can even override the Home page by setting a custom path of "/" for a page.
      It is highly recommended to set access controls on the custom_path field so that only privileged roles can edit it: superuser-only is recommended.
      It is up to the user to set and maintain suitable custom paths for any pages where the module is in use. Make sure your custom paths are compatible with ProcessWire's $config and .htaccess settings, and if you are basing the custom path on the names of parent pages you will probably want to have a strategy for updating custom paths if parent pages are renamed or moved.
      Example hooks to Pages::saveReady
      You might want to use a Pages::saveReady hook to automatically set the custom path for some pages. Below are a couple of examples.
      1. In this example the start of the custom path is fixed but the end of the path will update dynamically according to the name of the page:
      $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'my_template') { $page->custom_path = "/some-custom/path-segments/$page->name/"; } }); 2. The Custom Paths module adds a new Page::realPath method/property that can be used to get the "real" ProcessWire path to a page that might have a custom path set. In this example the custom path for news items is derived from the real ProcessWire path but a parent named "news-items" is removed:
      $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'news_item') { $page->custom_path = str_replace('/news-items/', '/', $page->realPath); } }); Caveats
      The custom paths will be used automatically for links created in CKEditor fields, but if you have the "link abstraction" option enabled for CKEditor fields (Details > Markup/HTML (Content Type) > HTML Options) then you will see notices from MarkupQA warning you that it is unable to resolve the links.
      Installation
      Install the Custom Paths module.
      Uninstallation
      The custom_path field is not automatically deleted when the module is uninstalled. You can delete it manually if the field is no longer needed.
       
      https://github.com/Toutouwai/CustomPaths
      https://modules.processwire.com/modules/custom-paths/
×
×
  • Create New...