CMSB v3.75 Beta (DB Performance, Debug Footers, and ZenDB)
1 posts by 1 authors in: Forums > CMS Builder
Last Post: 2 hours ago (RSS)
By Dave - 2 hours ago
Hi everyone,
We've released a beta of version 3.75! This update has an interesting mix of new features:
- Uploads Table: We've optimized the database and added indexes for faster performance (10x faster or more for large databases)
- Upload Counts: Upload fields are now stored in MySQL and store a count of uploads for that record, so you can now easily search for records with uploads if you need to
- CMS Debug Footers: This is for plugin developers. If you're logged in as an admin, you can view-source on any page in the CMS, scroll to the bottom, and see a list of PHP files included and plugin hooks called on each one. This makes it a lot easier to find where to "hook in" to the CMS on a given page when you're writing a plugin
- Web Debug Footers: We're often debugging client websites and searching for what files are being included to build a page. This is especially true when using permalinks and the URL doesn't necessarily even correlate to the php files. If you are logged in to the CMS as an admin, you can now add ?__debug (or &__debug) to the query string of any front-end page and see some debug info and a list of included files in the footer. Here's an example from our front page:
<!-- DEBUG FOOTER (visible to admins only)
CMS Version: 3.75 (build 2805)
Memory Usage: 819.02 KB (peak: 919.51 KB)
Execution Time: 0.006 seconds
Included Frontend Files (3):
/var/www/vhosts/interactivetools.com/httpdocs/index.php
/var/www/vhosts/interactivetools.com/httpdocs/_init.php
/var/www/vhosts/interactivetools.com/httpdocs/_footer.php
-->
This lets us quickly track down the files we need to edit or update, saving time on every project.
- ZenDB Updates: ZenDB now uses SmartArray and SmartString. This makes it incredibly easy to write some simple, compact, and powerful code. We've had to make a backwards incompatible change to make this work, though. So if you are using SmartArrays already, you need to change ::new() to :newSS(). SmartArray::new() creates a SmartArray with regular values, whereas SmartArray::newSS() returns SmartStrings for values. And don't worry if none of that makes sense, we'll automate and simplify it over time. But rest assured we have some incredibly powerful new tools we're rolling out.
- SmartArray and SmartString docs: You can find them here:
- ZenDB ->load() method: ZenDB can now load associated records from any of these field types: createdByUserNum, updatedByUserNum, upload fields, list field, and foreign key fields. Here's an example with some of the above libraries all working together:
$articles = DB::select("articles", "LIMIT 10"); // SmartArray of articles
$latestArticle = $articles->last(); // Get last article
$latestArticle->debug(); // show debug info
// Output:
//[
// 'num' => 25,
// 'createdDate' => '2024-11-12 22:04:28',
// 'createdByUserNum' => 0, // ->load('createdByUserNum') for more
// 'name' => 'Sample Article title',
// 'categoryId' => "\t12\t36\t22\t", // ->load('categoryId') for more
// 'uploads' => 12, // ->load('uploads') for more
// 'authorId' => 231, // ->load('authorId') for more
// ]
// You can now call ->load() to load additional records:
foreach ($latestArticle->load('uploads') as $upload) { /* show uploads */ }
$latestArticle->load('authorId')->fullname; // get author name
// Or even use these values in strings:
foreach ($articles as $article) {
echo "$article->title by {$article->load('authorId')->fullname}\n";
}
The property format (e.g., $article->title) is much cleaner and simpler than what you'd typically have to write with {$article['title']}. The rule with properties is you don't need {braces} with basic $var->property access, only if you're adding more on (like the load query above).
We've done this in such a way that nothing is loaded until you need it (to minimize load on the database) and when you load() something it loads and caches associated records, but not everything. So in the above examples, it would load authors for the 10 articles on the page, so only one database query is required.
Lots of new things there so feel free to post any questions or feedback!
The full changelog for this release is as follows:
*** November 26, 2024 - Version 3.75 (Debug Footers and DB performance)
SERVER REQUIREMENTS (Since Dec 2023): PHP 8.0+ and MySQL 5.7+ (or MariaDB 10.2+)
NEW FEATURES
- Uploads Table: Optimized database and added indexes for faster performance (up to 10x faster for large databases)
- Debug Footers: Added admin debug footers (HTML comments with page/system info for troubleshooting)
- Frontend: Add ?__debug to URL to see exec time, memory usage, and included files
- CMS Admin: View source to see loaded menu files and plugin hooks available on any page
- ZenDB: Added new $results->load('field') method loads records for uploads, createdByUserNum, and other list fields
- ZenDB: Added :: as an alternative alias for inserting table prefixes
MINOR CHANGES
- Database Editor UI: Add colored labels for MySQL Type column and display non-utf8mb4 charsets (if present)
- Upload fields: Columns now store a count of the uploads (for database queries)
- Programmers: Added utility functions: explodeTSV(), implodeTSV() and inTSV() for parsing multi-value list field values
- ZenDB: Results are returned as SmartArrays and SmartStrings for advanced array and string manipulation
BUG FIXES
- PHP 8.4 compatibility fixes
- Database Editor: Added option to bypass errors when unable to automatically apply schema updates
- Single Record Menus: Fixed issue where previous uploads weren't showing up in upload browse list
- Minor UI fixes for field and label spacing and alignment
- Misc code and other minor improvements
You can download the latest beta here:https://www.interactivetools.com/download/
Please post (or email) any feedback, questions, concerns, or bugs you find. Your help beta testing allows us to release new features even faster.
Thanks, we look forward to your feedback! :)
interactivetools.com