meta_query order by date present -> future then show null

Thanks for taking the time to read this. I’ve been struggling with a meta_query for an events site I’m working on.

I have used ACF to create a field for date start and date end, but not all events will have a date.

What I’m trying to achieve, is when you go to the archive or tax view, the first thing you see are the posts that have a date assigned, in order from today’s date into the future. Then after those dated events have been output, to cycle through all empty date posts.

So far I have the below in my functions.php file. This kind of works, but in the wrong order. So the correct events that are dated are output and in the right order. But only after the null valued items have output. I thought that may be because of the ordering in the arrays themselves, so moved the date ordered array to the end. That had no effect.

$  query->set( 'post_type', 'courses' ); $  query->set( 'meta_query', array(     'relation' => 'OR',     array(         'key'        => '_course_date_from',         'compare'    => '=',         'value'      => '',     ),     array(         'key'     => '_course_date_from',         'compare' => '>=',         'value'   => date('Ymd'),     ) ) ); $  query->set( 'orderby', 'meta_value title' ); $  query->set( 'order', 'ASC' ); 

Thanks for your time. Ben.

Null byte injection using JSON

I’m trying to make a chatroom for my university, It takes username in JSON, and then stores it in an array, then takes it to DB for keeping logs, but the thing is, that array also has a "status" key, whose value is set to guest my default, but is set to ADMIN if I log in or any member from my team logs in. I know that the idea of storing "status" with username is bad but I just started working on the project. I want to confirm that is it possible to inject NULL byte using username field via JSON and add another key with same name "status" to gain admin privileges??

Will Postgres use a multi-column index when setting multiple colums not null?

Typically, when I set a column not null, if it doesn’t have an index then I add it first, so that postgres can (hopefully) use the index while doing the table scan while locking the table, so that the table is locked for a shorter amount of time.

I want to set several columns not null, like so:

alter table foos   alter column bar1 set not null   alter column bar2 set not null   alter column bar3 set not null   alter column bar4 set not null; 

If I make a multicolumn index for these columns, will postgres use it when scanning the locked table before making this alteration?

CREATE INDEX CONCURRENTLY my_index on foos (bar1, bar2, bar3, bar4); 

What if I made a partial index on IS NULL (or, IS NOT NULL)

CREATE INDEX CONCURRENTLY my_index on foos (bar1, bar2, bar3, bar4) where bar1 is null and bar2 is null and bar3 is null and bar4 is null; 

How to create a Datum for database NULL in PostgreSQL a server side C function?

I was just wondering how to create a Datum for the database NULL value in PostgreSQL?

I known there is PG_RETURN_NULL() for returning a database NULL in a LANGUAGE C function. But I just want to create a Datum for NULL, e.g. to be stored in an array (or record). Should I just use (Datum) 0?

(This is with PostgreSQL 12)

MySQL trigger calling stored procedure always get null value for out parameter of stored procedure

My stored procedure OUT parameter, always return a null value.

Here is sample Table, Trigger and Procedure code.

Table: test
Columns:

  • id - Int
  • status - enum(‘pass’, ‘fail’)

    • status - enum(‘pass’, ‘fail’) (null is allowed)

Values in a table:

id  |  status 1   |  null 

Trigger:

create trigger BEFORE_UPDATE_TEST before update on `test` for each row begin      call Test_BEFORE_UPDATE_TEST(old.id, @updatedStatus);         ## I always get @updatedStatus null/nil      if (@updatedStatus is not null and @updatedStatus <> new.status) then         set new.status = @updatedStatus;     end if;  end; 

Procedure:

create procedure Test_BEFORE_UPDATE_TEST (   IN id int(5),   OUT status enum(‘pass’, ‘fail’) ) begin    @status = ‘pass’;  END; 

What is wrong with this code, as I get unexpected result as null in the value @updatedStatus, which should be 'pass'.

I looked around following QAs on dba.stackexchange but could’t find solution.

I use MySQLWorkbench in MacOS Catalina and version of MySQL is 8.0.19.

add_action(‘the_content’, ‘my_plugin_content’) is null

I am creating in personal plugin where I recover data from a personal table. Con add_action(‘the_content’, ‘my_plugin_content’); posso far vedere il contenuto in una pagina. I would like to save the content in wp_posts with add_filter (‘save_post’, ‘my_plugin_content’), but the content is empty.

function my_plugin_content($  content){      $  current_page = $  wp->request;      include_once(plugin_dir_path( __FILE__ ).'views/view.php');      $  obj = new Loader;      $  content.=$  obj->controller($  current_page);      $  my_post = array();       $  my_post['ID'] = $  post->ID;      $  my_post['post_content']=$  cont; } 

