PacktPublishing / Developing-Extensions-for-Joomla-5

Developing Extensions for Joomla! 5, published by Packt
MIT License
7 stars 4 forks source link

Notice msg breaks each Project link (in the Router) #1

Closed garstud closed 2 months ago

garstud commented 11 months ago

Hello @carcam , Thank you for your awesome work on this book.

When trying to execute com_spm with the Router, i found a "Notice" (in local dev) on the Router link of a project.

How to reproduce

  1. configure your web site to display error (even Notices)
  2. get the chapter 3 codes and build the package of com_spm.
  3. install it
  4. add a new menu item to the projects list
  5. go on the frontend and click on the menu link
  6. the link of each project may be broken and have the following html code :

<a href="/<br /> <b>Notice</b>: Undefined variable: id in <b>C:\laragon\www\joomla42\components\com_spm\src\Service\Router.php</b> on line <b>38</b><br /> <br /> <b>Notice</b>: Undefined variable: id in <b>C:\laragon\www\joomla42\components\com_spm\src\Service\Router.php</b> on line <b>38</b><br /> /index.php/spm-projects/sit-quod">sit quod</a>

Solution

In the /src/Service/Router.php in line 38 : Replace: $id = (int) $id; with: $key = (int) $key;

carcam commented 10 months ago

Hi @garstud , Thank you very much for your report!! It looks as I forgot something in the code. Let me check it and I will come back with a fix.

Happy new year!!

carcam commented 2 months ago

Hi @garstud , I have noticed I didn't reply to this.

I have just pushed a fix for this at: https://github.com/PacktPublishing/Developing-Extensions-for-Joomla-5/commit/3c5c88dce49a03cead1576a5e1a4c58f5b97d5c9

Thanks!!