“Cannot use import statement outside a module” JS error while adding a custom meta block?

I am following the “Store Post Meta with a Block” guide from the official Block Editor Handbook to add a custom post meta block using the supplied sample code (below). However, the block does not load and a Uncaught SyntaxError: Cannot use import statement outside a module error is displayed from the myguten.js file in the console when loading the block editor page.

How can I resolve this? Is the WordPress Block Editor Handbook code incorrect?

myguten-meta-block.php:

// register custom meta tag field
function myguten_register_post_meta() {
    register_post_meta( 'post', 'myguten_meta_block_field', array(
        'show_in_rest' => true,
        'single' => true,
        'type' => 'string',
    ) );
}
add_action( 'init', 'myguten_register_post_meta' );

function myguten_enqueue() {
    wp_enqueue_script(
        'myguten-script',
        plugins_url( 'myguten.js', __FILE__ ),
        array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-data', 'wp-core-data', 'wp-block-editor' )
    );
}
add_action( 'enqueue_block_editor_assets', 'myguten_enqueue' );

myguten.js:

import { registerBlockType } from '@wordpress/blocks';
import { TextControl } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { useEntityProp } from '@wordpress/core-data';
import { useBlockProps } from '@wordpress/block-editor';
 
registerBlockType( 'myguten/meta-block', {
    title: 'Meta Block',
    icon: 'smiley',
    category: 'text',
 
    edit( { setAttributes, attributes } ) {
        const blockProps = useBlockProps();
        const postType = useSelect(
            ( select ) => select( 'core/editor' ).getCurrentPostType(),
            ()
        );
        const ( meta, setMeta ) = useEntityProp( 'postType', postType, 'meta' );
        const metaFieldValue = meta( 'myguten_meta_block_field' );
        function updateMetaValue( newValue ) {
            setMeta( { ...meta, myguten_meta_block_field: newValue } );
        }
 
        return (
            <div { ...blockProps }>
                <TextControl
                    label="Meta Block Field"
                    value={ metaFieldValue }
                    onChange={ updateMetaValue }
                />
            </div>
        );
    },
 
    // No information saved to the block
    // Data is saved to post meta via the hook
    save() {
        return null;
    },
} );

linux – ffmpeg segfault at 0 error 4 in libx265.so

While using ffmpeg 4.2 to transcode some files into h265 I get the below error repeatedly. I’ve tried two different operating systems with the same result.

(84364.574137) ffmpeg(2257282): segfault at 0 ip 00007f4f0629d440 sp 00007f4e0f7fd020 error 4 in libx265.so.179(7f4f0623b000+116f000) (84364.593586) Code: 85 75 0c 00 00 85 c0 0f 85 7b 03 00 00 48 8b 43 08 f2 0f 10 83 58 01 00 00 4c 8b 80 98 00 00 00 4c 8b 48 10 8b 80 e8 08 00 00 <49> 8b 08 49 8b 31 48 8b 39 48 8b 16 f2 0f 10 9e c0 05 00 00 f2 0f (89693.205703) ffmpeg(2349621): segfault at 0 ip 00007fdc4116b440 sp 00007fdbd1d6f020 error 4 in libx265.so.179(7fdc41109000+116f000) (89693.225147) Code: 85 75 0c 00 00 85 c0 0f 85 7b 03 00 00 48 8b 43 08 f2 0f 10 83 58 01 00 00 4c 8b 80 98 00 00 00 4c 8b 48 10 8b 80 e8 08 00 00 <49> 8b 08 49 8b 31 48 8b 39 48 8b 16 f2 0f 10 9e c0 05 00 00 f2 0f (90604.112280) ffmpeg(2388193): segfault at 0 ip 00007f41326b3440 sp 00007f40a15a6020 error 4 in libx265.so.179(7f4132651000+116f000) (90604.131793) Code: 85 75 0c 00 00 85 c0 0f 85 7b 03 00 00 48 8b 43 08 f2 0f 10 83 58 01 00 00 4c 8b 80 98 00 00 00 4c 8b 48 10 8b 80 e8 08 00 00 <49> 8b 08 49 8b 31 48 8b 39 48 8b 16 f2 0f 10 9e c0 05 00 00 f2 0f (95462.996431) ffmpeg(2477426): segfault at 0 ip 00007f43d7eef440 sp 00007f430fffe020 error 4 in libx265.so.179(7f43d7e8d000+116f000) (95463.015906) Code: 85 75 0c 00 00 85 c0 0f 85 7b 03 00 00 48 8b 43 08 f2 0f 10 83 58 01 00 00 4c 8b 80 98 00 00 00 4c 8b 48 10 8b 80 e8 08 00 00 <49> 8b 08 49 8b 31 48 8b 39 48 8b 16 f2 0f 10 9e c0 05 00 00 f2 0f

