Skip to content

Instantly share code, notes, and snippets.

View esimonetti's full-sized avatar
📃
Open to new opportunities

Enrico Simonetti esimonetti

📃
Open to new opportunities
View GitHub Profile
@esimonetti
esimonetti / table_record_counter.php
Last active October 30, 2019 08:16
Count records per Sugar table and output in json and csv format for reporting purposes - USE TOOTHPASTE INSTEAD! https://github.com/esimonetti/toothpaste
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2018-09-19 on Sugar 8.0.0
//
// CLI script to output the current record count per SQL table, in json and csv format
ini_set('memory_limit', '64M');
@esimonetti
esimonetti / mysql_tables_optimize.php
Last active October 30, 2019 08:14
CLI script to optimize Sugar mysql tables, by dropping all non-primary indices, optimizing and finally re-creating indices. Script similar to https://gist.github.com/esimonetti/7c4d57d57464ce6a71973de6fe0da089 but implementing the recommendations described here https://www.percona.com/blog/2010/12/09/mysql-optimize-tables-innodb-stop/ - USE TOOT…
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2019-01-04 on Sugar 8.0.2
//
// CLI script to optimize Sugar mysql tables, by dropping all non-primary indices, optimizing and finally re-creating indices
function usage($error = '') {
@esimonetti
esimonetti / createMissingTables.php
Last active October 30, 2019 08:13
Create missing tables - USE TOOTHPASTE INSTEAD! https://github.com/esimonetti/toothpaste
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2019-09-24 Sugar 9.0.0
// create missing tables
function usage($error = '') {
if (!empty($error)) print(PHP_EOL . 'Error: ' . $error . PHP_EOL);
@esimonetti
esimonetti / extractMetadata.php
Last active October 30, 2019 08:13
Utility to extract Sugar's metadata content to be able to compare two different metadatas - USE TOOTHPASTE INSTEAD! https://github.com/esimonetti/toothpaste
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2019-09-26 on Sugar 9.0.0
//
// Metadata extractor, to compare 2 metadatas with a diff command
// eg: diff -auNw file1.array file2.array)
@esimonetti
esimonetti / with_acl_team_set_id.php
Last active October 10, 2019 07:35
Find records across all tables with acl_team_set_id not null, and their teams
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2019-09-02 on Sugar 8.0.0
//
// CLI script to find records with acl_team_set_id
function usage($error = '') {
@esimonetti
esimonetti / commentlog.php
Created December 28, 2018 05:47
Show last 10 commentlog entries on Cases, with the newest one at the top
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2018-12-28 Sugar 8.3.0
// Show last 10 commentlog entries on Cases, with the newest one at the top
//
// file: custom/Extension/modules/Cases/Ext/Vardefs/commentlog.php
//
@esimonetti
esimonetti / .htaccess
Last active August 27, 2019 10:17
Change sugar upload dir to another disk/mount
...
...
# file path will depend on the installation path or where the file should be
# if this needs to be executed everywhere (even from cron), consider setting it on php.ini instead of the .htaccess
php_value auto_prepend_file /var/www/html/sugar/prepend.php
@esimonetti
esimonetti / secretHandling.php
Last active May 13, 2019 05:45
Sample of programmatic AES256GCM and blowfish encryption and decryption of secret value in Sugar
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2019-05-13
// Sample of programmatic AES256GCM and blowfish encryption and decryption of secret value in Sugar
// secret value to encrypt for storage purposes, and to decrypt real-time
@esimonetti
esimonetti / TidewaysProf.php
Last active February 20, 2019 10:04
POC of Tideways profiling extension for Sugar 7.9.1.0 on PHP 7.1
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// Original work: https://gist.github.com/lblockken/78a59273f2460b36eb127a7c2ee510a1
//
// 2017-07-31 on Sugar 7.9.1.0 with PHP 7.1
// filename: custom/include/SugarXHprof/TidewaysProf.php
@esimonetti
esimonetti / ProcessQueueCommand.php
Last active January 21, 2019 02:44
Sugar CLI command to run index processing without waiting for the scheduler - SUPERSEDED, LOOK INTO ./bin/sugarcrm search:silent_reindex and ./bin/sugarcrm search:silent_reindex_mp
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-12-15 on Sugar 7.9.2.0
// Sugar CLI command to run index processing without waiting for the scheduler
//
// Trigger reindex with: ./bin/sugarcrm search:reindex
// Process records by running either as a background process or with a cron: ./bin/sugarcrm elastic:process_records