Make WordPress Core

Changes between Initial Version and Version 4 of Ticket #40404


Ignore:
Timestamp:
02/12/2025 04:14:16 PM (12 months ago)
Author:
swissspidy
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #40404

    • Property Component changed from General to Query
    • Property Summary changed from Slow sampling when a large number of posts from a big 10-ing thousand to Slow queries with a large number of posts (tens of thousands and above)
  • Ticket #40404 – Description

    initial v4  
    77To store "lists" of sorting in the database was created table:
    88
    9 ###
     9{{{
    1010CREATE TABLE `wp_сорт` (
    1111  `номер_сорта` int(10) unsigned NOT NULL AUTO_INCREMENT,
     
    3131  CONSTRAINT `внешка_сорта` FOREIGN KEY (`номер_сорта`) REFERENCES `wp_сорт` (`номер_сорта`) ON DELETE CASCADE ON UPDATE CASCADE
    3232) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
    33 ###
    34 
    35 Modification of the file wp-includes/class-wp-query.php in the function get_posts () somewhere 2513 string to find:
    36 
    37 ###
     33}}}
     34
     35Modification of the file `wp-includes/class-wp-query.php` in the function `get_posts()` somewhere 2513 string to find:
     36
     37
    3838{{{#!php
    3939<?php
     
    4141    // First get the IDs and then fill in the objects
    4242}}}
    43 ###
     43
    4444       
    4545and insert the following:
    4646
    47 ###
     47
    4848{{{#!php
    4949<?php
     
    130130}
    131131}}}
    132 ###
    133 
    134 To give the number of records in set_found_posts function ( $q, $limits ) change:
    135 
    136 ###
     132
     133
     134To give the number of records in `set_found_posts` function ( $q, $limits ) change:
     135
     136
    137137{{{#!php
    138138<?php
    139139$this->found_posts = $wpdb->get_var ( apply_filters_ref_array ( 'found_posts_query', [ 'SELECT FOUND_ROWS()', &$this ] ) );
    140140}}}
    141 ###
     141
    142142
    143143on:
    144144
    145 ###
     145
    146146{{{#!php
    147147<?php
     
    151151        $this->found_posts = $wpdb->get_var ( apply_filters_ref_array ( 'found_posts_query', [ 'SELECT FOUND_ROWS()', &$this ] ) );
    152152}}}
    153 ###
     153
    154154
    155155in cron you need to add one-time during installation, for example, the plugin task:
    156156
    157 ###
    158157{{{#!php
    159158<?php
    160159wp_schedule_event ( time (), 'wp_wc_updater_cron_interval', 'xray_sorting_event' );
    161160}}}
    162 ###
     161
    163162
    164163at the event:
    165164
    166 ###
     165
    167166{{{#!php
    168167<?php
    169168add_action ( 'xray_sorting_event', 'xray_sorting_event_func' );
    170169}}}
    171 ###
     170
    172171
    173172and, accordingly, the function itself:
    174173
    175 ###
     174
    176175{{{#!php
    177176<?php
     
    220219}
    221220}}}
    222 ###
     221
    223222
    224223I repeat that this is a working model. Can requires file. But all the errors which may be in code(commas, spaces, something like that) is the problem of copy-paste.