networking – Do I still need to modify PolKit in order to add a new Wifi connection without root?

After googling this problem, it appears (as of 7 YEARS ago) that the only way to allow users to change wifi networks is to modify PolKit (solution 1, solution 2).

Is this still the case with Ubuntu 20.04, without having to install further packages? Hard to believe that Ubuntu hasn’t made this more user-friendly yet over the last 7 years.

hash – Why is it impossible to modify a transaction in the blockchain?

Keep in mind two things:

  • Digest functions or hash functions ((see here))1

  • proof of work – Finding a hash that satisfies some conditions (see here)

Briefly, hash functions take a data structure (of any length) and give it a “fingerprint” in a default size. Minor changes to the input info change the fingerprint wildly.

Proof of work, in Bitcoin requires that you assemble a block (with all the transactions AND the previous block hash) and try out values (in the nounce field) until you reach a valid hash. It is called proof of work because the only way to reach a valid hash is by trying different inputs (thus working) until you reach it.

So, it is hard to change a tx after it has been confirmed as the latest block references the previous block’s hash, which in turn references the previous block and so on. If any data changes in any of those blocks, all subsequent hashes will change, leading the proof of work on all these blocks to become invalid.

The only way is to go all the way back and solve the PoW again for all blocks that had hashes affected.

In order to change a transactions confirmed 2 blocks ago (let´s call it block t-2), you would need to reassemble that block (t-2), solve the proof of work for it, then reassemble the subsequent block (t-1), solve it’s proof of work and only then you would be able to start working on block t. While you were spending energy/work on your new version of block t-2, other miners were already working hard on block t.

This race to revert something becomes exponentially more difficult the further back you go in the blockchain. In order to even start such an attack the attacker will need, at least 51% of the hashing power and probably way more the deeper “changing the record” goes.

Is it possible to completely modify a stock ROM, so that the phone company and system apps can’t track me?

I bought a device with a Chinese ROM. Now a while ago just shifted to the global ROM of that device.
Now what I want to do is –

  1. I want to modify the whole ROM, so that the ROM owner/the phone company can’t track me and can’t get any data or anything out of my phone.

  2. Apart from the phone company I also don’t want other system apps like google and others to track me. So either I want to remove them, or want to remove their data collection capability.

  3. To be more specific – I actually want to modify or build my own ROM – that won’t track me, collect any data and I’ll be able to limit the data collection policy of whatever app I install.

If my whole expectation can come true then that’s fantastic but if a portion of what I want is possible still that’s great. So help me out.
And thanks in Advance.

8 – When I create or modify a page, a random URL is created

Usually I set an URL with the title of the page, but even if I set the URL I would like, I got a 404 error if I try to visit a page using that URL, but if I try to visit the page from the contents list, the page has a random link that comes from another website installed on the server using drupal (different installation, not on multi-site).
Is there a way to get rid of this random-generation and use the URL I set?
Thanks in advane

hooks – Why can’t I modify $form in hook_form_FORM_ID_alter?

I want to modify the $form variable in an implementation of hook_form_FORM_ID_alter but can’t seem to be able to set the #prefix and #suffix variables on field widget.

/**
 * @file
 * Implementations Module Hooks
 */

use DrupalCoreFormFormStateInterface;

/**
 * Implements hook_form_FORM_ID_alter().
 *
 * Alter the node/create form for implementation types
 */
function implementations_form_node_implementation_form_alter(&$form, DrupalCoreFormFormStateInterface $form_state, $form_id) {
  $prefix = '<div style="display:none;">';
  $suffix = '</div>';

  $form('field_parent_idea')('widget')('#prefix') = $prefix;
  $form('field_parent_idea')('widget')('#suffix') = $suffix;

  dpm($form('field_parent_idea')('widget'));
  dpm($form('field_parent_idea')('widget')('#prefix'));
  dpm($form('field_parent_idea')('widget')('#suffix'));
}

When I navigate to node/add/implementation I would expect to see the value of $form('field_parent_idea')('widget') with the #prefix and #suffix variables set, but instead they’re blank. Here’s the relevant snippet showing the suffix/prefix values:

