modxcms / revolution

MODX Revolution - Content Management Framework
https://modx.com/
GNU General Public License v2.0
1.36k stars 528 forks source link

Bug with getting information about the context #15653

Open Semdevmaster opened 3 years ago

Semdevmaster commented 3 years ago

Bug report

Summary

In templates or snippets $modx->context->key;//works fine $modx->context->rank;//works fine $modx->context->name;//does not work (always empty string) $modx->context->description;//does not work (always empty string)

Step to reproduce

create a snippet that returns data from the current context

Observed behavior

in all templates and snippets when requesting current context data, only key and rank available Name and description are always empty, although filled in the admin panel But $res = $modx->getObject('modContext',['key'=>'web']); print_r($res->toArray()); Array ( [key] => web [name] => Москва [description] => Москва [rank] => 0 ) Works fine

Expected behavior

$modx->context->name;//should output the data from admin panel $modx->context->description;//should output the data from admin panel

Related issue(s)/PR(s)

Environment

MODX 2.8.1

opengeek commented 3 years ago

The name and description of the context have never been part of the data stored in the context cache which is used to load a context when initialized. This may seem like a bug as you might expect that data to be available in the templates/snippets, but it is a feature request.

JoshuaLuckers commented 3 years ago

If I'm not mistake the rank property isn't part of the data that's stored in the cache either. In the reporters example $modx->context->rank returns 0 because it's the default value for the property.