Monday, April 25, 2022

fixing an error in a moodle ad-hoc query

One of the ad-hoc queries in one of our moodle servers was returning "Error reading from database" when executing certain queries with certain parameters, working with other parameters.

Troubleshooting - The general issue is that with ad-hoc queries, only the generic error "Error reading from database" is shown, and not the exact cause of the error, which would be some problem with the SQL query. Running the same query using DBeaver, (I had to find/replace { with ourprefix_ and } with a space) 
I get the more helpful error message

SQL Error [1242] [21000]: Subquery returns more than 1 row

Commenting out all except the first subquery, I still got the error. So, there was an issue is with the first subquery.

Looking at the table ourprefix_feedback_value I saw that there are some entries where the name field with match
like '%Chapter%' but the typ field is not a textfield.

Assuming that this is what is causing the problem, I modified the query by adding an additional line in bold below
where
fc.timemodified = fc2.timemodified
and fi2.name like '%Chapter%'
and fi2.typ = 'textfield') as "Chapter name",

This also did not solve the issue. Then, checked the ourprefix_feedback_completed table looking for duplicates in the timestamps like
select fc3.timemodified, count(fc3.timemodified)
from
ourprefix_feedback_value  fv3
left join vv_feedback_item  fi3 on fi3.id = fv3.item
left join vv_feedback_completed  fc3 on fc3.id = fv3.completed
where
fi3.name like '%Main%Script%'
GROUP BY fc3.timemodified
HAVING COUNT(fc3.timemodified) > 1

found 1646480361 was repeated twice. Two feedback items had exactly the same timestamp. Changed the second one to 1646480362 and the problem was solved.


 

Saturday, April 23, 2022

troubleshooting a php framework / cms based site

A couple of websites went down after a server upgrade. Checking out the contents of public_html, found some directories named fuel and codeigniter. Initially thought it was a codeigniter-based site, 

Later, found some function calls like fuel_set_var() which on searching github and google led to FUEL CMS - 

My first impressions were that upgrading from the existing 0.9x version to 1.5x was not so straightforward - the migration tool, mentioned in the documentation above, did not run. Then there is the part of the documentation which says that it needs MySQL 4.x + - 
Hopefully it works with 5.x? Will have to try manually capitalizing filenames and class names as needed for codeigniter 3+. 
"If you have a current installation of 1.3x or less and are wanting to upgrade, there are a few things to be aware of. FUEL 1.4 uses CodeIgniter 3.x which includes a number of changes, the most prominent being the capitalization of controller and model names. Additionally it is more strict on reporting errors."


Friday, April 22, 2022

changing cpanel theme for all accounts in WHM

There was the notification about CPanel Paper Lantern theme being deprecated and replaced with Jupiter theme. Changed the theme for all accounts using

- changed themes for all by going to WHM - Edit a package - and editing all the defined default packages. 

fixing wordpress errors after server upgrade

A wordpress site was not loading after a server upgrade. Just a blank screen. To troubleshoot, first checked database connectivity, database password in wp-config - that was working. Then, tried to get more information about the error by changing the define( 'WP_DEBUG', false ); - changed to true. Then the error showed up - Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 65536 bytes) in /home/websitename/public_html/wp-content/plugins/woocommerce/includes/class-wc-ajax.php on line 1101

Fixed it using the solution at 
by adding 
ini_set('memory_limit','128M');
to the top of wp-config.php

Problem solved. Set the WP_DEBUG variable back to false. 

Wednesday, April 20, 2022

OpenCV with Qt creator

K asked for pointers for this issue - I am trying to integrate OpenCV into the C++ code that I wrote for gamma acquisition. I am facing a problem while integrating it into the software Qt Creator. The headers are included without any errors, but when I initialize an empty matrix it returns "undefined reference to 'cv::Mat::~Mat()'". 

My reply was - 

"Undefined reference in the linking process doesn't mean, that it can't find the declaration in the header file, it means that it cant find the definition/implementation in any of the provided object files."

So the issue is most probably due to some path issue in the Makefile - it depends on what you are using to build the project. If you are using qt creator, then it would be qmake.

