cd /var/www/clients/client0/web4/web/wp-content/plugins/video-importer/ python3 - <<'EOF' path = "video-importer.php" with open(path, "r") as f: content = f.read() old = """ public static function get_known_video_ids( $source_id ) { // TODO: $this->log( 'Getting known video IDs' ); global $wpdb; $known_ids = $wpdb->get_col( " SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='rfvi_video_id' " ); // TODO: $this->log( 'Done getting ' . count( $known_ids ) . ' known video IDs' ); return $known_ids; }""" new = """ public static function get_known_video_ids( $source_id ) { static $known_ids = null; if ( $known_ids !== null ) { return $known_ids; } global $wpdb; $known_ids = $wpdb->get_col( " SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='rfvi_video_id' " ); return $known_ids; }""" count = content.count(old) print(f"Found {count} match(es)") if count == 1: content = content.replace(old, new) with open(path, "w") as f: f.write(content) print("Replaced successfully") else: print("Did not replace — match count was not exactly 1, check manually") EOF 8222Познание | Bibliata.TV