getrecords() docblock says one thing, function does something else

4 posts by 2 authors in: Forums > CMS Builder
Last Post: Yesterday at 9:00pm   (RSS)

Good catch, Jeff!

You're absolutely right that the docblock shows two return values while the function returns three.

The third value (schema) is intentionally undocumented as it's an internal feature we use within CMS Builder, but one we don't officially promote as part of the public API. It contains the same data you'd get from calling loadSchema('tableName') directly.

For the typical use case, the first two return values ($records and $details) provide everything needed for building viewers. The schema is returned primarily for internal functions and advanced customization scenarios. If you have a specific need for it, you're welcome to use it, just be aware that undocumented features aren't officially supported and could theoretically change without notice in future versions.

That said, this particular return structure has been stable for over 10 years, so it's highly unlikely to change. In general, if the documentation doesn't mention a feature, it usually means you won't need it for standard viewer development. But for developers who dig deeper into the code, the feature is there and available.

Good eye catching that detail!

Dave Edis - Senior Developer
interactivetools.com

Good to know. I had AI doing a code review of my code and it flagged that the function returned 3 values, but I was only using 2. I will add it to my agents.md file that only 2 are used and the 3rd is CMSB internal use. That will stop the warmings.

Jeff Shields
yaadev.com

By Dave - Yesterday at 9:00pm - edited: Yesterday at 9:02pm

Hi jeff, 

I'll convert the function comment to a proper PHPDoc block with an @return tag at the end as well.  That might help: 

*
* @return array|null [$records, $listMetaData, $schema] - schema for advanced use
*/
Dave Edis - Senior Developer
interactivetools.com