The easiest way to solve this would be perhaps a google search on getting started with OpenCV and QT creator.
Perhaps
if you are using windows.

This is an old version for opencv 3 on ubuntu,
but you may get some ideas from it.

He finally solved it himself - "I could link the library and use its functions now. I believe there are a lot of ways to link the library and I figured one way that worked for me.

I have discussed the way I solved it here 
so that it will be helpful to whoever compiles the OpenCV with Mingw 32-bit in Qt Creator."

So, in short, he "had to link the libraries by right-clicking on the project folder on the left-sidebar, selecting Add Libraries and choosing the External Libraries option (added one by one).

win32: LIBS += -LD:/opencv-build/install/x86/mingw/lib/ -llibopencv_core320.dll
win32: LIBS += -LD:/opencv-build/install/x86/mingw/lib/ -llibopencv_highgui320.dll
win32: LIBS += -LD:/opencv-build/install/x86/mingw/lib/ -llibopencv_imgcodecs320.dll 
INCLUDEPATH += D:/opencv-build/install/include
DEPENDPATH += D:/opencv-build/install/include

////NOTE: imgcodecs library is required for imread to work//////

Friday, April 15, 2022

improvMX for domain email forwarding

In a previous post, I had mentioned using our domain registrar's free email service. Now I have moved away from that to improvMX, for a hopefully more stable performance - emails were taking around 20 minutes to be forwarded using our domain registrar's mail severs, and this was causing problems with one-time passwords (OTPs) sent by Github, for example. There is a way to send emails via gmail smtp servers, too (but it displays "via ourdomain.tld" when I use my account@ourdomain.tld ).

Sunday, April 10, 2022

PBX with Raspberry Pi - RasPBX - or with the cloud - AWS

 https://www.youtube.com/watch?v=n_txukfW3uE
How to turn Raspberry Pi into FreePBX-based GSM gateway
(needs 3g modem)

Or, if willing to pay for the SIP trunk termination instead of buying a 3g modem, AWS based method -
https://www.youtube.com/watch?v=n_1wX7kKx7k

Quite interesting. 

Friday, April 08, 2022

youtube live streaming possibilities

Wednesday, April 06, 2022

bulk replacing descriptions

In our local database, using phpPgAdmin, got an sql prompt by choosing a Select and Edit SQL, then the following query worked:

SELECT "fileid","description","languageid" FROM "public"."file_information" WHERE "description" LIKE 'Our Descrip%' AND "languageid" = '1'

Edited SQL to

update "public"."file_information" set "description"
REPLACE(description,'Our Descrip', 'Prefix to Our Descrip') 
WHERE "description" LIKE 'Our Descrip%' AND "languageid" = '1'

(trying this with a view instead of a table did not work, 
ERROR:  cannot update a view
HINT:  You need an unconditional ON UPDATE DO INSTEAD rule.)

For the remote database, tried a similar query, but it failed. phpMyAdmin had a find/replace option, so used that, and the corresponding query, which has single back-quotes, was:
UPDATE `our_table_name` SET `description` = REPLACE(`description`, 'Our Descrip', 'Prefix to Our Descrip') WHERE `description` LIKE 'Our Descrip%' COLLATE utf8mb4_bin

Tuesday, April 05, 2022

moodle minor upgrade

An update for doing minor point upgrades to moodle - much simpler than what I have listed at 
https://hnsws.blogspot.com/2021/08/detailed-steps-for-moodle-upgrade-using.html

Just
cd /var/www/theLMSgit
sudo -u www-data /usr/bin/php admin/cli/maintenance.php --enable
git pull
sudo chown -R azureuser:www-data .
sudo chmod -R 775 .
sudo -u www-data /usr/bin/php admin/cli/upgrade.php
(type y when prompted)

sudo -u www-data /usr/bin/php admin/cli/maintenance.php --disable
cd our-notifier-folder
sudo ./startupscript.sh
(can check out.log to see if server has started)

We can then test notifications using Site Administration - Messaging - Mobile - Check and test push notification configuration - that page asks us to make sure that "your devices are connected to the Internet and that the mobile app is not open (since push notifications are only displayed when received in the background)."