It may be related to the hardware I’m running (threadripper 1950x) as it doesn’t seem to be happening on my xeon however reading online most answers suggest it’s a software related issue to do with unreferenced pointers, memory leaks or similar.

The memory I’ve got has passed multiple hours of memory tests also.

Can anyone suggest how I might get to the bottom of this?

Many thanks,

Marshalleq

8 – Error Passing Extra Parameter to Custom Form

I have a simple custom form that works until I try to add a custom parameter for my module called “forms_admin”.

These are the contents of my forms_admin.routing.yml

forms_admin.settings:
  path: 'admin/config/system/forms/{arg1}'
  defaults:
    _form: 'Drupalforms_adminFormFormSettings'
    _title: 'Forms Settings'
  requirements:
    _permission: 'access content'

This is a relevant part of my FormSettings.php file (Currently do not have any custom Validation or Submit actions)

public function buildForm(array $form, FormStateInterface $form_state, $arg1 = NULL) {
    $form('title') = array(
      '#type' => 'textfield',
      '#title' => t('Title'),
      '#required' => TRUE,
    );

    $form('submit') = array(
      '#type' => 'submit',
      '#value' => t('Submit'),
    );


return $form;
}

And my third file is: forms_admin.links.menu.yml

forms_admin.config:
  title: Forms
  route_name: forms_admin.settings
  parent: system.admin_config_system
  description: 'Forms settings'
  weight: 0

The moment that I add {arg1} to my forms_admin.routing.yml and , $arg1 = NULL to my FormSettings.php file, I am unable to acces the website.


I receive a white page with the error that states:

The website encountered an unexpected error. Please try again later.

After removing arg1 from my two files and going to the Recent Log messages, this is the error I receive:

SymfonyComponentRoutingExceptionMissingMandatoryParametersException: Some mandatory parameters are missing (“arg1”) to generate a URL for route “forms_admin.settings”. in DrupalCoreRoutingUrlGenerator->doGenerate() (line 182 of /var/www/test_site/docroot/core/lib/Drupal/Core/Routing/UrlGenerator.php).


I have tried changing arg1 to other names, not making $arg1 = NULL, etc. and I receive an error every time.

What am I missing?

nginx – CORS error after setting up self hosted Plausible

I set up Plausible and in the end, it seems not to be working because of a CORS error.

Failed to load resource: net::ERR_FAILED (index):1 Access to
XMLHttpRequest at ‘https://example.com/api/event’ from origin
‘https://www.example.com’ has been blocked by CORS policy: No
‘Access-Control-Allow-Origin’ header is present on the requested
resource. example.com/api/event:1 Failed to load resource:
net::ERR_FAILED

I have searched and found this solved issue but authentication doesn’t seem to be my case.

Plausible script in the header of example.com:

<script async defer="defer" data-domain="example.com" src="https://stats.example.com/js/plausible.js"></script>

Nginx Plausible server block:

