Skip to content

Instantly share code, notes, and snippets.

View garvinhicking's full-sized avatar

Garvin Hicking garvinhicking

View GitHub Profile
@garvinhicking
garvinhicking / parse-json.php
Created July 1, 2024 14:57
Pleroma rejection filter
<?php
$stdin = file_get_contents('php://stdin');
$json = json_decode($stdin, true, JSON_OBJECT_AS_ARRAY | JSON_THROW_ON_ERROR);
if ($json['group'] !== ':pleroma' || $json['key'] !== ':mrf_simple') {
echo "Only :pleroma & :mrf_simple JSON supported. Stop feeding me microplastics.\n";
exit(1);
}
$count = 0;
echo '"Site";"Reason"' . "\n";
foreach ($json['value'] as $json_struct) {
@garvinhicking
garvinhicking / patch.diff
Created January 24, 2024 20:33
TYPO3 ImportExport stripPathSitePrefix Patch
diff --git a/typo3/sysext/impexp/Classes/Export.php b/typo3/sysext/impexp/Classes/Export.php
index 54b4b63599..dd94d85749 100644
--- a/typo3/sysext/impexp/Classes/Export.php
+++ b/typo3/sysext/impexp/Classes/Export.php
@@ -1095,7 +1095,7 @@ class Export extends ImportExport
$fileInfo = [];
$fileInfo['filename'] = PathUtility::basename($fileData['ID_absFile']);
$fileInfo['filemtime'] = $fileStat['mtime'];
- $fileInfo['relFileRef'] = PathUtility::stripPathSitePrefix($fileData['ID_absFile']);
+ $fileInfo['relFileRef'] = PathUtility::stripPathSitePrefix((string)$fileData['ID_absFile'] ?? '');
bacon/bacon-qr-code 2.0.8 BaconQrCode is a QR code generator for PHP.
bnf/phpstan-psr-container 1.0.1 PHPStan dynamic return type extension for PSR-11 ContainerInterface
christian-riesen/base32 1.6.0 Base32 encoder/decoder according to RFC 4648
composer/pcre 3.1.1 PCRE wrapping library that offers type-safe preg_* replacements.
composer/semver 3.4.0 Semver library that offers utilities, version constraint parsing and validation.
composer/xdebug-handler 3.0.3 Restarts a process without Xdebug.
contentblocks/examples dev-main 7d19858 TYPO3 CMS Content Blocks examples
dasprid/enum 1.0.5 PHP 7.1 enum implementation
doctrine/annotations 2.0.1 Docblock Annotations Parser
doctrine/cache 2.2.0 PHP Doctrine Cache library is a popular cache implementation that supports m
@garvinhicking
garvinhicking / index.html
Created November 30, 2023 11:47
SVG crop dummy implementation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SVG comparison</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
* {
box-sizing: border-box;
font-family: sans-serif;
@garvinhicking
garvinhicking / Makefile
Created November 9, 2023 17:17
Makefile
PHP_BIN ?= docker run -it --rm --user $$(id -u):$$(id -g) -v${PWD}:/opt/project -w /opt/project php:8.2-cli php -d memory_limit=1024M
PHP_PROJECT_BIN = docker run -i --rm --user $$(id -u):$$(id -g) -v${PWD}:/project typo3-docs:local php -d memory_limit=1024M
## This can be adapted in the .git/hooks/pre-commit call of this step. If you change this line (i.e. new PHP version), also change it in that template
.PHONY: help
help: ## Displays this list of targets with descriptions
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: code-style
code-style:
@garvinhicking
garvinhicking / SpiderApplication.php
Created November 9, 2023 10:09
SpiderApplication - `php cli.php`
<?php
namespace TYPO3\CMS\Core\Console;
use Symfony\Component\Console\Application as SymfonyConsoleApplication;
use Symfony\Component\Console\Exception\ExceptionInterface;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use TYPO3\CMS\Core\Adapter\EventDispatcherAdapter as SymfonyEventDispatcher;
@garvinhicking
garvinhicking / recoverypatch-11.5.diff
Created October 26, 2023 19:27
Recovery me, oh danny boy
diff --git a/typo3/sysext/felogin/Classes/Service/RecoveryService.php b/typo3/sysext/felogin/Classes/Service/RecoveryService.php
index a460d3d899..2b19652e2c 100644
--- a/typo3/sysext/felogin/Classes/Service/RecoveryService.php
+++ b/typo3/sysext/felogin/Classes/Service/RecoveryService.php
@@ -138,7 +138,9 @@ class RecoveryService implements RecoveryServiceInterface
*/
protected function prepareMail(Address $receiver, string $hash): Email
{
- $url = $this->uriBuilder->setCreateAbsoluteUri(true)
+ $url = $this->uriBuilder
@garvinhicking
garvinhicking / YourName-Services-AuthenticationService.php
Created October 25, 2023 15:16
Simple TYPO3 Authentication service
<?php
namespace YourName\YourExtension\Services;
use TYPO3\CMS\Core\Session\Backend\Exception\SessionNotCreatedException;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Connection;
use Psr\Http\Message\RequestInterface;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Http\ServerRequestFactory;
@garvinhicking
garvinhicking / flashmessage.fluid.html
Last active October 25, 2023 14:57
FlashMessage.html
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true">
<f:flashMessages as="flashMessages">
<f:if condition="{flashMessages}">
<ul class="typo3-messages">
<f:for each="{flashMessages}" as="flashMessage">
<li class="alert {f:if(condition: '{flashMessage.severity} == 0', then: 'alert-success', else: 'alert-warning')}">
<p class="alert-message">
<f:comment>MAKE SURE no user-specified content is added here without CUSTOM escaping!!!</f:comment>
<f:format.raw>{flashMessage.message}</f:format.raw>
@garvinhicking
garvinhicking / ReferenceIndex.php.diff
Last active October 15, 2023 19:16
ReferenceIndex Post-Patch
diff --git a/typo3/sysext/core/Classes/Database/ReferenceIndex.php b/typo3/sysext/core/Classes/Database/ReferenceIndex.php
index a5ea028d9c..39c8998f55 100644
--- a/typo3/sysext/core/Classes/Database/ReferenceIndex.php
+++ b/typo3/sysext/core/Classes/Database/ReferenceIndex.php
@@ -981,6 +981,11 @@ class ReferenceIndex
if ($numberOfDeletedRecordsInTargetTable > 0) {
$numberOfHandledRecords += $numberOfDeletedRecordsInTargetTable;
// List of deleted=0 records in target table that have records in sys_refindex.
+ // Note: $subQueryBuilder actually fills parameter placeholders for the main $queryBuilder
+ // That means the subQuery is never meant to be executed on its own, only used to be filled-in