CMSB v3.75 Released (Dec 10) - DB Performance & Debug Footers

9 posts by 5 authors in: Forums > CMS Builder
Last Post: March 12   (RSS)

By rez - January 28 - edited: January 28

I'm, for example, fetching recipes that contain the product on a details web page. So in a recipe record, I have checkboxes / a list of all the products (list from another database table) I manually checkbox when pasting in a recipe (meh, works ok for a small site, kind of manual though). Then, on the product page, the related recipes are displayed, example below. Over the years, all the exploding and such to get this type of thing done has always put me in a fog and I'd use snippets to get it done again next time.

This is what load is for? As in, the header when making a list (loading records) gets this all done? Where do I learn more? Is this in the code generator now or... 

Thanks for any direction.

    <?php if($retail_itemsRecord):?>     
           <!-- Display recipes if they match the current product -->
        <?php
          $matchedRecipes = [];
          foreach ($recipesRecords as $recipe) {
              if (in_array($retail_itemsRecord['num'], $recipe['products:values'])) {
                  $matchedRecipes[] = $recipe;
              }
          }
        ?>

        <?php if (!empty($matchedRecipes)): ?>
          <section class="theme-1 padding-vertical-1">
            <div class="grid-container">
              <div class="grid-x grid-padding-x">              
                  <div class="cell">
                      <hr>
                      <h2>Related Recipes:</h2>
                  </div>
              </div>
            </div>
        </section>
    <?php endif ?>

    <?php if($retail_itemsRecord):?>
          <section class="theme-1 padding-vertical-1">
            <div class="grid-container">
              <div class="grid-x grid-padding-x medium-up-3 large-up-4" data-equalizer data-equalize-on="medium" data-equalize-by-row="true">
                
                  <?php foreach ($matchedRecipes as $recipe): ?>
                    <a href="<?php echo htmlencode($recipe['_link']); ?>">
                    <div class="cell padding-1">
                    <div class="card" data-equalizer-watch>
                      <?php if (!empty($recipe['image'])): ?>  
                          <?php foreach ($recipe['image'] as $index => $upload): ?>
                            <img src="<?php echo htmlencode($upload['thumbUrlPath3']) ?>" alt="<?php echo ($recipe['title']) ?>">
                          <?php endforeach ?>
                      <?php else: ?>
                        <?php foreach ($placeholder_imageRecord['image'] as $index => $upload): ?>    
                          <img src="<?php echo htmlencode($upload['thumbUrlPath3']) ?>" alt="<?php echo ($recipe['title']) ?>">
                        <?php endforeach; ?>
                      <?php endif; ?>
                      <div class="card-section">
                        <?php echo htmlencode($recipe['title']); ?>
                      </div>      
                    </div>
                    </div></a>
                  <?php endforeach; ?>
              </div>
            </div>
          </section>
        <?php endif; ?>
    <?php endif ?>

Hi Rez, 

I'm glad to hear you want to try out the new DB code!  We're aiming to make it much easier to use.  

Can you post the getRecords code you used to create this page?   Or simpler, fill out a 2nd level support request with a link to your page, and I'll mock up a demo for you so you can try it.
https://interactivetools.com/support/request/

ZenDB still doesn't support automatic searching or paging, but all of that is on the way, and once it's ready, it will be in the code generator.

Dave Edis - Senior Developer
interactivetools.com

In my 3.75 versions, when I get errors in the development log, the date is coming up as "never"  - This is something new that I haven't seen in previous versions.

Kenny H

Hi Kenny,

Just out of clarification, are you talking about in the development log under the "Date / When" heading? Or somewhere else in the development log? Did you recently update to 3.75? Are all the development log records showing that or just some of them? Was there any kind of database update from your host do you know?

Usually when 'never' appears it means that a date time field is not in a recognizable format. There could be a host of reasons. If you are seeing it a lot, it might be worth submitting a support ticket with us to investigate further.

I am going to guess something was either updated or changed recently that may have resulted in bad dates.

Tim Hurd
Senior Web Programmer
Interactivetools.com

Hello again Kenny,

Thinking through it a bit more a few things you can check on your end would be to go to the MySQL Source tab in CMSB admin

/admin.php?menu=database&action=editTable&tableName=_error_log#tab_mysqlSource

Within this page you can see if the `dateLogged` field is properly set up as being `timestamp NULL DEFAULT CURRENT_TIMESTAMP`.

You can also try enabling your developer console plugin and going to

/admin.php?_pluginAction=mysqlConsole&tableName=accounts

There you can try running a query like:

SELECT num, dateLogged, error FROM ::_error_log ORDER BY num DESC LIMIT 20

This should show you the type of dates that CSMB is using and why it might be coming back as `never`. 

If you have any additional questions about this, I will be happy to elaborate further. I hope this helps! :)

Tim Hurd
Senior Web Programmer
Interactivetools.com

Hi Tim,

I looked through and performed some of the actions you asked me to. I get an error when running the MySql Query

MySQL Error(1064): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':cms_error_log ORDER BY num DESC LIMIT 20' at line 1

I couldn't find a dateLogged field to look at.

I have narrowed down some of the problem. I redesigned a website and some of the pages (permalinks) have been removed and 301 redirects implemented. When someone tries to go to an old page that doesn't exist, those errors are being logged with the never timestamp and the 301 redirect doesn't work.

Errors in the developer log that are related say:

  • Warning: Trying to access array offset on value of type null (deleted pages)
  • Warning: Undefined variable $isLastRecord (my mistake)

I have fixed these problems with:

	// Check if FAQ record exists before rendering content
	if (!empty($faqRecord) && is_array($faqRecord)) {	// Define $isLastRecord if not already defined
		$isLastRecord = $isLastRecord ?? false;

 isLastRecord was causing problems because I forgot to define it, but mentioned on the page <?= $isLastRecord ? 'mb-0' : 'mb-4' ?>

So, in short, I think I have fixed these problems, but it doesn't explain the never timestamp in the developer log when these errors occur. It's not stopping anything from happening here, so very low priority.

Thanks for helping me getting the actual errors figured out - you put me on the right path.

Kenny

Hey Dave - 

I upgraded to 3.75 but it is stuck on "software update to 3.65" and it doesn't go any further and I can't get into the admin panel at all.  Any ideas on how I can get access back?

Thanks!

craig

Hi Craig, 

Can you fill out a second level support request and we'll take a look for you? 
https://interactivetools.com/support/request/

Thanks!

Dave Edis - Senior Developer
interactivetools.com