in another file I run the data recovery query that I refer to the file loader that loads the views

File loader

public function view($  view, array $  dati){       require(DIR_PLUGIN.'views/'.$  view.'_v.php'); } 

File view

    <?php foreach($  dati as $  p){  echo '<p><strong>'.$  p->NAME.'</strong></p>; }?> 

Using Chacha20 with a NULL nonce

I am new to ChaCha20. From the RFC —

The inputs to ChaCha20 are:

o A 256-bit key, treated as a concatenation of eight 32-bit little- endian integers.

o A 96-bit nonce, treated as a concatenation of three 32-bit little- endian integers.

o A 32-bit block count parameter, treated as a 32-bit little-endian integer.

Now looking at Apple’s CryptoKit the counter is not provided as an input option. They implement the counter underneath the hood. For the sake of this question, let’s assume the counter is implemented properly.

The key is set randomly for the encryption session (which is encrypting network data).

Now if I use a NULL nonce, the counter is still used. Will it be ok?

Is the max number of messages that can be encrypted this way before the key must be changed 2^32? or is it the max number of bytes?

Why do I get this warning when using a null conditional operator?

In the OnTriggerEnter2D function of my Bullet script, I have the following code:

private void OnTriggerEnter2D(Collider2D other) {      if (other.CompareTag("Enemy"))      {          var enemy = other.GetComponent<Enemy>();          enemy?.Death();      } } 

The reason for the null conditional operator (the question mark) in enemy?.Death() is because the Death function actually destroys the Enemy component script, so it suppresses an error when the bullet hits the enemy again. It’s supposed to be shorthand for:

if (enemy != null)     enemy.Death(); 

The code works; the error is suppressed. However, the IDE that I’m using, Jetbeans Rider, gives the following warning:

‘?.’ on a type deriving from ‘UnityEngine.Object’ bypasses the lifetime check on the underlying Unity object.

What does that mean exactly? Should I continue using the null conditional operator?

add_submenu_page returns null

After creating a parent admin menu item, which works fine, I fail to add a submenu page. Trying to var_dump the return value of add_submenu_page() I get ‘null’.

My functions are:

    /**      * Register the admin menu page      *       * @since   1.0.0      */     public function add_admin_menu() {         add_menu_page( 'WPQuotes', 'WPQuotes', 'manage_options', 'wp-quotes-plugin', 'wpq_admin_settings_page_main', 'dashicons-networking' );         add_submenu_page( 'wp-quotes-plugin', 'New WPQ Form', 'New WPQ Form', 'manage-options', 'wpq-new-form', 'wpq_admin_settings_page_new_form');     }      public function run_all(){         add_action( 'admin_menu', array($  this, 'add_admin_menu'), 10 );     } 

twentysixteen child theme – responsive menu – ham icon button not working – Cannot read property ‘classList’ of null

I am trying to convert this site http://buildandtest.atspace.cc/ into twentysixteen child theme. It appears that /js/menu.js in my child theme is not working as nothing happens when the ham icon button is clicked (pls.see my site link above to check correct behavior). On inspecting via Google Chrome Inspect I am getting the following errors:

Uncaught TypeError: Cannot read property ‘classList’ of null at mediaqueryresponse (menu.js?ver=5.3.2:19) at menu.js?ver=5.3.2:10 at menu.js?ver=5.3.2:31 mediaqueryresponse @ menu.js?ver=5.3.2:19 (anonymous) @ menu.js?ver=5.3.2:10 (anonymous) @ menu.js?ver=5.3.2:31

Any advice is appreciated

header.php in child theme

<header class="header" id='myTopnav'>  <?php  wp_nav_menu(              array(                   'theme_location'=> 'topnav',                   'container' => 'nav',                   'menu_class' => 'topnav',                   'menu_id'    => 'myTopnav',                   )  );?>  <button class="ham-icon"><span class="fa fa-bars fa-2x"></span></button>  </header> 

/js/menu.js in child theme

(function () {   var mql = window.matchMedia("screen and (max-width: 960px)");   //detect media query    var navTop = document.querySelector(".header");   //return first element within the document that matches .header    var toggle = document.querySelector(".ham-icon");    mediaqueryresponse(mql);   //ensures that addListener function is executed when the page loads, by default addListener only fires when state of the window changes   mql.addListener(mediaqueryresponse);    function mediaqueryresponse(mql) {     if (mql.matches) {       toggle.addEventListener("click", clickMenu);       //if media query matches, execute click or clickMenu event     } else {       navTop.classList.remove("responsive");       //otherwise remove .responsive       toggle.removeEventListener("click", clickMenu);       //and remove EventListener     }    }    function clickMenu() {     navTop.classList.toggle("responsive");   }  })();