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

Strange issue creating custom menu #3986

Closed
Serios opened this issue Oct 28, 2019 · 16 comments
Closed

Strange issue creating custom menu #3986

Serios opened this issue Oct 28, 2019 · 16 comments
Labels
core: pages/menus type: bug A problem that should not be happening
Milestone

Comments

@Serios
Copy link
Contributor

Serios commented Oct 28, 2019

Using latest v.2.2.1 I can't create custom menu to use in menu manager with my theme. Menu is actually created trough Custom pages/Menus but menu_name field is not saved to the DB even if I try to modify existing one the menu_name field gets blank and thus is not listed in Menu manager under custom menus. Menu is created with name, title, text and icon.

@Moc Moc added core: pages/menus status: testing required Someone needs to confirm this issue's existence and write a test to prevent the fix from regressing. labels Oct 28, 2019
@sudakk
Copy link
Contributor

sudakk commented Oct 28, 2019

I can 't repeat this problem. The menu is created and renamed without problems. And it's visible in the Menu Manager.

@Serios
Copy link
Contributor Author

Serios commented Oct 28, 2019

@sudakk on new install or on updated system?

@sudakk
Copy link
Contributor

sudakk commented Oct 28, 2019

@Serios on updated.

@Jimmi08
Copy link
Contributor

Jimmi08 commented Oct 28, 2019

@Serios 2.2.1 from e107.org? Check database validity and export one of the problematic records and put it here. If you use Chrome, use a different browser.
My guess is that you have already menu name with the same name or it saved your username as menu title if you are using Chrome.
2.2.1 doesn't have this problem, I would notice this, your data could be a problem.
If it is not problem, you can export your cpage table to xml (Database/tools) and put it here, I could try to import it to my 2.2.1 version.

@Serios
Copy link
Contributor Author

Serios commented Oct 28, 2019

@Jimmi08 @sudakk I managed to track the problem in relation with the php version of the server. On php ver 7.3 the problem exist. If php version is set to the minimum required 5.6 the problem no longer exist and menu_name is properly submitted to the DB. Confirmed it by trying both on my local server and on production server as well.

@Jimmi08 Can you test this for additional confirmation?

@Jimmi08
Copy link
Contributor

Jimmi08 commented Oct 28, 2019

@Serios try 7.2, e107 officially support only this version, I use only this one or 5.6. I will need to install xampp with 7.3. Yes, today I can :)

@Serios
Copy link
Contributor Author

Serios commented Oct 28, 2019

@Jimmi08 It's working properly on 7.2

You can setup your xampp to run different versions of php for different projects. If you are interested, you can check this guide

@Jimmi08
Copy link
Contributor

Jimmi08 commented Oct 28, 2019

Thanks, too complicated. I know better and easier way :) for somebody who is not server/administrator guy :)

@Jimmi08
Copy link
Contributor

Jimmi08 commented Oct 28, 2019

Confirmed only for Chrome
image

Firefox:

image

It's old not solved problem with prefilled fields in Chrome:
#3196
#3131

With php 7.3 it is worse, because you can't edit .

@Jimmi08
Copy link
Contributor

Jimmi08 commented Oct 28, 2019

Hm, now I can edit it in Chrome too. I couldn't before.
I have it.

  • click on Add new menu
  • start to write to Page title, then click to Menu tab, menu title is not editable

but

  • click on Add new menu
  • click directly on menu tab, menu is editable

Edit, No, I can't point where that field is editable and when not. But this happens.

@Jimmi08
Copy link
Contributor

Jimmi08 commented Oct 28, 2019

Next problem:
I am using only name, title and description.
first time record was saved (closed editing) without any error but record didn't exist.
second time this error appeared and only way how to save menu was adding sef-url to page.
image

Update to 2.2.2git didn't help

image

image

it is able to save empty name although menu name is a mandatory field.

@Jimmi08
Copy link
Contributor

Jimmi08 commented Oct 28, 2019

That SEF-URL error is because of this:
$newdata['page_sef'] = eHelper::title2sef($newdata['menu_name']);
$newdata['menu_name'] has value NULL, so it's not generated correctly.
So this is the result, not cause.

@Jimmi08
Copy link
Contributor

Jimmi08 commented Oct 28, 2019

NULL value for menu_name is caused by this line:

$newdata['menu_name'] = preg_replace('/[^\w-*]/','-',$newdata['menu_name']);

before this, it has the correct value.

@Jimmi08
Copy link
Contributor

Jimmi08 commented Oct 28, 2019

This is fix (2 places):
$newdata['menu_name'] = preg_replace('/[^\w\-*]/','-',$newdata['menu_name']);

For php 7.3. hyphen has to be escaped.

"It is advised to check all the regex you are using in your applications and test them with PHP 7.3."

@sudakk
Copy link
Contributor

sudakk commented Oct 28, 2019

The ability to save a menu\page with an empty both fields menu_name & page_title occurs because there is no check in function beforeUpdate (in cpage.php) as when creating a menu\page in function beforeCreate. If you add this code, you will receive an error when you try to save an empty both fields menu_name & page_title:

function beforeUpdate($newdata,$olddata, $id)
{

	if(isset($newdata['page_title']) && isset($newdata['menu_name']) && empty($newdata['page_title']) && empty($newdata['menu_name']))
	{
		e107::getMessage()->addError(CUSLAN_79);
		return false;
	}
	$newdata = e107::getCustomFields()->processDataPost('page_fields',$newdata);

	if(isset($newdata['menu_name']))
	{
		$newdata['menu_name'] = preg_replace('/[^\w\-*]/','',$newdata['menu_name']);
	}
	return $newdata;	
}

@sudakk
Copy link
Contributor

sudakk commented Oct 28, 2019

@Jimmi08 post updated according to your note.

@Moc Moc added type: bug A problem that should not be happening and removed status: testing required Someone needs to confirm this issue's existence and write a test to prevent the fix from regressing. labels Nov 26, 2019
@Moc Moc added this to the e107 2.3.0 milestone Nov 26, 2019
@Moc Moc closed this as completed Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core: pages/menus type: bug A problem that should not be happening
Projects
None yet
Development

No branches or pull requests

4 participants