Move the assignment of modules from #__module_menu to the new menu_assignment in #__modules. Now the menu assignment section for a module will have 2 new options for exlude child pages. For joomla updates there wil not be any visual change, since all assigned modules in #__module_menu will be copy to menu_assignment.
Testing Instructions
Preparation steps
This pull request make some changes in the database, you will need to update an existing joomla site with the prebuilt package. The faster way, just copy the sentences and execute it directly in your sql client (just do not forget to adjust the prefix #_). Minimum you need execute the follow:
Apply the patch if you did not used the prebuilt package update
Administrator -> Site Modules
The column "Pages", need have the exact same values you have before. If you only executed the minimum sql sentence, then will show for all modules "None" and that is expected.
Filter by some Menu Item
Order by pages in asc/desc
Create/Delete a module
Batch a module. In both case (move/copy) check the assigned menu items stay in their position.
Administrator -> Site Modules -> Edit a module
Go to the tab Menu Assignment and choose a module assigment option. Save and check these options remain as you edited.
Save and close. Repeat Administrator -> Site Modules test
Administrator -> Menus -> Edit a menu item
Go to the tab Module Assignment and check the Display column show the correct tag about what module is assignment or not to the menu.
Turn on/off the Unassigned Modules toggle and check the module hide or shown according with yoru selection.
Delete a menu item (make sure first is assigned to a module). Open the module and check the menu assignment is working. If you ca also in the #__modules table, search the menu_assignment value for this module and check the menu item id you just deleted, do not show up inside the assigned menu item array.
Frontend
Check if the current modules you have are working as before.
Edit a module and set as menu assignment one of the two new values, On all pages except those selected (do not include child pages) or Only on the pages selected (do not include child pages) . One way to test it, first assign a menu item to a parent category. Create a new category as child of this one. Then create a article inside this child category. Go to the frontend and check the module show up inside the parent category view, but not in the child category view or the article view.
Actual result BEFORE applying this Pull Request
All work as expected
Expected result AFTER applying this Pull Request
All work as expected. But now you can choose that do not render a module in child pages.
This is a b/c break and can not be merged into 5.x. you will have to rebase this to 6.0. regardless of that, I don't think this is a good idea. Your check if you are on the page you want to be is extremely sketchy and will not work for a very large number of websites. Just checking on view and id is nowhere near reliable. Besides that, it is an anti-pattern to store this in a JSON. It prevents us from doing joins on the data.
@carlitorweb If you want to add a new column to the modules table you also have to modify the CREATE TABLE statements in the base.sql files for new installations here https://github.com/joomla/joomla-cms/blob/5.2-dev/installation/sql/mysql/base.sql#L587 amd here https://github.com/joomla/joomla-cms/blob/5.2-dev/installation/sql/postgresql/base.sql#L611 . Please do it like it is for other columns of type
text
in the particular file. It does not need to specifyNULL DEFAULT NULL
for them.