Skip to content

Commit addc8db

Browse files
author
DenysTsymbal
committed
8738-blog-urls-with-capital=letters-move-check-to-php
1 parent acb330f commit addc8db

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

Model/ResourceModel/Category.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ protected function _getLoadByIdentifierSelect($identifier, $storeIds)
188188
'cp.category_id = cps.category_id',
189189
[]
190190
)->where(
191-
'cp.identifier COLLATE utf8_bin = ?',
191+
'cp.identifier = ?',
192192
$identifier
193193
)->where(
194194
'cps.store_id IN (?)',
@@ -226,7 +226,7 @@ protected function isValidPageIdentifier(\Magento\Framework\Model\AbstractModel
226226
*
227227
* @param string $identifier
228228
* @param int|array $storeId
229-
* @return int
229+
* @return false|string
230230
*/
231231
public function checkIdentifier($identifier, $storeIds)
232232
{
@@ -235,9 +235,15 @@ public function checkIdentifier($identifier, $storeIds)
235235
}
236236
$storeIds[] = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
237237
$select = $this->_getLoadByIdentifierSelect($identifier, $storeIds);
238-
$select->reset(\Zend_Db_Select::COLUMNS)->columns('cp.category_id')->order('cps.store_id DESC')->limit(1);
238+
$select->reset(\Zend_Db_Select::COLUMNS)->columns(['cp.category_id', 'cp.identifier'])->order('cps.store_id DESC')->limit(1);
239+
240+
$row = $this->getConnection()->fetchRow($select);
241+
if (isset($row['category_id']) && isset($row['identifier'])
242+
&& $row['identifier'] == $identifier) {
243+
return (string)$row['category_id'];
244+
}
239245

240-
return $this->getConnection()->fetchOne($select);
246+
return false;
241247
}
242248

243249
/**

Model/ResourceModel/Post.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ protected function _getLoadByIdentifierSelect($identifier, $storeIds)
340340
'cp.post_id = cps.post_id',
341341
[]
342342
)->where(
343-
'cp.identifier COLLATE utf8_bin = ?',
343+
'cp.identifier = ?',
344344
$identifier
345345
)->where(
346346
'cps.store_id IN (?)',
@@ -378,7 +378,7 @@ protected function isValidPageIdentifier(\Magento\Framework\Model\AbstractModel
378378
*
379379
* @param string $identifier
380380
* @param int|array $storeId
381-
* @return int
381+
* @return false|string
382382
*/
383383
public function checkIdentifier($identifier, $storeIds)
384384
{
@@ -387,9 +387,15 @@ public function checkIdentifier($identifier, $storeIds)
387387
}
388388
$storeIds[] = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
389389
$select = $this->_getLoadByIdentifierSelect($identifier, $storeIds);
390-
$select->reset(\Zend_Db_Select::COLUMNS)->columns('cp.post_id')->order('cps.store_id DESC')->limit(1);
390+
$select->reset(\Zend_Db_Select::COLUMNS)->columns(['cp.post_id', 'cp.identifier'])->order('cps.store_id DESC')->limit(1);
391+
392+
$row = $this->getConnection()->fetchRow($select);
393+
if (isset($row['post_id']) && isset($row['identifier'])
394+
&& $row['identifier'] == $identifier) {
395+
return (string)$row['post_id'];
396+
}
391397

392-
return $this->getConnection()->fetchOne($select);
398+
return false;
393399
}
394400

395401
/**

Model/Tag.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ public function getOwnTitle($plural = false)
134134
*/
135135
public function checkIdentifier($identifier)
136136
{
137-
return $this->load($identifier)->getId();
137+
$tag = $this->load($identifier);
138+
if ($tag->getIdentifier() == $identifier) {
139+
return $tag->getId();
140+
}
141+
142+
return null;
138143
}
139144

140145
/**

0 commit comments

Comments
 (0)