В 2024 году потребовалось на PHP написать функцию сортировки массива, при которой элементы для которых дан порядок сортировки, окажутся впереди в нужном порядке, а остальные останутся как есть. За пару тычков было написано следующее:

usort($categories, function($a, $b) use ($customAllSort) {
  $indexA = array_search((int)$a->id, $customAllSort);
  $indexB = array_search((int)$b->id, $customAllSort);
  if ($indexA === false && $indexB === false) { return 0; } 
  if ($indexA === false && $indexB !== false) { return 1; } 
  if ($indexA !== false && $indexB === false) { return -1; }
  return $indexA <=> $indexB;
});

Спустя триллион тычков оказялось, чтоонё нёнёнё роботоит потомушьто PHP<8.0.0.0.0.0 - элементы массива, не затрагиваемые сортировкой оказывались ПРОИЗВОЛЬНО ПЕРЕМЕШАНЫ нахуй.

Note:

If two members compare as equal, they retain their original order. Prior to PHP 8.0.0, their relative order in the sorted array was undefined.

Вот спасибо, ебать, большое. Спустя тысячу тычков было написано следующее:

usort($categories, function($a, $b) use ($categories, $customAllSort) {
  $indexA = array_search((int)$a->id, $customAllSort);
  $indexB = array_search((int)$b->id, $customAllSort);
  if ($indexA === false && $indexB === false) 
    { return array_search($a,$categories) <=> array_search($b,$categories); } 
  if ($indexA === false && $indexB !== false) { return 1; } 
  if ($indexA !== false && $indexB === false) { return -1; }
  return $indexA <=> $indexB;
});

И на локалхосте оно отработало. ХОВЕВЕР.

Fatal error: Nesting level too deep - recursive dependency? in /istochnik/nevrnogo/tika/ProductController.php on line 120

Скотомогильное уёбище натужно отыскало в этом коде рекурсию на строчке array_search($a,$categories) <=> array_search($b,$categories). Покажите мне, блядь, рекурсию в этом месте, нахуй. Рекурсия тут есть только в больной башке у шайтан-коробки с электронами.

Спустя десять тысяч тычков было написано следующее:

array_multisort(
  array_map(
    function($index, $category) use ($customAllSort) {
      $position = array_search($category->id, $customAllSort);
      return $position !== false ? $position : count($customAllSort) + 1 + $index;
    }, 
    array_keys($categories), 
    $categories
  ), 
  $categories
);

Вау! Оно того стоило! (нет, не стоило)

А день уже прошёл. А сутки жизни уже не вернуть. Вот это я классно обменялся! Ставьте лайки, пишите "нц ты и лох" в колмментрю.досвидня

 

set -o xtrace

To revert to normal, exit the subshell or

set +o xtrace

 

transparent-1x1.tiny.png:

<div style="width:1px;height:1px;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=');"></div>
<img style="width:1px;height:1px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=" />

СКАЧАТЬ PNG ФАЙЛ

 
docker run -ti --entrypoint /bin/sh kodekloud/simple-prompt-docker
docker run -ti kodekloud/simple-prompt-docker /bin/sh
docker run -ti kodekloud/simple-prompt-docker sh
 

https://stackoverflow.com/questions/33682977/php-returning-pdoexception-could-not-find-driver-when-trying-to-connect-do-sql/74010959#74010959

I've had similar problem and I think it is important to give another elaborate answer on this. The root of the problem was that I built my own newest version of sqlite from sources (repo for Ubuntu 16.04 is outdated) without SQLITE_ENABLE_COLUMN_METADATA definition. It worked before I restarted the machine. Probably it's the previous version was running or something like that, because after a reboot I've got the trouble.

http://source.online.free.fr/Linux_HowToCompileSQLite.html

The SQLitePass library uses specific SQLite functions to retrieve schema information on an SQL statement.

These functions are :

    sqlite3_column_database_name
    sqlite3_column_database_name16
    sqlite3_column_table_name
    sqlite3_column_table_name16
    sqlite3_column_origin_name
    sqlite3_column_origin_name16
    sqlite3_table_column_metadata

Unfortunately, they are not always available in the precompiled library available on the SQLite webpage or in the sqlite package dedicated to your Linux distribution.

In order to get these functions in our sqlite3.so library, we need to compile the SQLite source code with the [SQLITE_ENABLE_COLUMN_METADATA] compiler directive.

That's why less +G /var/log/php_errors.log output had the line

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/pdo_sqlite.so' - /usr/lib/php/20151012/pdo_sqlite.so: undefined symbol: sqlite3_column_table_name in Unknown on line 0

although the pdo_sqlite was present in phpinfo(); output all the time.

To solve the problem I did follow the compilation instructions by the link above: open sqlite3.c in the sources and after the lines

#define SQLITE_CORE 1
#define SQLITE_AMALGAMATION 1
#ifndef SQLITE_PRIVATE
# define SQLITE_PRIVATE static
#endif

add

#define SQLITE_ENABLE_COLUMN_METADATA

then run

$ ./configure
$ make
$ make check
make: Nothing to be done for 'check'.
$ sudo make install
$ sudo service apache2 restart

and now sqlite is working again.

 
# Default server configuration

server 
{
        server_name _;
        listen 80 default_server;
        listen [::]:80 default_server;
        access_log /var/log/nginx/default.access.log;
        error_log /var/log/nginx/default.error.log;
        return 444;
}
server
{
        server_name _;
        listen 443 http2 ssl default_server;
        ssl_certificate /etc/nginx/ssl/certs/nginx-default.crt;
        ssl_certificate_key /etc/nginx/ssl/private/nginx-default.key;
        access_log /var/log/nginx/default.access.log;
        error_log /var/log/nginx/default.error.log;
        return 444;
}

SELECT (NULL + 1)

Results in:

NULL

Оуказиваеться если к нулю прибавить один, будет нуль. Шёл 2022-й...

Когда родил ундехуйнед, но на дворе суровые 70-е и ты за неимением мозгов, называешь ундехуйнед нулём, а благодарные потомки повторяют твой собаче-конский бред из версии в версию.

Расскажить им блядь про ундехйнид ёбанный.. Ебать блядь. Хоть бы алиас для приличия ввели. Нет, хотим жрать говно. А вместо FALSE у нас будет .F.

P.S.
Сикуель, остановись.
https://stackoverflow.com/questions/16129432/why-not-pdo-mysql-return-integer

В корневой директории сайта необходимо найти файл wp-config.php и открыть его для редактирования любым текстовым редактором.
Далее, нужно в самом низу файла прописать следующую настройку:

define('ALLOW_UNFILTERED_UPLOADS', true);

Я только что еще раз проверил - все работает. Не забываем делать именно так, как написано в статье. Загружать файл ТОЛЬКО через Медиафайлы > Добавить новый. Данный способ не подходит для встроенного в редактор загрузчика файлов, поэтому в нем он работать не будет.

https://pc.ru/articles/oshibka-izvinite-etot-tip-fajla-nedopustim-po-soobrazheniyam-bezopasnosti

https://chrome.google.com/webstore/detail/crx-extractordownloader/ajkhmmldknmfjnmeedkbkkojgobmljda


CRX-Extractor-Downloader---Интерне

https://github.com/dashokkumar93/crx-download