Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2] SEF: Enforce suffix #42850

Merged
merged 14 commits into from
Aug 15, 2024
Merged

[5.2] SEF: Enforce suffix #42850

merged 14 commits into from
Aug 15, 2024

Conversation

Hackwar
Copy link
Member

@Hackwar Hackwar commented Feb 21, 2024

Pull Request for Issue #15025 .

Summary of Changes

Joomla has been improving its SEO performance constantly and one issue which is still open is the behavior of the suffix. Right now, you can access a URL in Joomla with or without suffix when the option is enabled in the global configuration. This PR introduces a new setting the SEF system plugin which enforces a consistent suffix behavior.

When SEF URLs are enabled, the suffix is enabled and this option is enabled, Joomla will always redirect GET requests to a URL with a suffix if none is present. It will also redirect URLs with a query format parameter to the nicer URL and replace the "nice" suffix with the format parameter if the two collide.

With Joomla 6.0 the option to switch this on/off should be removed again and this should be the default behavior, which would then be added to SiteRouter::parseFormat(). Right now this is YASO (Yet Another Stupid Option) to allow people to test this in live systems and to switch it off if we encounter unforseen issues. The time from 5.1 to 6.0 could be seen as a grace period.

This PR depends on #42692.

I'd like to thank djumla GmbH for sponsoring this feature.

Testing Instructions

  1. Make sure that you have PR [5.1] Implement onAfterInitialiseRouter event #42692 in your test installation
  2. Apply the patch
  3. Enable SEF URLs and the "Add Suffix to URL" options in global configuration
  4. Go to "System - SEF" plugin and enable the option to "Enforce Suffix"
  5. Open a URL in the frontend and see that URLs ending in a / don't have a suffix, everything else has a suffix.
  6. Take a URL with a suffix and remove the suffix. See that Joomla redirects back to a URL with .html.
  7. Take a URL with a suffix and add ?format=feed to it, for example for a category blog view. See that you get the feed output with the right URL.

Link to documentations

Please select:

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-5.1-dev labels Feb 21, 2024
@Hackwar Hackwar added Feature PBF Pizza, Bugs and Fun and removed Language Change This is for Translators PR-5.1-dev labels Feb 21, 2024
@brianteeman
Copy link
Contributor

This looks like it addresses a 7 year old bug #15025

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-5.1-dev labels Feb 21, 2024
@ceford
Copy link
Contributor

ceford commented Feb 23, 2024

I have tested this item ✅ successfully on 784cfda


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42850.

2 similar comments
@nielsnuebel
Copy link
Contributor

I have tested this item ✅ successfully on 784cfda


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42850.

@viocassel
Copy link
Contributor

I have tested this item ✅ successfully on 784cfda


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42850.

@richard67 richard67 removed Language Change This is for Translators PR-5.1-dev labels Feb 24, 2024
@richard67
Copy link
Member

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42850.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Feb 24, 2024
@richard67 richard67 added Language Change This is for Translators PR-5.1-dev labels Feb 24, 2024
@brianteeman
Copy link
Contributor

In favour of the bug fix. Not in favour of the option. As such this should be in 4.4 as a bug fix and not as a new feature in a future release

@Hackwar
Copy link
Member Author

Hackwar commented Feb 24, 2024

Link to documentation has been added.

@Hackwar
Copy link
Member Author

Hackwar commented Feb 24, 2024

This is a change in behavior and not just a bugfix. That's why we wont get around this option. For Joomla 6.0 this option will be removed again and the behavior added to the normal behavior of the Add Suffix to URL option. So as long as we will stick to semantic versioning we will have to add this as an option.

@Nuyonuyonoina
Copy link

Failed. Too bad, because it's a strong request from a client of mine and for that reason SEO agency it's working with ask to migrate to another CMS...

@Hackwar
Copy link
Member Author

Hackwar commented Feb 24, 2024

@Nuyonuyonoina could you comment what is failing on your end? Otherwise I can't fix that and this PR wont be merged.

@webfeuerflo
Copy link

failed. followed the instructions, but if I remove .html from the URL it does not get added back

@webfeuerflo
Copy link

I have tested this item 🔴 unsuccessfully on 784cfda

failed. followed the instructions, but if I remove .html from the URL it does not get added back


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42850.

@webfeuerflo
Copy link

Tested on PHP 8.1.27, 10.4.32-MariaDB, Joomla! 5.1.0-alpha4 Alpha [ Kudumisha ] 20-February-2024 16:31 GMT


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42850.