server {
server_name stats.example.com www.stats.example.com;

        location / {
                proxy_pass http://127.0.0.1:8000;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

    listen (::):443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/stats.example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/stats.example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
if ($host = www.stats.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot


    if ($host = stats.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        server_name stats.example.com www.stats.example.com;

        listen 80;
        listen (::):80;
    return 404; # managed by Certbot




}

Please, do you have any idea where I have messed up?

Javascript y firebase, tengo un problema ya que estoy tratando de configurar el botón eliminar pero, me está generando un error, el cual no he podido

Tengo una base de datos en firebase, y cargué los registros en una tabla a través de JavaScript en una aplicación web, al momento de presionar clic en el botón eliminar me genera un error y no me elimina el registro que seleccioné, el error lo genera específicamente al en ref() que está en la siguiente línea: firebase.database().ref(‘students/${uid}’).remove(), si yo le quito /${uid} me elimina todos los registros pero necesito eliminar solo el registro seleccionado. Agradezco su ayuda.

const deleteStudent = (Uid) => {
firebase.database().ref(‘students/${uid}’).remove()//ESTA ES LA PARTE QUE ESTÁ GENERANDO EL ERROR, NO ELIMINA EL SEGISTRO SELECCIONADO

}

window.addEventListener(‘DOMContentLoaded’, async(e) => {

await studentRef.on('value', (students) => {
    studentsTable.innerHTML = ``
    students.forEach(student => {
        let studentData = student.val()
        studentsTable.innerHTML += `<tr>
        
        <th>1</th>
        <td>${studentData.Documento}</td>
        <td>${studentData.Nombres}</td>
        <td>${studentData.Apellidos1}</td>
        <td>${studentData.Apellidos2}</td>
        <td>${studentData.Grado}</td>
        <td>${studentData.Jornada}</td>
        <td>${studentData.Rh}</td>
        <td>${studentData.Acudiente}</td>
        <td>${studentData.Direccion}</td>
        <td>${studentData.Zona}</td>
        
        <td>

        <button class="button is-warning" id="${studentData.Uid}">
            <i class="fas fa-pencil-alt" > </i>
        </button>
        <button class="button is-danger" id="${studentData.Uid}">
            <i class="fas fa-trash-alt " > </i>
        </button>

    </td>
    </tr>`
        const deleteButtons = document.querySelectorAll('.is-danger')
        deleteButtons.forEach((button) => {
            button.addEventListener('click', (e) => {
                deleteStudent(e.target.dataset.id)


            })
        })

    })
})

})
introducir la descripción de la imagen aquí

Error: "Cannot read property apply of undefined" while running gulp commands for SPFx webpart

I am trying to do a sample webpart.

While running any of the below commands, it is showing the same error as shown in the image:

  • gulp trust-dev-cert
  • gulp serve
  • gulp build

enter image description here

Can anyone help me on this error?

java – Error al sobrescribir un método

Quiero sobrescribir el siguiente método:

@Override
public E put(E hijo, E padre) {}

Pero al añadir el @Override me dice lo siguiente:
The method put(E, E) of type ArbolTabulado must override or implement a supertype method

Y al quitarlo:
Name clash: The method put(E, E) of type ArbolTabulado has the same erasure as put(Object, Object) of type AbstractMap but does not override it

¿Por qué no detecta bien cuando lo sobrescribo?¿Y como podría solucionarlo?

jakarta ee – problem with recapcha ERROR for site owner: Invalid key type

Im sure that my api keys are right , my domain is checked.
I used 127.0.0.1 as a domain to develope every state of recapcha.
Recapcha return 0.9 and i set threshold = 0.99 to test the recapcha .
but it shows me everytime this ERROR for site owner: Invalid key type.
It seems problem from recapcahjs.
I’ve no idea.

ACPI BIOS (bug), ACPI ERROR: Aborting method, AE_NOT_FOUND

my root partition is getting bigger and bigger due to "acpi error" "acpi bios (bug)"" "AE_NOT_FOUND" errors. My problem is similar to this; var/log/syslog growing indefinitely in size . But i dont know hot ro resolve it. I post a photo below of the terminal output when I run "tail -f /var/log/syslog". thank kou.

enter image description here

pygame – What is the error?

Here is my code on pygame and I’m not sure about the error I’m seeing… If possible can anyone explain to me what is the problem in my code??

code:

import pygame

pygame.init()
  
white = (255, 255, 255)
green = (0, 255, 0)
blue = (0, 0, 128)
black = (0, 0, 0)
red = (255, 0, 0)

w = 500
h = 500

x = 15
y = 480

vel = 5
screen = pygame.display.set_mode((500, 500))

square = pygame.image.load(r'/Users/lanik2009/Downloads/square.PNG')
square = pygame.transform.scale(square, (46, 40))
triangle = pygame.image.load(r'/Users/lanik2009/Downloads/triangle.PNG')
triangle = pygame.transform.scale(triangle, (46, 40))

def player():
    screen.fill(black)
    screen.blit(triangle, (100, 460))
    screen.blit(square, (300, 460))
    
jump = False

obstacles = pygame.sprite.Group()

obstacles.add(square)
obstacles.add(triangle)

running = True

while running:
      
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    keys = pygame.key.get_pressed()
    
    if keys(pygame.K_LEFT):
        x -= vel

    if keys(pygame.K_RIGHT):
        x += vel

    if jump == False:
        y = 480
        
    if keys(pygame.K_UP):
        y -= 40
        jump = False
        
    if event.type == pygame.KEYUP:
        jump = False
        
    player()
    
    player = pygame.draw.circle(screen, white, (x, y), 10, 500)
    pygame.display.update()

    hits = pygame.sprite.spritecollide(player, obstacles, False)
    if hits:
        running = False

pygame.quit()