diff --git a/administrator/language/en-GB/en-GB.lib_joomla.ini b/administrator/language/en-GB/en-GB.lib_joomla.ini index 5301ad0994980..26c9fa6a27fd0 100644 --- a/administrator/language/en-GB/en-GB.lib_joomla.ini +++ b/administrator/language/en-GB/en-GB.lib_joomla.ini @@ -143,6 +143,7 @@ JLIB_DATABASE_ERROR_ADAPTER_MYSQLI="The MySQL adapter 'mysqli' is not available. JLIB_DATABASE_ERROR_BIND_FAILED_INVALID_SOURCE_ARGUMENT="%s: :bind failed. Invalid source argument." JLIB_DATABASE_ERROR_ARTICLE_UNIQUE_ALIAS="Another article from this category has the same alias (remember it may be a trashed item)." JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS="Another category with the same parent category has the same alias (remember it may be a trashed item)." +JLIB_DATABASE_ERROR_ALIAS_STARTS_WITH_A_NUMBER="The alias needs to start with a letter, but it starts with a digit." JLIB_DATABASE_ERROR_CHECK_FAILED="%s: :check Failed - %s" JLIB_DATABASE_ERROR_CHECKIN_FAILED="%s: :check-in failed - %s" JLIB_DATABASE_ERROR_CHECKOUT_FAILED="%s: :check-out failed - %s" diff --git a/libraries/legacy/table/category.php b/libraries/legacy/table/category.php index dfb761ef886d1..ffa8b891cb2e0 100644 --- a/libraries/legacy/table/category.php +++ b/libraries/legacy/table/category.php @@ -152,7 +152,7 @@ public function check() if (trim(str_replace('-', '', $this->alias)) == '') { - $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s'); + $this->alias = 'a' . JFactory::getDate()->format('Y-m-d-H-i-s'); } return true; @@ -235,6 +235,14 @@ public function store($updateNulls = false) return false; } + // Verify if the alias starts with a number + if (preg_match('/^\d/', $this->alias) === 1 && $this->modified_time === $this->created_time) + { + $this->setError(JText::_('JLIB_DATABASE_ERROR_ALIAS_STARTS_WITH_A_NUMBER')); + + return false; + } + return parent::store($updateNulls); } }