@joomla-cms-bot joomla-cms-bot added the Language Change This is for Translators label Mar 23, 2024
@Hackwar
Copy link
Member Author

Hackwar commented Jun 1, 2024

Thank you, @SniperSister, I fixed that. @ceford, @nielsnuebel, @viocassel and of course anybody else who is intersted, would you be so kind to test this again, so that we can merge this for 5.2?

@ceford
Copy link
Contributor

ceford commented Jun 2, 2024

I have tested this item ✅ successfully on 5900b39

I see #42692 has been merged. I am using a cms clone - so I did a git pull them npm ci, applied the patch and I get this:

An error has occurred.

0 Call to undefined method Joomla\Plugin\System\Sef\Extension\Sef::setSiteRouter() 

I needed to disable the sef plugin in the database to get admin working again.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42850.

@ceford
Copy link
Contributor

ceford commented Jun 2, 2024

I have tested this item 🔴 unsuccessfully on 5900b39

I see #42692 has been merged. I am using a cms clone - so I did a git pull them npm ci, applied the patch and I get this:

An error has occurred.

0 Call to undefined method Joomla\Plugin\System\Sef\Extension\Sef::setSiteRouter() 

I needed to disable the sef plugin in the database to get admin working again.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42850.

@Hackwar
Copy link
Member Author

Hackwar commented Jun 2, 2024

@ceford The comment about #42692 actually isn't true anymore and that PR actually has been reverted before the release of 5.1. Since this PR also doesn't touch that code, your git clone most likely is very outdated and should be updated to latest 5.2-dev before testing this.

@ceford
Copy link
Contributor

ceford commented Jun 3, 2024

My clone is up to date. I checked out 5.2-dev - title bar shows ‎5.2.0-alpha1-dev

The SEF plugin is enabled. I apply the patch and then all menu items in the back end give:

     0 Call to undefined method Joomla\Plugin\System\Sef\Extension\Sef::setSiteRouter() 

Call Stack
# 	Function 	Location
1 	() 	JROOT/plugins/system/sef/services/provider.php:42
2 	Joomla\DI\ServiceProviderInterface@anonymous/Users/ceford/Sites/joomla-cms5/plugins/system/sef/services/provider.php:22$97->{closure}() 	JROOT/libraries/vendor/joomla/di/src/ContainerResource.php:172
3 	Joomla\DI\ContainerResource->getInstance() 	JROOT/libraries/vendor/joomla/di/src/Container.php:95
4 	Joomla\DI\Container->get() 	JROOT/libraries/src/Extension/ExtensionManagerTrait.php:177
5 	Joomla\CMS\Application\CMSApplication->loadExtension() 	JROOT/libraries/src/Extension/ExtensionManagerTrait.php:99
6 	Joomla\CMS\Application\CMSApplication->bootPlugin() 	JROOT/libraries/src/Plugin/PluginHelper.php:232
7 	Joomla\CMS\Plugin\PluginHelper::import() 	JROOT/libraries/src/Plugin/PluginHelper.php:192
8 	Joomla\CMS\Plugin\PluginHelper::importPlugin() 	JROOT/libraries/src/Application/CMSApplication.php:765 

So I have to disable the plugin so I can revert the patch. It may be my installation that is the problem but I don't know what to do about it.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42850.

@SniperSister
Copy link
Contributor

I have tested this item ✅ successfully on ef8201e


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42850.

1 similar comment
@webnet-assmann
Copy link

I have tested this item ✅ successfully on ef8201e


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42850.

@Hackwar Hackwar added the RTC This Pull Request is Ready To Commit label Jul 23, 2024
@robbiejackson
Copy link

I have tested this item ✅ successfully on ef8201e

I tested this by just patching the changed files into my 5.1 instance.

I confirmed that with the global config set then the html prefix is restored after you remove it manually.

I also confirmed that an xml feed document was returned correctly whenever a prefix of .feed or a query parameter of format=feed was set in the URL.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42850.

@bembelimen
Copy link
Contributor

@ceford could you please check if the problem still exists?

@pe7er pe7er self-assigned this Aug 15, 2024
@pe7er pe7er enabled auto-merge (squash) August 15, 2024 20:05
@pe7er pe7er merged commit 5909f54 into joomla:5.2-dev Aug 15, 2024
3 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Aug 15, 2024
@Hackwar Hackwar added this to the Joomla! 5.2.0 milestone Aug 15, 2024
@pe7er
Copy link
Contributor

pe7er commented Aug 16, 2024

Thanks @Hackwar !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Language Change This is for Translators PBF Pizza, Bugs and Fun PR-5.2-dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.