? ? ? Pending

User tests: Successful: Unsuccessful:

avatar infograf768
infograf768
9 Aug 2019

Pull Request for Issue #17708

Summary of Changes

as title says

Testing Instructions

Create a new menu item of type "Create Article"
In the Options tab, set Default Category to Yes
Do NOT select a category in the field below which only displays by a showon.
Save menu item.

Before patch

The menu item is saved. No error is set.
Category id was wrongly set to 1, which wrong behaviour is now corrected in frontend, among other issues with permissions, with #17674

After patch

Preventing saving and displaying an error message

Screen Shot 2019-08-09 at 09 50 28

@alikon @LivioCavallo

avatar infograf768 infograf768 - open - 9 Aug 2019
avatar infograf768 infograf768 - change - 9 Aug 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 9 Aug 2019
Category Administration com_menus Language & Strings
avatar infograf768 infograf768 - change - 9 Aug 2019
The description was changed
avatar infograf768 infograf768 - edited - 9 Aug 2019
avatar infograf768 infograf768 - change - 9 Aug 2019
Labels Added: ? ?
avatar brianteeman
brianteeman - comment - 9 Aug 2019
  1. I'm assuming that the obvious option of making the field required is not used for a valid reason

  2. COM_CONTENT_CREATE_ARTICLE_ERROR="When default category is enabled, a category should be selected."
    As its an error message not a help doc this can be rewritten to something like
    COM_CONTENT_CREATE_ARTICLE_ERROR="A default category is required."

avatar infograf768
infograf768 - comment - 9 Aug 2019

I'm assuming that the obvious option of making the field required is not used for a valid reason

It's impossible as the field should be ignored when Default category is set to no and we do not have a specific "requiredon" (on the model of "showon" code).

COM_CONTENT_CREATE_ARTICLE_ERROR="When default category is enabled, a category should be selected."
As its an error message not a help doc this can be rewritten to something like
COM_CONTENT_CREATE_ARTICLE_ERROR="A default category is required."

Why not give this detail? It does not cost much and help user solve the issue. grrr

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 9 Aug 2019

I have tested this item successfully on 0a9638a


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

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 9 Aug 2019

I have tested this item successfully on 0a9638a


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

avatar franz-wohlkoenig franz-wohlkoenig - test_item - 9 Aug 2019 - Tested successfully
avatar richard67
richard67 - comment - 9 Aug 2019

I have tested this item successfully on 261fdbe


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

avatar richard67 richard67 - test_item - 9 Aug 2019 - Tested successfully
avatar richard67
richard67 - comment - 9 Aug 2019

@franz-wohlkoenig Last change after your test was just a language change, so you can just set your test result again without retest, just review last change, and then RTC 😄

avatar infograf768
infograf768 - comment - 9 Aug 2019

Don't worry about appveyor btw.

avatar richard67
richard67 - comment - 9 Aug 2019

I know.

avatar franz-wohlkoenig franz-wohlkoenig - change - 9 Aug 2019
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 9 Aug 2019

Status "Ready To Commit".

avatar infograf768 infograf768 - change - 11 Aug 2019
Labels Added: ?
avatar HLeithner
HLeithner - comment - 23 Aug 2019

Sorry to say but this solution is really hacky in my opinion that should be done in a plugin for example content->joomla in the on_before_save event.

avatar infograf768
infograf768 - comment - 24 Aug 2019

@HLeithner
I would not know how to do what you suggest.

avatar richard67
richard67 - comment - 24 Aug 2019

@HLeithner I would also not know. I have an idea what you mean but I'm not good enough in event based stff to do it either. And it has 2 good tests, one from me. And I would not call it "hacky", only maybe "old style but working". So for me it's pretty fine.

P.S.: And it fixes an issue.

avatar HLeithner
HLeithner - comment - 26 Aug 2019

@richard67 writing a hardcoded string into com_menu because a specific other component needs it is wrong. It's possible that we don't have another way but if we have the choice we should use it.

Please but this in to plg_content_joomla + the language string.

	/**
	 * The save event.
	 *
	 * @param   string   $context  The context
	 * @param   object   $table    The item
	 * @param   boolean  $isNew    Is new item
	 * @param   array    $data     The validated data
	 *
	 * @return  void
	 *
	 * @since   __DEPLOY_VERSION__
	 */
	public function onContentBeforeSave($context, $table, $isNew, $data)
	{
		// Check we are handling the frontend edit form.
		if ($context !== 'com_menus.item')
		{
			return true;
		}

		// Special case for Create article menu item
		if ($table->link !== 'index.php?option=com_content&view=form&layout=edit')
		{
			return true;
		}

		// Display error if catid is not set when enable_category is enabled
		$params = json_decode($table->params, true);

		if ($params['enable_category'] == 1 && empty($params['catid']))
		{
			$table->setError(JText::_('PLG_CONTENT_JOOMLA_CREATE_ARTICLE_WITH_EMPTY_CATEGORY_ERROR'));
			return false;
		}
	}
avatar richard67
richard67 - comment - 26 Aug 2019

@HLeithner Is not my PR, is @infograf768

avatar infograf768
infograf768 - comment - 26 Aug 2019

will test. No idea what happens btw in general when that plugin is disabled.

avatar joomla-cms-bot joomla-cms-bot - change - 26 Aug 2019
Category Administration com_menus Language & Strings Administration Language & Strings Front End Plugins
avatar infograf768
infograf768 - comment - 26 Aug 2019

@richard67 @HLeithner
used plugin instead. Please test.
(The lang string has to remain in com_content.ini as that plugin is not loading its lang files in the page concerned.)

avatar richard67 richard67 - test_item - 26 Aug 2019 - Tested successfully
avatar richard67
richard67 - comment - 26 Aug 2019

I have tested this item successfully on b04c352


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

avatar richard67
richard67 - comment - 26 Aug 2019

@franz-wohlkoenig Could you test again?

avatar franz-wohlkoenig franz-wohlkoenig - test_item - 26 Aug 2019 - Tested successfully
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Aug 2019

I have tested this item successfully on b04c352


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

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Aug 2019

I have tested this item successfully on b04c352


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

avatar HLeithner
HLeithner - comment - 27 Aug 2019

Thanks for catching this error.

avatar HLeithner HLeithner - change - 27 Aug 2019
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2019-08-27 11:24:13
Closed_By HLeithner
avatar HLeithner HLeithner - close - 27 Aug 2019
avatar HLeithner HLeithner - merge - 27 Aug 2019

Add a Comment

Login with GitHub to post a comment