Skip to content

Commit

Permalink
If TV identifier is numeric, assume it is a mis-cast ID (and not the …
Browse files Browse the repository at this point in the history
…name of a TV)
  • Loading branch information
pbowyer committed Mar 3, 2017
1 parent 97c7d26 commit d9ffca5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/model/modx/modresource.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -823,10 +823,8 @@ public function hasChildren() {
* TV is not found.
*/
public function getTVValue($pk) {
$byName = false;
if (is_string($pk)) {
$byName = true;
}
$byName = (is_numeric($pk)) ? false : true;

/** @var modTemplateVar $tv */
if ($byName && $this->xpdo instanceof modX) {
$tv = $this->xpdo->getParser()->getElement('modTemplateVar', $pk);
Expand All @@ -845,7 +843,9 @@ public function getTVValue($pk) {
*/
public function setTVValue($pk,$value) {
$success = false;
if (is_string($pk)) {
if (is_numeric($pk)) {
$pk = intval($pk);
} elseif (is_string($pk)) {
$pk = array('name' => $pk);
}
/** @var modTemplateVar $tv */
Expand Down

0 comments on commit d9ffca5

Please sign in to comment.