Disable Magic URL Shortening or Edit Parameters

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
EVO_VV
Registered User
Posts: 55
Joined: Tue Feb 13, 2018 3:11 pm

Disable Magic URL Shortening or Edit Parameters

Post by EVO_VV »

Just updated a site from 3.1.8 to 3.2.1
All the links in the posts are shortened which I do not want although I do want them to be automatically 'Clickable'

Searching around I found in includes/functions_content :-

Code: Select all

$short_url = (utf8_strlen($url) > 55) ? utf8_substr($url, 0, 39) . ' ... ' . utf8_substr($url, -10) : $url;
And this is exactly what the shortening is doing.
However if I edit that to :-

Code: Select all

$short_url = (utf8_strlen($url) > 200) ? utf8_substr($url, 0, 100) . ' ... ' . utf8_substr($url, -10) : $url;
Or :-

Code: Select all

$short_url = $url;
And then after clearing the cache both in phpBB and my Browser there is no change whatsoever.

Is this not the correct place to adjust these settings or am I missing something else that I ought to be doing ?
Last edited by EVO_VV on Wed Feb 14, 2018 5:48 am, edited 1 time in total.
User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Re: Disable Magic URL Shortening or Edit Parameters

Post by A_Jelly_Doughnut »

First, the fragment of code you're referencing is in functions_content.php. Threw me a curveball trying to find that :-)

Changing the code in that location will only affect posts written after the change.
I believe that you can make this change, then run the reparse posts tool that is available in phpBB's Command line interface to update older posts: viewtopic.php?p=14929036#p14929036 (may also be available from the web, not sure)
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish
EVO_VV
Registered User
Posts: 55
Joined: Tue Feb 13, 2018 3:11 pm

Re: Disable Magic URL Shortening or Edit Parameters

Post by EVO_VV »

Sorry about the file name mistake, corrected now.

I did try, after the edit, to post a URL but exactly the same shortened URL was displayed.
The complete URL is stored in the database so I'm not sure that a re-parse will have any effect.
I was under the impression that the re-parsing done by that CLI function was only done when you updated the database on installation to change the storage format from HTML to XML.
Of course I could be wrong about that but it does seem that the URL is only shortened for display and must be controlled somewhere.
User avatar
AmigoJack
Registered User
Posts: 5773
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Disable Magic URL Shortening or Edit Parameters

Post by AmigoJack »

That's because s9e interferes - you also have to edit public function truncate_text(\s9e\TextFormatter\Parser\Tag $tag) in /phpbb/textformatter/s9e/link_helper.php. Your previous edits affect non-post texts, such as in reports.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.
User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 4559
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Disable Magic URL Shortening or Edit Parameters

Post by kasimi »

EVO_VV
Registered User
Posts: 55
Joined: Tue Feb 13, 2018 3:11 pm

Re: Disable Magic URL Shortening or Edit Parameters

Post by EVO_VV »

Many thanks for your help gentlemen.
However, it does only affect new posts as far as I can see.
This would indicate that something in the older posts need 'editing' to make it have an effect there as well.
I assume that this was set when the database was 'Updated' during the installation process and therefore that I either need to try the Extension method quoted by JoshyPHP in the link you referred to or I need to run the database Update again on the 'posts' using the CLI.
Unfortunately the link to the that Extension no longer works so it looks like I have to try the CLI method.

I know I have to use the .cli in the install folder but how do I tell it to only do the posts text ?
Also as the upgrade was very recent, how can I tell if the 'in the background' updating has completed ?
I don't think it would be a good idea to try and have them both working at the same time as the potential consequences would be disastrous.
User avatar
kinerity
Community Team Member
Community Team Member
Posts: 2820
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Disable Magic URL Shortening or Edit Parameters

Post by kinerity »

EVO_VV wrote:
Wed Feb 14, 2018 3:38 pm
Unfortunately the link to the that Extension no longer works.
It was removed because I submitted it to the Customisation Database for validation. If you want the extension, you can download it here.
Kailey Truscott - Community Team
GitHub repositories (including un-released extensions)
EVO_VV
Registered User
Posts: 55
Joined: Tue Feb 13, 2018 3:11 pm

Re: Disable Magic URL Shortening or Edit Parameters

Post by EVO_VV »

Thank you for that Kailey.
I'll give it a try if I have problems getting the edits to the code working.
Seems strange to me that while it is possible to alter the truncation parameters they do not have an immediate effect for all posts.
The parameters set in those code snippets must be stored somewhere for the Text Formatter to use every time you go to a page.
Would be nice to find that.
I do feel that the ability to configure this display setting should be under the control of the Forum Admin.
EVO_VV
Registered User
Posts: 55
Joined: Tue Feb 13, 2018 3:11 pm

Re: Disable Magic URL Shortening or Edit Parameters

Post by EVO_VV »

Found the CLI command, was actually in another post referred to above which I missed.

Code: Select all

php bin/phpbbcli.php reparser:reparse --safe-mode post_text
However I still need to know how to tell if the 'In the Background' updating of the database from the upgrade has completed so as not to inadvertently cause any conflict problems.
Post Reply

Return to “phpBB Custom Coding”