(#max_delta) => 0
(#prefix) => 
(#suffix) => 
(add_more) => Array

Why are they blank?

This is the full output of what I see.


Array
(
    (0) => Array
        (
            (target_id) => Array
                (
                    (#title) => stdClass Object
                        (
                            (__CLASS__) => DrupalCoreStringTranslationTranslatableMarkup
                            (translatedMarkup:protected) => 
                            (options:protected) => Array
                                (
                                )

                            (stringTranslation:protected) => stdClass Object
                                (
                                    (__CLASS__) => DrupalCoreStringTranslationTranslationManager
                                    (translators:protected) => Array
                                        (
                                            (30) => Array(1)
                                        )

                                    (sortedTranslators:protected) => Array
                                        (
                                            (0) => DrupalCoreStringTranslationTranslatorCustomStrings
                                        )

                                    (defaultLangcode:protected) => en
                                    (_serviceId) => string_translation
                                )

                            (string:protected) => @title (value @number)
                            (arguments:protected) => Array
                                (
                                    (@title) => Parent Idea
                                    (@number) => 1
                                )

                        )

                    (#title_display) => invisible
                    (#description) => 
                    (#field_parents) => Array
                        (
                        )

                    (#required) => 1
                    (#delta) => 0
                    (#weight) => 0
                    (#type) => entity_autocomplete
                    (#target_type) => node
                    (#selection_handler) => default:node
                    (#selection_settings) => Array
                        (
                            (target_bundles) => Array
                                (
                                    (idea) => idea
                                )

                            (sort) => Array
                                (
                                    (field) => _none
                                )

                            (auto_create) => 
                            (auto_create_bundle) => 
                            (match_operator) => CONTAINS
                            (match_limit) => 10
                        )

                    (#validate_reference) => 
                    (#maxlength) => 1024
                    (#default_value) => 
                    (#size) => 60
                    (#placeholder) => 
                )

            (_weight) => Array
                (
                    (#type) => weight
                    (#title) => stdClass Object
                        (
                            (__CLASS__) => DrupalCoreStringTranslationTranslatableMarkup
                            (translatedMarkup:protected) => 
                            (options:protected) => Array
                                (
                                )

                            (stringTranslation:protected) => stdClass Object
                                (
                                    (__CLASS__) => DrupalCoreStringTranslationTranslationManager
                                    (translators:protected) => Array
                                        (
                                            (30) => Array(1)
                                        )

                                    (sortedTranslators:protected) => Array
                                        (
                                            (0) => DrupalCoreStringTranslationTranslatorCustomStrings
                                        )

                                    (defaultLangcode:protected) => en
                                    (_serviceId) => string_translation
                                )

                            (string:protected) => Weight for row @number
                            (arguments:protected) => Array
                                (
                                    (@number) => 1
                                )

                        )

                    (#title_display) => invisible
                    (#delta) => 0
                    (#default_value) => 0
                    (#weight) => 100
                )

        )

    (#theme) => field_multiple_value_form
    (#field_name) => field_parent_idea
    (#cardinality) => -1
    (#cardinality_multiple) => 1
    (#required) => 1
    (#title) => Parent Idea
    (#description) => 
    (#max_delta) => 0
    (#prefix) => 

    (#suffix) => 

    (add_more) => Array
        (
            (#type) => submit
            (#name) => field_parent_idea_add_more
            (#value) => stdClass Object
                (
                    (__CLASS__) => DrupalCoreStringTranslationTranslatableMarkup
                    (translatedMarkup:protected) => 
                    (options:protected) => Array
                        (
                        )

                    (stringTranslation:protected) => 
                    (string:protected) => Add another item
                    (arguments:protected) => Array
                        (
                        )

                )

            (#attributes) => Array
                (
                    (class) => Array
                        (
                            (0) => field-add-more-submit
                        )

                )

            (#limit_validation_errors) => Array
                (
                    (0) => Array
                        (
                            (0) => field_parent_idea
                        )

                )

            (#submit) => Array
                (
                    (0) => Array
                        (
                            (0) => DrupalCoreFieldPluginFieldFieldWidgetEntityReferenceAutocompleteWidget
                            (1) => addMoreSubmit
                        )

                )

            (#ajax) => Array
                (
                    (callback) => Array
                        (
                            (0) => DrupalCoreFieldPluginFieldFieldWidgetEntityReferenceAutocompleteWidget
                            (1) => addMoreAjax
                        )

                    (wrapper) => field-parent-idea-add-more-wrapper
                    (effect) => fade
                )

        )

    (#after_build) => Array
        (
            (0) => Array
                (
                    (0) => DrupalCoreFieldPluginFieldFieldWidgetEntityReferenceAutocompleteWidget
                    (1) => afterBuild
                )

        )

    (#field_parents) => Array
        (
        )

    (#parents) => Array
        (
            (0) => field_parent_idea
        )

    (#tree) => 1
)

At first I thought that the issue was because I was setting on a nested array variable, but that’s exactly what the example code in the documentation does.


function hook_form_alter(&$form, DrupalCoreFormFormStateInterface $form_state, $form_id) {
  if (isset($form('type')) && $form('type')('#value') . '_node_settings' == $form_id) {
    $upload_enabled_types = Drupal::config('mymodule.settings')
      ->get('upload_enabled_types');
    $form('workflow')('upload_' . $form('type')('#value')) = array(
      '#type' => 'radios',
      '#title' => t('Attachments'),
      '#default_value' => in_array($form('type')('#value'), $upload_enabled_types) ? 1 : 0,
      '#options' => array(
        t('Disabled'),
        t('Enabled'),
      ),
    );

    // Add a custom submit handler to save the array of types back to the config file.
    $form('actions')('submit')('#submit')() = 'mymodule_upload_enabled_types_submit';
  }
}

rewrite rules – When I modify the product’s permalink, the pages stop working

I’m trying to modify the Woocommerce slugs with the object $wp_rewrite. When I modify it, everything works as I put it, but the rest as the pages stop working. Here the code:

public function rewrite(): void {
        global $wp_rewrite;

        $wp_rewrite->add_rewrite_tag("%category%", '((^/)+)', "category=")
        $wp_rewrite->add_permastruct( 'category', '%category%' );
        $wp_rewrite->add_rewrite_tag("%product_cat%", '((^/)+)', "product_cat=");
        $wp_rewrite->add_permastruct( 'product_cat', '%product_cat%' );
        $wp_rewrite->add_rewrite_tag("%product%", '((^/)+)', "product=");
        $wp_rewrite->add_permastruct( 'product', '%product_cat%/%product%' );
    
}

This function is executed with the hook init.

Does anyone know why it doesn’t work or is it a bug?

I also tried modifying the array of extra_permastructs, but it doesn’t work either.

audio – Modify sound of a website in Chrome (Specifically Whatsapp Web running in Chrome –app box)

I have several Whatsapp Webs running in Chrome apps on Windows 10 (i.e. argument "C:Program Files (x86)GoogleChromeApplicationchrome.exe" --app=https://web.whatsapp.com (I can pick which with profile-directory argument)

However, they all play the same new sound when a message is received. How can I swap the new message sound of an individual instance for my own custom sound?

custom post types – How to modify a query in functions.php to involve both post_title and fields from wp_postmeta?

On my Fusion Builder powered WP website I have created a CPT called movies. The title of each post (i.e. each movie) has a post_title property which is located in wp_posts table, other custom properties like production_date (int(8)) and movie_subtitle (‘varchar(255)’) are located inside wp_postmeta table.

Now, I have an archive page www.mydomain.com/movies which lists all posts of type movies and I want to be able to filter movies based on production_date‘s year and a string typed into a search bar.

The url like this: www.mydomain.com/movies?production_year=2004&search=batman would filter out only those movies which have wp_postmeta.production_year as 2004 and which contain a string batman in either wp_posts.post_title or wp_postmeta.movie_subtitle

This is one of my movies:

wp_posts.post_title: Batman & Robin

wp_postmeta.production_date: 20041803 (i.e. 18th March 2004)

wp_postmeta.movie_subtitle: Joker’s revenge

functions.php

<?php
class searchMovies{
 
    function __construct(){
        add_action( 'pre_get_posts', array( $this, 'filterquery' ) );
    }

    function filterquery( $query ){
        global $pagenow;
        global $typenow;

        if ( is_archive()
            && $query->is_main_query()
            && isset( $_GET('production_year') )
            && !empty( $_GET('production_year') )
            && isset( $_GET('search') )
            && !empty( $_GET('search') )
        ) {
            $query->set(
                'meta_query',
                array(
                    'relation' => 'AND',
                    array(
                        'key' => 'production_date',
                        'value' => array(sanitize_text_field( $_GET('production_year') . '0101'), sanitize_text_field( $_GET('production_year')) . '1231'),
                        'type' => 'DATE',
                        'compare' => 'BETWEEN'
                    ),
                    array(
                        'relation' => 'OR', 
                        array(
                            'key' => 'post_title',
                            'value' => $_GET('search'),
                            'compare' => 'LIKE'
                        ),
                        array(
                            'key' => 'movie_subtitle',
                            'value' => $_GET('search'),
                            'compare' => 'LIKE'
                        )
                    )
                )
            );
        }

        // THIS DOES NOT SEEM TO WORK HERE ↓↓↓
        if ( is_archive()
            && $query->is_main_query()
            && isset( $_GET('search') )
            && !empty( $_GET('search') )
            && ( !isset( $_GET('production_year') ) || empty( $_GET('production_year') ) )
        ) {
            $query->set(
                'meta_query',
                array(
                    'relation' => 'OR',
                    array(
                        'key' => 'post_title',
                        'value' => $_GET('search'),
                        'compare' => 'LIKE'
                    ),
                    array(
                        'key' => 'movie_subtitle',
                        'value' => $_GET('search'),
                        'compare' => 'LIKE'
                    )
                )
            );
        }

        if ( is_archive()
            && $query->is_main_query()
            && ( ! empty( $_GET('production_year') ) )
        ) {
            $query->set(
                'meta_query',
                array(
                    array(
                        'key' => 'production_date',
                        'value' => array(sanitize_text_field( $_GET('production_year') . '0101'), sanitize_text_field( $_GET('production_year')) . '1231'),
                        'type' => 'DATE',
                        'compare' => 'BETWEEN'
                    )
                )
            );
        }
        return $main_query;
    }
}

new searchMovies();

PROBLEM:

This works OK: www.mydomain.com/movies?production_year=2004&search=batman

This DOES NOT work: www.mydomain.com/movies?search=batman

Apparently something is wrong with my 2nd if condition inside my function filterquery() in functions.php, but I don’t know what is wrong.