ADD NEW BLOCK and Block Type MySQLI error

Permalink
I recently updated our concrete5 site from 5.6.2.1 to 5.6.3.5 using the concrete5.6.3.5_remote_updater.

...but I now can no longer Add New Blocks. On investigation I discovered that under

DASHBOARD > STACKS & BLOCKS > Block Types

...the following error occurs on the dashboard in the logs and the issue appears to be coming from discussions...

ERROR
mysqli 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 '' at line 3] in EXECUTE("SELECT uID, uName FROM Users WHERE uLastOnline > 1607522307 ORDER BY uLastOnline DESC LIMIT ")


From the logs, I traced the problem to packages > discussions > blocks > users_online > controller.php (lines 19 and 52).
I have changed line 52 as seen in the commented code but the problem persists.


protected function getArrayOfRecentUsers($since_in_seconds,$number_of_users){
         $q = "SELECT uID, uName
            FROM Users
            WHERE uLastOnline > ? ORDER BY uLastOnline DESC";      
         /*$q = 'SELECT uID, uName '
         . 'FROM Users ' 
         . 'WHERE '          
         . 'uLastOnline > ? '
         . 'ORDER BY uLastOnline DESC';*/
         $v = Array(time()-$since_in_seconds);         
         $db = Loader::db();         
         $rs = $db->SelectLimit($q,$number_of_users,-1,$v);
         $users = array();
         while ($row = $rs->fetchRow()) {
            $users[($row['uID'])]  = $row['uName'];


I think it is also preventing me from Adding New Blocks.
Can anyone please help as I'm under a lot of pressure to proceed?

3 Attachments

 
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
The query has LIMIT but with no value?
How many users are listed in the Users database table?
zeetron replied on at Permalink Reply
Appreciate the rapid reply immensely.
For now just two users as I got a lot of spam and deleted the rest.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
EDIT...
Try changing line 52 to this
$rs = $db->SelectLimit($q,100000,0,$v);
zeetron replied on at Permalink Reply 2 Attachments
Hi Concrete5Owl,

When I went back to Block Types after clearing the cache I got...

Fatal error: Cannot redeclare class FormBlockController in /home/sites/digitizethis.co.uk/public_html/updates/concrete5.6.3.5_remote_updater/concrete/blocks/form/controller.php on line 3
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
There must be something else causing this.
I installed the discussion package on a dev 5.6 site and modified the controller as per my post.
I am able to browse the Block Types with no problem?
zeetron replied on at Permalink Reply 2 Attachments
Aren't the logs suppose to inform a PHP developer of what is happening? I'm no PHP developer but If my surmising is any good, I strongly think any deductions should be retrieved from these logs. See attached.

Initially when I look in the network tab I see a 500 error on "edit_area_popup.php?cID=150&arHandle=Sidebar&atask=add&addOnly=0" but now after your suggested change I get a better feedback and a status code of 200 but it has the last error message i notified.

Otherwise, could MariaDB SQL database constitute the problem?

I can edit existing blocks since the concrete5 update, but I can't seem to "Add any new blocks" on any page, hence the reason I visited the Block Types page only to discover the MySQLi error which is consistent with the logs whenever i try to add a new block.

The funny thing is I haven't used the discussions package yet so no customised parts.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
If your not using the discussions package, why not just uninstall it?
I will take a look at the log file image to see if anything can be found that might be causing the errors.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
The first two error messages are probably being caused by search engine bots attempting to use the forms on your site.
The last message is an old one that was thrown up before you edited the controller file.
You should clear the logs and see if any others pop up later.
zeetron replied on at Permalink Best Answer Reply 3 Attachments
Hi ConcreteOwl,

I have now resolved the problem.

Following your suggestions yesterday with modifying the discussions file line 52...
I kept getting the following error...

Fatal error: Cannot redeclare class FormBlockController in /home/sites/digitizethis.co.uk/public_html/updates/concrete5.6.3.5_remote_updater/concrete/blocks/form/controller.php on line 3


I then did the following...

First of all I cleared the logs and uninstalled "discussions" package. That made no difference.
Then I removed the concrete folder in the updater (concrete5.6.3.5_updater) and replaced it with a new concrete folder from the concrete5 downloads page [https://www.concrete5.org/download] (version 5.6.3.5) and that made no difference either.
Cleared the cache but no change...

Finally I hesitantly addressed the updater file on line 3 at "./updates/concrete5.6.3.5_remote_updater/concrete/blocks/form/controller.php"

I then changed it from...
<?php 
defined('C5_EXECUTE') or die("Access Denied.");
class FormBlockController extends Concrete5_Controller_Block_Form {}
class FormBlockStatistics extends Concrete5_Controller_Block_FormStatistics {}
class MiniSurvey extends Concrete5_Controller_Block_FormMinisurvey {}


to

<?php 
defined('C5_EXECUTE') or die("Access Denied.");
class FormBlockStatistics extends Concrete5_Controller_Block_FormStatistics {}



It now WORKS perfectly.
"Dashboard > Stack & Blocks > BlockTypes" also works.
Now I can also add new blocks with no pending spinners.

Thanks for you kind assistance, it gave me reason to think outside the box.